aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-03-19 15:18:53 +0100
committerTeddy Wing2022-03-19 15:18:53 +0100
commit54cbd8ca5f7d00f3866724bbe92ae9a6ce6e1e57 (patch)
tree0fd0c8d34d915507c5c3c00fd78d49bf38a34b88
parent8b52dd67c57ed843e7d4d2d493f5bdfc4c2c214c (diff)
downloadyaqlite-54cbd8ca5f7d00f3866724bbe92ae9a6ce6e1e57.tar.bz2
select(): Column name interface and default primary key column interface
Add a new function that allows using a specified column name for selection. The `select()` function will default to using the table's primary key column. Still need to update the references to the "id" column in the function.
-rw-r--r--src/select.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/select.rs b/src/select.rs
index 1405347..71a096e 100644
--- a/src/select.rs
+++ b/src/select.rs
@@ -14,6 +14,20 @@ pub fn select(
table_name: &str,
record_id: &str,
) -> Result<yaml_rust::Yaml, crate::Error> {
+ select_by_column(
+ dbconn,
+ table_name,
+ &crate::sqlite::table_primary_key_column(dbconn, table_name)?,
+ record_id,
+ )
+}
+
+pub fn select_by_column(
+ dbconn: &rusqlite::Connection,
+ table_name: &str,
+ primary_key_column: &str,
+ record_id: &str,
+) -> Result<yaml_rust::Yaml, crate::Error> {
use crate::yaml::Yaml;
let mut stmt = dbconn.prepare(