diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e28e766e..4ccbb6642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Release Notes ### New - `Database.isSQLiteInternalTable(_:)` returns whether a table name is an internal SQLite table. +- `Database.isGRDBInternalTable(_:)` returns whether a table name is an internal GRDB table. ### Breaking Changes diff --git a/GRDB/Core/Database+Schema.swift b/GRDB/Core/Database+Schema.swift index 748bbb4fc..4c053acb5 100644 --- a/GRDB/Core/Database+Schema.swift +++ b/GRDB/Core/Database+Schema.swift @@ -32,6 +32,8 @@ extension Database { /// Returns whether a table is an internal SQLite table. /// + /// Those are tables whose name begins with "sqlite_". + /// /// For more information, see https://www.sqlite.org/fileformat2.html public func isSQLiteInternalTable(_ tableName: String) -> Bool { // https://www.sqlite.org/fileformat2.html#internal_schema_objects @@ -42,7 +44,14 @@ extension Database { // > "sqlite_". return tableName.starts(with: "sqlite_") } - + + /// Returns whether a table is an internal GRDB table. + /// + /// Those are tables whose name begins with "grdb_". + public func isGRDBInternalTable(_ tableName: String) -> Bool { + return tableName.starts(with: "grdb_") + } + /// Returns whether a view exists. public func viewExists(_ viewName: String) throws -> Bool { // SQlite identifiers are case-insensitive, case-preserving (http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html) diff --git a/README.md b/README.md index 368828eea..cae0b6f3a 100644 --- a/README.md +++ b/README.md @@ -1647,7 +1647,8 @@ try db.indexes(on: "players") // [IndexInfo], the indexes defined on the tab try db.foreignKeys(on: "players") // [ForeignKeyInfo], the foreign keys defined on the table try db.primaryKey("players") // PrimaryKeyInfo try db.table("players", hasUniqueKey: ["email"]) // Bool, true if column(s) is a unique key -Database.isSQLiteInternalTable("players") // Bool, true if argument is the name of an internal to SQLite table +Database.isSQLiteInternalTable(...) // Bool, true if argument is the name of an internal SQLite table +Database.isGRDBInternalTable(...) // Bool, true if argument is the name of an internal GRDB table ```