aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/store/sqlite.rs89
1 files changed, 72 insertions, 17 deletions
diff --git a/src/app/store/sqlite.rs b/src/app/store/sqlite.rs
index 67ec046..0fac2cd 100644
--- a/src/app/store/sqlite.rs
+++ b/src/app/store/sqlite.rs
@@ -199,6 +199,7 @@ impl SQLiteStore {
}
}
+ /// Attempts to get the migration list from the database; if that fails, creates the migration table and returns an empty vec
fn exec_migration_list(&mut self) -> Result<Vec<SQLiteMigration>, ContextError> {
let conn = self.get_connection()?;
@@ -303,11 +304,29 @@ impl SQLiteStore {
let mut statement = conn.prepare(Self::FIDUCIARY_ACCOUNT_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
- (":fiduciary_account_id", i64::from(account.fiduciary_account_id).into()),
- (":fiduciary_account_name", account.fiduciary_account_name.clone().into()),
- (":fiduciary_account_number", i64::try_from(account.fiduciary_account_number)?.into()),
- (":fiduciary_account_description", account.fiduciary_account_description.clone().into()),
- (":fiduciary_account_created_timestamp", account.fiduciary_account_created_timestamp.to_string().into()),
+ (
+ ":fiduciary_account_id",
+ i64::from(account.fiduciary_account_id).into(),
+ ),
+ (
+ ":fiduciary_account_name",
+ account.fiduciary_account_name.clone().into(),
+ ),
+ (
+ ":fiduciary_account_number",
+ i64::try_from(account.fiduciary_account_number)?.into(),
+ ),
+ (
+ ":fiduciary_account_description",
+ account.fiduciary_account_description.clone().into(),
+ ),
+ (
+ ":fiduciary_account_created_timestamp",
+ account
+ .fiduciary_account_created_timestamp
+ .to_string()
+ .into(),
+ ),
])?;
Ok(())
}
@@ -340,11 +359,26 @@ impl SQLiteStore {
let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
- (":equity_symbol_id", i64::try_from(symbol.equity_symbol_id)?.into()),
- (":equity_symbol_name", symbol.equity_symbol_name.clone().into()),
- (":equity_symbol_type", symbol.equity_symbol_type.to_string().into()),
- (":equity_symbol_managing_company", symbol.equity_symbol_managing_company.clone().into()),
- (":equity_symbol_created_timestamp", symbol.equity_symbol_created_timestamp.to_string().into()),
+ (
+ ":equity_symbol_id",
+ i64::try_from(symbol.equity_symbol_id)?.into(),
+ ),
+ (
+ ":equity_symbol_name",
+ symbol.equity_symbol_name.clone().into(),
+ ),
+ (
+ ":equity_symbol_type",
+ symbol.equity_symbol_type.to_string().into(),
+ ),
+ (
+ ":equity_symbol_managing_company",
+ symbol.equity_symbol_managing_company.clone().into(),
+ ),
+ (
+ ":equity_symbol_created_timestamp",
+ symbol.equity_symbol_created_timestamp.to_string().into(),
+ ),
])?;
Ok(())
}
@@ -381,13 +415,34 @@ impl SQLiteStore {
let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
- (":equity_change_event_id", i64::try_from(event.equity_change_event_id)?.into()),
- (":fiduciary_account_id", i64::from(event.fiduciary_account_id).into()),
- (":equity_symbol_id", i64::try_from(event.equity_symbol_id)?.into()),
- (":equity_change_quantity", event.equity_change_quantity.to_f64().into()),
- (":equity_change_cost_basis", event.equity_change_cost_basis.to_f64().into()),
- (":equity_change_type", event.equity_change_type.to_string().into()),
- (":equity_change_timestamp", event.equity_change_timestamp.to_string().into()),
+ (
+ ":equity_change_event_id",
+ i64::try_from(event.equity_change_event_id)?.into(),
+ ),
+ (
+ ":fiduciary_account_id",
+ i64::from(event.fiduciary_account_id).into(),
+ ),
+ (
+ ":equity_symbol_id",
+ i64::try_from(event.equity_symbol_id)?.into(),
+ ),
+ (
+ ":equity_change_quantity",
+ event.equity_change_quantity.to_f64().into(),
+ ),
+ (
+ ":equity_change_cost_basis",
+ event.equity_change_cost_basis.to_f64().into(),
+ ),
+ (
+ ":equity_change_type",
+ event.equity_change_type.to_string().into(),
+ ),
+ (
+ ":equity_change_timestamp",
+ event.equity_change_timestamp.to_string().into(),
+ ),
])?;
Ok(())
}