From e3c2a7f3972013708a09b2fb68fc470269331679 Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Tue, 23 Jan 2024 16:36:29 +0100 Subject: [PATCH] Correctly define unique constraint in SQLite table definition --- src/sqlite_db.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sqlite_db.cpp b/src/sqlite_db.cpp index e6633e6..761b154 100644 --- a/src/sqlite_db.cpp +++ b/src/sqlite_db.cpp @@ -166,6 +166,10 @@ void SQLiteDB::GetTableInfo(const string &table_name, ColumnList &columns, vecto StringUtil::Trim(sqlite_type); auto column_type = all_varchar ? LogicalType::VARCHAR : SQLiteUtils::TypeToLogicalType(sqlite_type); + if (pk) { + primary_key_index = cid; + primary_keys.push_back(sqlite_colname); + } ColumnDefinition column(std::move(sqlite_colname), std::move(column_type)); if (!default_value.empty() && default_value != "\"\"") { auto expressions = Parser::ParseExpressionList(default_value); @@ -178,10 +182,6 @@ void SQLiteDB::GetTableInfo(const string &table_name, ColumnList &columns, vecto if (not_null) { constraints.push_back(make_uniq(LogicalIndex(cid))); } - if (pk) { - primary_key_index = cid; - primary_keys.push_back(sqlite_colname); - } found = true; } if (!found) {