From 6939029dd85176c2c13a61c5dce2078d385a672b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 28 Jan 2025 16:02:19 +0100 Subject: [PATCH] Disallow text in int column in SQLite get_affected_rows() test The unit test relies on failing to insert "a" into an integer column but SQLite is perfectly fine with doing this by default, so use an explicit CHECK constraint to prevent this from succeeding and to make it behave in the same way as the other databases. --- tests/sqlite3/test-sqlite3.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/sqlite3/test-sqlite3.cpp b/tests/sqlite3/test-sqlite3.cpp index 39855c97e..f065dec80 100644 --- a/tests/sqlite3/test-sqlite3.cpp +++ b/tests/sqlite3/test-sqlite3.cpp @@ -913,7 +913,13 @@ struct table_creator_for_get_affected_rows : table_creator_base table_creator_for_get_affected_rows(soci::session & sql) : table_creator_base(sql) { - sql << "create table soci_test(val integer)"; + // The CHECK clause is needed to make SQLite refuse inserting "a" into + // this column: the test using this table relies on this to fail and + // this condition ensures it does. + // + // Note that more straightforward checks, like typeof(val) = 'integer', + // don't work with old SQLite version, such as 3.12 used on AppVeyor. + sql << R"(create table soci_test(val integer check (val < 100)))"; } };