mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
add nullable value support, change field datatype
This commit is contained in:
parent
6a4790c92b
commit
a2643d953d
3 changed files with 11 additions and 4 deletions
|
|
@ -151,6 +151,7 @@ impl Request {
|
||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
|
// Keep value in memory until operation complete
|
||||||
let text = self.widget.text();
|
let text = self.widget.text();
|
||||||
|
|
||||||
match Database::add(
|
match Database::add(
|
||||||
|
|
|
||||||
|
|
@ -93,10 +93,16 @@ impl Widget {
|
||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_item_id: &i64,
|
app_browser_window_tab_item_id: &i64,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
|
// Keep value in memory until operation complete
|
||||||
|
let title = self.gobject.title();
|
||||||
|
|
||||||
match Database::add(
|
match Database::add(
|
||||||
transaction,
|
transaction,
|
||||||
app_browser_window_tab_item_id,
|
app_browser_window_tab_item_id,
|
||||||
Some(&self.gobject.title().to_string()),
|
match title.is_empty() {
|
||||||
|
true => None,
|
||||||
|
false => Some(title.as_str()),
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// let id = Database::last_insert_id(transaction);
|
// let id = Database::last_insert_id(transaction);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use sqlite::{Error, Transaction};
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
// pub app_browser_window_tab_item_id: i64, not in use
|
// pub app_browser_window_tab_item_id: i64, not in use
|
||||||
pub title: Option<String>,
|
pub title: Option<String>, // can be stored as NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
|
|
@ -17,7 +17,7 @@ impl Database {
|
||||||
(
|
(
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
`app_browser_window_tab_item_id` INTEGER NOT NULL,
|
`app_browser_window_tab_item_id` INTEGER NOT NULL,
|
||||||
`title` TEXT
|
`title` VARCHAR(1024)
|
||||||
)",
|
)",
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
@ -26,7 +26,7 @@ impl Database {
|
||||||
pub fn add(
|
pub fn add(
|
||||||
tx: &Transaction,
|
tx: &Transaction,
|
||||||
app_browser_window_tab_item_id: &i64,
|
app_browser_window_tab_item_id: &i64,
|
||||||
title: Option<&String>,
|
title: Option<&str>,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"INSERT INTO `app_browser_window_tab_item_widget` (
|
"INSERT INTO `app_browser_window_tab_item_widget` (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue