Skip to content

Commit

Permalink
Fix #53: parse BOOLEAN type as integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Oct 19, 2023
1 parent 34fb8d5 commit 97d25dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Binary file added data/db/boolean.db
Binary file not shown.
7 changes: 6 additions & 1 deletion src/sqlite_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ LogicalType SQLiteUtils::TypeToLogicalType(const string &sqlite_type) {
if (StringUtil::Contains(sqlite_type, "int")) {
return LogicalType::BIGINT;
}

// boolean
if (StringUtil::Contains(sqlite_type, "bool")) {
return LogicalType::BIGINT;
}

// If the declared type of the column contains any of the strings "CHAR",
// "CLOB", or "TEXT" then that column has TEXT affinity. Notice that the type
// VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity.
Expand All @@ -89,7 +95,6 @@ LogicalType SQLiteUtils::TypeToLogicalType(const string &sqlite_type) {
// classes.
// ...
// we add some more extra rules to try to be somewhat sane

if (sqlite_type == "date") {
return LogicalType::DATE;
}
Expand Down
20 changes: 20 additions & 0 deletions test/sql/storage/issue53.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# name: test/sql/storage/issue53.test
# description: Test issue #53 - BOOLEAN data type is not supported
# group: [sqlite_scanner]

require sqlite_scanner

statement ok
ATTACH 'data/db/boolean.db' AS sqlite (TYPE SQLITE)

query I
SELECT name, type FROM pragma_table_info('sqlite.entry')
----
id BIGINT
is_active BIGINT

query II
SELECT * FROM sqlite.entry
----
44 0
55 0

0 comments on commit 97d25dc

Please sign in to comment.