diff options
author | Teddy Wing | 2022-03-23 00:24:22 +0100 |
---|---|---|
committer | Teddy Wing | 2022-03-23 00:27:50 +0100 |
commit | 2313a1bd0910e7b42cc23f83d6722272b87e0baf (patch) | |
tree | df1d0ac52ed1c050b377afae7c02921674d9fc22 | |
parent | 466aa5dc480048ff4448c2f2f1ee8cbe02cad3a8 (diff) | |
download | yaqlite-2313a1bd0910e7b42cc23f83d6722272b87e0baf.tar.bz2 |
extract(): Rename function to `db_insert()`
The name `extract()` didn't make sense to me any more since the function
is doing more than its originally intended behaviour which was to
extract the YAML into a hash-like format for easy insertion into the
database.
I decided to give up on that behaviour since this works for what we want
it to do. Maybe this function is doing more than it should, but I'm okay
with that for the current functional requirements.
-rw-r--r-- | src/insert.rs | 2 | ||||
-rw-r--r-- | src/yaml.rs | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/insert.rs b/src/insert.rs index f58fc4c..9c15fc7 100644 --- a/src/insert.rs +++ b/src/insert.rs @@ -9,7 +9,7 @@ pub fn insert( for mut doc in data { let tx = dbconn.transaction()?; - crate::yaml::extract(&mut doc, &tx, &table_name, &table_columns)?; + crate::yaml::db_insert(&mut doc, &tx, &table_name, &table_columns)?; tx.commit()?; } diff --git a/src/yaml.rs b/src/yaml.rs index ed64afd..c8840bf 100644 --- a/src/yaml.rs +++ b/src/yaml.rs @@ -12,10 +12,8 @@ pub(crate) use sql::*; pub use write::*; -// TODO: Separate functions to get a list of YAML hashes, and insert hashes into -// the database. -/// TODO -pub fn extract( +/// Insert a YAML document into the given table in the database. +pub fn db_insert( doc: &mut yaml::Yaml, tx: &rusqlite::Transaction, table_name: &str, @@ -24,7 +22,7 @@ pub fn extract( match doc { yaml::Yaml::Array(ref mut array) => { for yaml_value in array { - extract(yaml_value, tx, table_name, table_columns)?; + db_insert(yaml_value, tx, table_name, table_columns)?; } } yaml::Yaml::Hash(ref mut hash) => { |