Skip to content

Commit

Permalink
Avoid uses of Record internals again (nushell#12312)
Browse files Browse the repository at this point in the history
# Description
Again avoid uses of the `Record` internals, so we are free to change the
data layout

- **Don't use internals of `Record` in `into sqlite`**
- **Don't use internals of `Record` in `to xml`**

Remaining: `rename`

# User-Facing Changes
None
  • Loading branch information
sholderbach authored Mar 28, 2024
1 parent 968926a commit 910e3b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions crates/nu-command/src/database/commands/into_sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::database::values::sqlite::{open_sqlite_db, values_to_sql};
use nu_engine::command_prelude::*;

use itertools::Itertools;
use std::{
path::Path,
sync::{
Expand Down Expand Up @@ -243,8 +244,8 @@ fn insert_in_transaction(
let insert_statement = format!(
"INSERT INTO [{}] ({}) VALUES ({})",
table_name,
val.cols.join(", "),
["?"].repeat(val.values().len()).join(", ")
Itertools::intersperse(val.columns().map(String::as_str), ", ").collect::<String>(),
Itertools::intersperse(itertools::repeat_n("?", val.len()), ", ").collect::<String>(),
);

let mut insert_statement =
Expand Down
3 changes: 1 addition & 2 deletions crates/nu-command/src/formats/to/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ impl Job {
fn find_invalid_column(record: &Record) -> Option<&String> {
const VALID_COLS: [&str; 3] = [COLUMN_TAG_NAME, COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME];
record
.cols
.iter()
.columns()
.find(|col| !VALID_COLS.contains(&col.as_str()))
}

Expand Down

0 comments on commit 910e3b5

Please sign in to comment.