Skip to content

Commit 2a3318e

Browse files
committed
ALTER TABLE DROP COLUMN is properly reported with SQLITE_ALTER_TABLE for SQLite 3.38+
1 parent f2c4678 commit 2a3318e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

GRDB/Core/StatementAuthorizer.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,19 @@ final class StatementAuthorizer {
160160
return SQLITE_OK
161161

162162
case SQLITE_FUNCTION:
163-
guard let cString2 = cString2 else { return SQLITE_OK }
164-
165-
// SQLite does not report ALTER TABLE DROP COLUMN with the
166-
// SQLITE_ALTER_TABLE action code. So we need to find another way
167-
// to set the `invalidatesDatabaseSchemaCache` flag for such
163+
// SQLite 3.37.2 does not report ALTER TABLE DROP COLUMN with the
164+
// SQLITE_ALTER_TABLE action code. SQLite 3.38 does.
165+
//
166+
// Until SQLite 3.38, we need to find another way to set the
167+
// `invalidatesDatabaseSchemaCache` flag for such
168168
// statement, and it is SQLITE_FUNCTION sqlite_drop_column.
169169
//
170170
// See <https://github.com/groue/GRDB.swift/pull/1144#issuecomment-1015155717>
171171
// See <https://sqlite.org/forum/forumpost/bd47580ec2>
172-
//
173-
// TODO: remove when SQLite properly reports SQLITE_ALTER_TABLE
174-
if strcmp(cString2, "sqlite_drop_column") == 0 {
172+
if sqlite3_libversion_number() < 3038000,
173+
let cString2,
174+
strcmp(cString2, "sqlite_drop_column") == 0
175+
{
175176
invalidatesDatabaseSchemaCache = true
176177
}
177178
return SQLITE_OK

0 commit comments

Comments
 (0)