From 2a3318ef9afcfbb45ce0ccc76c7ed12a850f919a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Rou=C3=A9?= Date: Wed, 7 Sep 2022 08:51:05 +0200 Subject: [PATCH] ALTER TABLE DROP COLUMN is properly reported with SQLITE_ALTER_TABLE for SQLite 3.38+ --- GRDB/Core/StatementAuthorizer.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/GRDB/Core/StatementAuthorizer.swift b/GRDB/Core/StatementAuthorizer.swift index 0b6eaa025..e77d823eb 100644 --- a/GRDB/Core/StatementAuthorizer.swift +++ b/GRDB/Core/StatementAuthorizer.swift @@ -160,18 +160,19 @@ final class StatementAuthorizer { return SQLITE_OK case SQLITE_FUNCTION: - guard let cString2 = cString2 else { return SQLITE_OK } - - // SQLite does not report ALTER TABLE DROP COLUMN with the - // SQLITE_ALTER_TABLE action code. So we need to find another way - // to set the `invalidatesDatabaseSchemaCache` flag for such + // SQLite 3.37.2 does not report ALTER TABLE DROP COLUMN with the + // SQLITE_ALTER_TABLE action code. SQLite 3.38 does. + // + // Until SQLite 3.38, we need to find another way to set the + // `invalidatesDatabaseSchemaCache` flag for such // statement, and it is SQLITE_FUNCTION sqlite_drop_column. // // See // See - // - // TODO: remove when SQLite properly reports SQLITE_ALTER_TABLE - if strcmp(cString2, "sqlite_drop_column") == 0 { + if sqlite3_libversion_number() < 3038000, + let cString2, + strcmp(cString2, "sqlite_drop_column") == 0 + { invalidatesDatabaseSchemaCache = true } return SQLITE_OK