WIP...
This commit is contained in:
parent
e7d2f8f6c7
commit
57d7e7a3ce
17 changed files with 608 additions and 500 deletions
|
|
@ -117,6 +117,7 @@ impl Connection {
|
|||
|
||||
fn get(&self) -> Result<PooledConnection<SqliteConnectionManager>> {
|
||||
let con = self.pool.get()?;
|
||||
// ('foreign_keys' is ON by default).
|
||||
con.pragma_update(None, "synchronous", "NORMAL")?;
|
||||
Ok(con)
|
||||
}
|
||||
|
|
@ -124,13 +125,12 @@ impl Connection {
|
|||
/// Called after the connection has been established for creating or updating the database.
|
||||
/// The 'Version' table tracks the current state of the database.
|
||||
fn create_or_update_db(&self) -> Result<()> {
|
||||
// Check the Database version.
|
||||
let mut con = self.get()?;
|
||||
con.pragma_update(None, "journal_mode", "WAL")?;
|
||||
con.pragma_update(None, "journal_mode", "WAL")?; // Note: use "WAL2" when available.
|
||||
|
||||
let tx = con.transaction()?;
|
||||
|
||||
// Version 0 corresponds to an empty database.
|
||||
// Check current database version. (Version 0 corresponds to an empty database).
|
||||
let mut version = {
|
||||
match tx.query_row(
|
||||
"SELECT [name] FROM [sqlite_master] WHERE [type] = 'table' AND [name] = 'Version'",
|
||||
|
|
@ -456,11 +456,14 @@ impl Connection {
|
|||
match con
|
||||
.query_row(
|
||||
"SELECT [Recipe].[id] FROM [Recipe]
|
||||
INNER JOIN [Image] ON [Image].[recipe_id] = [Recipe].[id]
|
||||
INNER JOIN [Group] ON [Group].[recipe_id] = [Recipe].[id]
|
||||
WHERE [Recipe].[user_id] = ?1
|
||||
AND [Recipe].[estimate_time] = NULL
|
||||
AND [Recipe].[description] = NULL",
|
||||
LEFT JOIN [Image] ON [Image].[recipe_id] = [Recipe].[id]
|
||||
LEFT JOIN [Group] ON [Group].[recipe_id] = [Recipe].[id]
|
||||
WHERE [Recipe].[user_id] = ?1
|
||||
AND [Recipe].[title] = ''
|
||||
AND [Recipe].[estimate_time] IS NULL
|
||||
AND [Recipe].[description] = ''
|
||||
AND [Image].[id] IS NULL
|
||||
AND [Group].[id] IS NULL",
|
||||
[user_id],
|
||||
|r| Ok(r.get::<&str, i64>("id")?),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue