From a8dda23cab51b178229b50a3ebbd8479818676f8 Mon Sep 17 00:00:00 2001 From: Eragon Date: Sat, 19 Oct 2024 23:29:14 +0200 Subject: [PATCH] refactor: Add fixme to (some) queries --- tokenserver-db-sqlite/src/models.rs | 3 +++ tokenserver-db/src/models.rs | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tokenserver-db-sqlite/src/models.rs b/tokenserver-db-sqlite/src/models.rs index f552739eb2..6c95c93d76 100644 --- a/tokenserver-db-sqlite/src/models.rs +++ b/tokenserver-db-sqlite/src/models.rs @@ -4,6 +4,7 @@ SELECT rowid as id FROM nodes WHERE service = ? AND node = ?"#; +// FIXME: MySQL specific pub const REPLACE_USERS_SYNC_QUERY: &str = r#" UPDATE users SET replaced_at = ? @@ -30,6 +31,7 @@ AND email = ? AND generation <= ? AND COALESCE(keys_changed_at, 0) <= COALESCE(?, keys_changed_at, 0) AND replaced_at IS NULL"#; +// FIXME: MySQL specific pub const POST_USER_SYNC_QUERY: &str = r#" INSERT INTO users (service, email, generation, client_state, created_at, nodeid, keys_changed_at, replaced_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?);"#; @@ -51,6 +53,7 @@ WHERE service = ? AND available <= 0 AND capacity > current_load AND downed = 0"#; +// FIXME: MySQL specific pub const GET_BEST_NODE_SPANNER_QUERY: &str = r#" SELECT id, node FROM nodes diff --git a/tokenserver-db/src/models.rs b/tokenserver-db/src/models.rs index ff0e01e284..1a1ddf71df 100644 --- a/tokenserver-db/src/models.rs +++ b/tokenserver-db/src/models.rs @@ -55,7 +55,7 @@ struct DbInner { impl TokenserverDb { // Note that this only works because an instance of `TokenserverDb` has *exclusive access* to - // a connection from the r2d2 pool for its lifetime. `LAST_INSERT_ID()`/`LAST_INSERT_ROWID()` + // a connection from the r2d2 pool for its lifetime. `LAST_INSERT_ID_QUERY` // returns the ID of the most recently-inserted record *for a given connection*. // If connections were shared across requests, using this function would introduce a race condition, // as we could potentially get IDs from records created during other requests. @@ -163,7 +163,6 @@ impl TokenserverDb { .execute(&self.inner.conn)?; diesel::sql_query(LAST_INSERT_ID_QUERY) - .bind::(&user.email) .get_result::(&self.inner.conn) .map_err(Into::into) }