Skip to content

Commit

Permalink
Disallow text in int column in SQLite get_affected_rows() test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vadz committed Jan 28, 2025
1 parent 42d5a2e commit 6939029
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/sqlite3/test-sqlite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))";
}
};

Expand Down

0 comments on commit 6939029

Please sign in to comment.