Skip to content

Commit

Permalink
Update appender tests to reflect computed columns support
Browse files Browse the repository at this point in the history
Prior to duckdb/duckdb#14346, the C API did not
support appending to tables with computed columns.

This would cause panics until
#296, where a test was
introduced asserting that an append to a table with computed columns
returns an error value.

Now that appending to is supported, update the test to reflect that.
  • Loading branch information
andrewhamon committed Nov 27, 2024
1 parent 640ecfd commit e01585b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/duckdb/src/appender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,23 @@ mod test {
}

#[test]
fn test_appender_error() -> Result<(), crate::Error> {
fn test_appender_computed_columns() -> Result<(), crate::Error> {
let conn = Connection::open_in_memory()?;
conn.execute(
r"CREATE TABLE foo (
foobar TEXT,
foobar_split TEXT[] AS (split(trim(foobar), ','))
foobar_twice TEXT AS (foobar || foobar)
);",
[],
)?;
let mut appender = conn.appender("foo")?;
match appender.append_row(["foo"]) {
Err(crate::Error::DuckDBFailure(.., Some(msg))) => {
assert_eq!(msg, "Call to EndRow before all columns have been appended to!")
}
_ => panic!("expected error"),
}
appender.append_row(["foo"])?;
appender.flush()?;
let val = conn.query_row("SELECT foobar, foobar_twice FROM foo", [], |row| {
<(String, String)>::try_from(row)
})?;
assert_eq!(val, ("foo".to_string(), "foofoo".to_string()));

Ok(())
}
}

0 comments on commit e01585b

Please sign in to comment.