Skip to content

Commit

Permalink
Adopt test from #59
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Oct 19, 2023
1 parent 8d838d9 commit 34fb8d5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/include/sqlite_stmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class SQLiteStatement {
int GetType(idx_t col);
bool IsOpen();
void Close();
void CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, int expected_type, idx_t col_idx);
void CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type,
int expected_type, idx_t col_idx);
void CheckTypeIsFloatOrInteger(sqlite3_value *val, int sqlite_column_type, idx_t col_idx);
void Reset();
};
Expand Down
3 changes: 2 additions & 1 deletion src/sqlite_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void SQLiteStatement::Close() {
stmt = nullptr;
}

void SQLiteStatement::CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type, int expected_type, idx_t col_idx) {
void SQLiteStatement::CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_value *val, int sqlite_column_type,
int expected_type, idx_t col_idx) {
D_ASSERT(stmt);
if (bind_data.all_varchar) {
// no type check required
Expand Down
3 changes: 2 additions & 1 deletion src/storage/sqlite_table_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace duckdb {

SQLiteTableEntry::SQLiteTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info, bool all_varchar)
SQLiteTableEntry::SQLiteTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info,
bool all_varchar)
: TableCatalogEntry(catalog, schema, info), all_varchar(all_varchar) {
}

Expand Down
33 changes: 33 additions & 0 deletions test/sql/storage/attach_mixed_numeric.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name: test/sql/storage/attach_mixed_numeric.test
# description:
# group: [sqlite_storage]

require sqlite_scanner

# load from a database with a numeric column that has mixed types

# using the all_varchar option, without the setting
statement ok
ATTACH 'data/db/mixed_data_numeric.db' as mydb (TYPE sqlite);

statement error
select * from mydb.tbl;
----
Invalid type in column "a"

statement ok
DETACH mydb;

statement ok
SET sqlite_all_varchar=true

# using the setting, not the all_varchar option
statement ok
ATTACH 'data/db/mixed_data_numeric.db' as mydb (TYPE sqlite);

query I
select * from mydb.tbl;
----
42
hello
NULL

0 comments on commit 34fb8d5

Please sign in to comment.