1#include "catch.hpp"
2#include "duckdb/main/appender.hpp"
3#include "test_helpers.hpp"
4
5#include <vector>
6
7using namespace duckdb;
8using namespace std;
9
10TEST_CASE("Abort appender due to primary key conflict", "[appender]") {
11 unique_ptr<QueryResult> result;
12 DuckDB db(nullptr);
13 Connection con(db);
14
15 REQUIRE_NO_FAIL(con.Query("CREATE TABLE integers(i INTEGER PRIMARY KEY)"));
16 REQUIRE_NO_FAIL(con.Query("INSERT INTO integers VALUES (1)"));
17
18 Appender appender(con, "integers");
19 appender.BeginRow();
20 appender.Append<int32_t>(1);
21 appender.EndRow();
22 // this should fail!
23 REQUIRE_THROWS(appender.Flush());
24
25 result = con.Query("SELECT * FROM integers");
26 REQUIRE(CHECK_COLUMN(result, 0, {1}));
27}
28