From 54cbd8ca5f7d00f3866724bbe92ae9a6ce6e1e57 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 19 Mar 2022 15:18:53 +0100 Subject: 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. --- src/select.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/select.rs b/src/select.rs index 1405347..71a096e 100644 --- a/src/select.rs +++ b/src/select.rs @@ -13,6 +13,20 @@ pub fn select( dbconn: &rusqlite::Connection, table_name: &str, record_id: &str, +) -> Result { + 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 { use crate::yaml::Yaml; -- cgit v1.2.3