Avoid uses of Record
internals again (#12312)
# 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
This commit is contained in:
parent
968926a327
commit
910e3b52a7
|
@ -1,6 +1,7 @@
|
||||||
use crate::database::values::sqlite::{open_sqlite_db, values_to_sql};
|
use crate::database::values::sqlite::{open_sqlite_db, values_to_sql};
|
||||||
use nu_engine::command_prelude::*;
|
use nu_engine::command_prelude::*;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use std::{
|
use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -243,8 +244,8 @@ fn insert_in_transaction(
|
||||||
let insert_statement = format!(
|
let insert_statement = format!(
|
||||||
"INSERT INTO [{}] ({}) VALUES ({})",
|
"INSERT INTO [{}] ({}) VALUES ({})",
|
||||||
table_name,
|
table_name,
|
||||||
val.cols.join(", "),
|
Itertools::intersperse(val.columns().map(String::as_str), ", ").collect::<String>(),
|
||||||
["?"].repeat(val.values().len()).join(", ")
|
Itertools::intersperse(itertools::repeat_n("?", val.len()), ", ").collect::<String>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut insert_statement =
|
let mut insert_statement =
|
||||||
|
|
|
@ -269,8 +269,7 @@ impl Job {
|
||||||
fn find_invalid_column(record: &Record) -> Option<&String> {
|
fn find_invalid_column(record: &Record) -> Option<&String> {
|
||||||
const VALID_COLS: [&str; 3] = [COLUMN_TAG_NAME, COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME];
|
const VALID_COLS: [&str; 3] = [COLUMN_TAG_NAME, COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME];
|
||||||
record
|
record
|
||||||
.cols
|
.columns()
|
||||||
.iter()
|
|
||||||
.find(|col| !VALID_COLS.contains(&col.as_str()))
|
.find(|col| !VALID_COLS.contains(&col.as_str()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user