Skip to content

Commit 704f422

Browse files
committed
Add more tests
1 parent 40f4eab commit 704f422

File tree

1 file changed

+37
-0
lines changed
  • crates/duckdb/src/appender

1 file changed

+37
-0
lines changed

crates/duckdb/src/appender/mod.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,41 @@ mod test {
518518

519519
Ok(())
520520
}
521+
522+
#[test]
523+
fn test_appender_with_columns_to_db_schema() -> Result<()> {
524+
let db = Connection::open_in_memory()?;
525+
db.execute_batch(
526+
"CREATE SCHEMA s;
527+
CREATE TABLE s.foo(a INTEGER DEFAULT 5, b INTEGER)",
528+
)?;
529+
530+
{
531+
let mut app = db.appender_with_columns_to_db("foo", "s", &["b"])?;
532+
app.append_row([7])?;
533+
}
534+
535+
let (a, b): (i32, i32) = db.query_row("SELECT a, b FROM s.foo", [], |row| Ok((row.get(0)?, row.get(1)?)))?;
536+
assert_eq!((a, b), (5, 7));
537+
Ok(())
538+
}
539+
540+
#[test]
541+
fn test_appender_with_columns_to_catalog_and_db() -> Result<()> {
542+
let db = Connection::open_in_memory()?;
543+
db.execute_batch(
544+
"CREATE SCHEMA s;
545+
CREATE TABLE s.bar(a INTEGER DEFAULT 11, b INTEGER)",
546+
)?;
547+
548+
{
549+
// Default in-memory catalog is "memory"
550+
let mut app = db.appender_with_columns_to_catalog_and_db("bar", "memory", "s", &["b"])?;
551+
app.append_row([9])?;
552+
}
553+
554+
let (a, b): (i32, i32) = db.query_row("SELECT a, b FROM s.bar", [], |row| Ok((row.get(0)?, row.get(1)?)))?;
555+
assert_eq!((a, b), (11, 9));
556+
Ok(())
557+
}
521558
}

0 commit comments

Comments
 (0)