aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2022-03-18 19:58:45 +0100
committerTeddy Wing2022-03-18 20:02:07 +0100
commitbe8bf2e903b25036f48df69fb48dedf14233d044 (patch)
tree3bf8ccda58dfc523ecd40432bcb12e17cfed6e24 /src
parent065f2e630f366fe38920885c63cf97a7d3218c21 (diff)
downloadyaqlite-be8bf2e903b25036f48df69fb48dedf14233d044.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/select.rs4
1 files changed, 2 insertions, 2 deletions
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,
},