Skip to content

Commit 63ba6b8

Browse files
committed
fix: pass argument through Escaped interface
1 parent 6e55668 commit 63ba6b8

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

libsql-server/src/connection/dump/exporter.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl<W: Write> DumpState<W> {
5050
let table_str = std::str::from_utf8(table)?;
5151
writeln!(
5252
self.writer,
53-
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql) VALUES('table','{}','{}',0,'{}');",
53+
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)VALUES('table','{}','{}',0,{});",
5454
table_str,
5555
table_str,
56-
std::str::from_utf8(sql)?
56+
Escaped(std::str::from_utf8(sql)?)
5757
)?;
5858
continue;
5959
} else {
@@ -536,4 +536,25 @@ mod test {
536536

537537
insta::assert_snapshot!(std::str::from_utf8(&out).unwrap());
538538
}
539+
540+
#[test]
541+
fn virtual_table_sql_escaping() {
542+
let tmp = tempdir().unwrap();
543+
let mut conn = Connection::open(tmp.path().join("data")).unwrap();
544+
545+
conn.execute(r#"CREATE VIRTUAL TABLE test_fts USING fts5(content)"#, ())
546+
.unwrap();
547+
548+
conn.execute(
549+
r#"CREATE VIRTUAL TABLE test_vocab USING fts5vocab(test_fts, 'row')"#,
550+
(),
551+
)
552+
.unwrap();
553+
554+
let mut out = Vec::new();
555+
export_dump(&mut conn, &mut out, false).unwrap();
556+
let dump_output = std::str::from_utf8(&out).unwrap();
557+
558+
assert!(dump_output.contains("''row''"));
559+
}
539560
}

0 commit comments

Comments
 (0)