Closed taniabogatsch closed 1 month ago
go-duckdb test reproduction.
func TestAppenderPK(t *testing.T) {
c, con, a := prepareAppender(t, `
CREATE TABLE test (
c1 INTEGER PRIMARY KEY
)`)
require.NoError(t, a.AppendRow(int32(1)))
require.NoError(t, a.AppendRow(int32(1)))
require.ErrorContains(t, a.Close(), "TODOpk violation")
cleanupAppender(t, c, con, a)
}
Currently, a constraint violation in the appender goes unnoticed, i.e.,
a.Close()
succeeds. The values aren't appended, but there is no feedback that a violation happened.When appending the same value to a primary key column twice, the second
a.AppendRow(int32(1))
cannot return an error. That is because we are constructing the data on the go-duckdb side first (without constraint context). We detect a constraint violation only when calling eitherFlush
orClose
. Currently, there is a bug causing these functions not to return the constraint violation error, leaving the user in the dark about the unsuccessful append.I believe this is a bug on the duckdb side itself, but I am opening a mirror issue here to make people aware until this is fixed. After fixing this (in duckdb), we should add respective tests for
errAppenderClose
anderrAppenderFlush
. For now, I'll push aFIXME
with the fix for #197.Reproduction in go-duckdb.
@marcboeker, feel free to go ahead and assign me!