From 361efe60a344d22eed56b4cc2e346415841a3f96 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sat, 18 Nov 2023 20:41:04 -0500 Subject: [PATCH] Use semicolons instead of commas as separator in sqlite string --- src/datasets.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/datasets.rs b/src/datasets.rs index ee13458..d726159 100644 --- a/src/datasets.rs +++ b/src/datasets.rs @@ -128,9 +128,9 @@ pub fn new_dataset( volatility REAL NOT NULL, sets_won TEXT NOT NULL, - sets_count_won INTEGER AS (length(sets_won) - length(replace(sets_won, ',', ''))), + sets_count_won INTEGER AS (length(sets_won) - length(replace(sets_won, ';', ''))), sets_lost TEXT NOT NULL, - sets_count_lost INTEGER AS (length(sets_lost) - length(replace(sets_lost, ',', ''))), + sets_count_lost INTEGER AS (length(sets_lost) - length(replace(sets_lost, ';', ''))), sets TEXT AS (sets_won || sets_lost), sets_count INTEGER AS (sets_count_won + sets_count_lost) ) STRICT; @@ -141,9 +141,9 @@ CREATE TABLE "{0}_network" ( advantage REAL NOT NULL, sets_A TEXT NOT NULL, - sets_count_A INTEGER AS (length(sets_A) - length(replace(sets_A, ',', ''))), + sets_count_A INTEGER AS (length(sets_A) - length(replace(sets_A, ';', ''))), sets_B TEXT NOT NULL, - sets_count_B INTEGER AS (length(sets_B) - length(replace(sets_B, ',', ''))), + sets_count_B INTEGER AS (length(sets_B) - length(replace(sets_B, ';', ''))), sets TEXT AS (sets_A || sets_B), sets_count INTEGER AS (sets_count_A + sets_count_B), @@ -292,8 +292,8 @@ pub fn set_player_data( ) -> sqlite::Result<()> { let query = format!( r#"UPDATE "{}_players" SET deviation = :dev, volatility = :vol, last_played = :last, - sets_won = iif(:won, sets_won || :set || ',', sets_won), - sets_lost = iif(:won, sets_lost, sets_lost || :set || ',') WHERE id = :id"#, + sets_won = iif(:won, sets_won || :set || ';', sets_won), + sets_lost = iif(:won, sets_lost, sets_lost || :set || ';') WHERE id = :id"#, dataset ); @@ -303,7 +303,7 @@ pub fn set_player_data( statement.bind((":last", last_played.0 as i64))?; statement.bind((":id", player.0 as i64))?; statement.bind((":won", if won { 1 } else { 0 }))?; - statement.bind((":set", set.0 as i64))?; + statement.bind((":set", &set.0.to_string()[..]))?; statement.next()?; Ok(()) } @@ -376,8 +376,8 @@ WHERE (player_A = :pl AND player_B != :plo) let query2 = format!( r#"UPDATE "{}_network" SET advantage = advantage + iif(:a > :b, -:v, :v), - sets_A = iif(:w = (:a > :b), sets_A || :set || ',', sets_A), - sets_B = iif(:w = (:b > :a), sets_B || :set || ',', sets_B) + sets_A = iif(:w = (:a > :b), sets_A || :set || ';', sets_A), + sets_B = iif(:w = (:b > :a), sets_B || :set || ';', sets_B) WHERE player_A = min(:a, :b) AND player_B = max(:a, :b)"#, dataset ); @@ -405,7 +405,7 @@ WHERE player_A = min(:a, :b) AND player_B = max(:a, :b)"#, statement.bind((":b", player2.0 as i64))?; statement.bind((":v", adjust2 - adjust1))?; statement.bind((":w", winner as i64))?; - statement.bind((":set", set.0 as i64))?; + statement.bind((":set", &set.0.to_string()[..]))?; statement.into_iter().try_for_each(|x| x.map(|_| ())) }