From be8bf2e903b25036f48df69fb48dedf14233d044 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 18 Mar 2022 19:58:45 +0100 Subject: select(): Remove parameterized primary key column name It turns out that adding the primary key column name to the query via a prepared parameter was causing it to be set as a literal instead of a column name. The resulting SQL was: SELECT * FROM test WHERE 'id' = '1'; instead of: SELECT * FROM test WHERE "id" = '1'; When the `id` column is hard-coded, this works correctly, producing the right SQL and extracting the correct record. We'll need to update this to add the column name via the format string like we've done with the table name so we can make it dynamic. --- src/select.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/select.rs b/src/select.rs index 4fcd41c..d9cbb5b 100644 --- a/src/select.rs +++ b/src/select.rs @@ -11,7 +11,7 @@ pub fn select( SELECT * FROM {} - WHERE :pk_column = :pk; + WHERE "id" = :pk; "#, table_name, ), @@ -31,7 +31,7 @@ pub fn select( let rows = stmt.query_map( rusqlite::named_params! { - ":pk_column": "id", + // ":pk_column": "id", ":pk": record_id, }, -- cgit v1.2.3