mirror of
https://github.com/groue/GRDB.swift
synced 2026-12-06 05:28:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20bda2af26 | ||
|
|
7a49f6293d | ||
|
|
81b21010f1 | ||
|
|
2526e0a2f7 | ||
|
|
af1e8470c9 | ||
|
|
dfd9da68a7 | ||
|
|
5e702234f4 | ||
|
|
9020dcca9a | ||
|
|
930a4e4c1d | ||
|
|
4db77f96b7 | ||
|
|
cc12c046b9 | ||
|
|
f5c63e0997 | ||
|
|
29a26800b7 | ||
|
|
bc5eeb3b3a | ||
|
|
40d02518b0 | ||
|
|
a2556edc69 | ||
|
|
111970fda9 |
No files matched your search
@@ -1,6 +1,32 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
## 1.2.2
|
||||
|
||||
Released July 20, 2017
|
||||
|
||||
**Fixed**
|
||||
|
||||
- The `Configuration.trace` function no longer leaks memory.
|
||||
|
||||
|
||||
## 1.2.1
|
||||
|
||||
Released July 19, 2017
|
||||
|
||||
**Fixed**
|
||||
|
||||
- Upgrade custom SQLite builds to [v3.19.3](http://www.sqlite.org/changes.html) (thanks to [@swiftlyfalling](https://github.com/swiftlyfalling/SQLiteLib)).
|
||||
- The [Query Interface](https://github.com/groue/GRDB.swift/#the-query-interface) now generates `IS NULL` SQL snippets for comparisons with `DatabaseValue.null`:
|
||||
|
||||
```swift
|
||||
// SELECT * FROM players WHERE email IS NULL
|
||||
Player.filter(Column("email") == DatabaseValue.null)
|
||||
```
|
||||
|
||||
It used to generate `= NULL` which would not behave as expected.
|
||||
|
||||
|
||||
## 1.2
|
||||
|
||||
Released July 13, 2017
|
||||
|
||||
@@ -3,7 +3,7 @@ Custom SQLite Builds
|
||||
|
||||
By default, GRDB uses the version of SQLite that ships with the target operating system.
|
||||
|
||||
**You can build GRDB with a custom build of [SQLite 3.19.2](https://www.sqlite.org/changes.html).**
|
||||
**You can build GRDB with a custom build of [SQLite 3.19.3](https://www.sqlite.org/changes.html).**
|
||||
|
||||
A custom SQLite build can activate extra SQLite features, and extra GRDB features as well, such as support for the [FTS5 full-text search engine](../../../#full-text-search), and [SQLite Pre-Update Hooks](../../../#support-for-sqlite-pre-update-hooks).
|
||||
|
||||
@@ -15,7 +15,7 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
|
||||
|
||||
```sh
|
||||
cd [GRDB.swift directory]
|
||||
git checkout v1.2
|
||||
git checkout v1.2.2
|
||||
git submodule update --init SQLiteCustom/src
|
||||
````
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '1.2'
|
||||
s.version = '1.2.2'
|
||||
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'A Swift application toolkit for SQLite databases.'
|
||||
|
||||
@@ -292,6 +292,22 @@
|
||||
562756481E963AAC0035B653 /* DatabaseWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562756421E963AAC0035B653 /* DatabaseWriterTests.swift */; };
|
||||
562756491E963AAC0035B653 /* DatabaseWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562756421E963AAC0035B653 /* DatabaseWriterTests.swift */; };
|
||||
5627564A1E963AAC0035B653 /* DatabaseWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562756421E963AAC0035B653 /* DatabaseWriterTests.swift */; };
|
||||
562EA8261F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA8271F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA8281F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA8291F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA82A1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA82B1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA82C1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA82D1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */; };
|
||||
562EA82F1F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8301F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8311F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8321F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8331F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8341F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8351F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
562EA8361F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
|
||||
56300B5F1C53C38F005A543B /* QueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B5D1C53C38F005A543B /* QueryInterfaceRequestTests.swift */; };
|
||||
56300B621C53C42C005A543B /* RowConvertible+QueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B601C53C42C005A543B /* RowConvertible+QueryInterfaceRequestTests.swift */; };
|
||||
56300B691C53D25E005A543B /* QueryInterfaceExpressionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */; };
|
||||
@@ -1900,6 +1916,8 @@
|
||||
562393711DEE104400A6B01F /* MapCursorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapCursorTests.swift; sourceTree = "<group>"; };
|
||||
5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GRDBTestCase.swift; sourceTree = "<group>"; };
|
||||
562756421E963AAC0035B653 /* DatabaseWriterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseWriterTests.swift; sourceTree = "<group>"; };
|
||||
562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompilationProtocolTests.swift; sourceTree = "<group>"; };
|
||||
562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompilationSubClassTests.swift; sourceTree = "<group>"; };
|
||||
56300B5D1C53C38F005A543B /* QueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceRequestTests.swift; sourceTree = "<group>"; };
|
||||
56300B601C53C42C005A543B /* RowConvertible+QueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "RowConvertible+QueryInterfaceRequestTests.swift"; sourceTree = "<group>"; };
|
||||
56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceExpressionsTests.swift; sourceTree = "<group>"; };
|
||||
@@ -2421,10 +2439,11 @@
|
||||
56176C581EACC2D8000F3F2B /* GRDBTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */,
|
||||
562EA81E1F17B26F00FA528C /* Compilation */,
|
||||
56A238111B9C74A90082EB20 /* Core */,
|
||||
5698AC3E1DA2BEBB0056AF8C /* FTS */,
|
||||
56176CA01EACEE2A000F3F2B /* GRDBCipher */,
|
||||
5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */,
|
||||
56A238231B9C74A90082EB20 /* Migrations */,
|
||||
569978D31B539038005EBEED /* Private */,
|
||||
56300B5C1C53C38F005A543B /* QueryInterface */,
|
||||
@@ -2481,6 +2500,15 @@
|
||||
name = GRDBCipher;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
562EA81E1F17B26F00FA528C /* Compilation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */,
|
||||
562EA8251F17B2AC00FA528C /* CompilationProtocolTests.swift */,
|
||||
);
|
||||
name = Compilation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56300B5C1C53C38F005A543B /* QueryInterface */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -3924,11 +3952,13 @@
|
||||
560FC5621CB00B880014AA8E /* Record+QueryInterfaceRequestTests.swift in Sources */,
|
||||
5698ACD81DA925420056AF8C /* RowTestCase.swift in Sources */,
|
||||
56A8C2411D1918EE0096E9D4 /* FoundationNSUUIDTests.swift in Sources */,
|
||||
562EA8301F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
562206031E420EA3005860AC /* DatabasePoolBackupTests.swift in Sources */,
|
||||
5657AB571D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
|
||||
564448841EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
560FC5B21CB031E30014AA8E /* StatementColumnConvertibleFetchTests.swift in Sources */,
|
||||
561667021D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
|
||||
562EA8271F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
569C1EB31CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */,
|
||||
560FC5651CB00B880014AA8E /* RecordPrimaryKeyNoneTests.swift in Sources */,
|
||||
560FC5661CB00B880014AA8E /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
@@ -4161,11 +4191,13 @@
|
||||
5671561F1CB16729007DC145 /* Record+QueryInterfaceRequestTests.swift in Sources */,
|
||||
5698ACD91DA925420056AF8C /* RowTestCase.swift in Sources */,
|
||||
567156221CB16729007DC145 /* StatementColumnConvertibleFetchTests.swift in Sources */,
|
||||
562EA8311F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
562206001E420EA3005860AC /* DatabasePoolBackupTests.swift in Sources */,
|
||||
567156231CB16729007DC145 /* RecordPrimaryKeyNoneTests.swift in Sources */,
|
||||
564448851EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
567156241CB16729007DC145 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
567156251CB16729007DC145 /* RowFromDictionaryTests.swift in Sources */,
|
||||
562EA8281F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
565F03C41CE5D3AA00DE108F /* RowAdapterTests.swift in Sources */,
|
||||
567156261CB16729007DC145 /* SelectStatementTests.swift in Sources */,
|
||||
567156281CB16729007DC145 /* QueryInterfaceExpressionsTests.swift in Sources */,
|
||||
@@ -4378,11 +4410,13 @@
|
||||
56F26C241CEE3F34007969C4 /* RowAdapterTests.swift in Sources */,
|
||||
56AFCA311CB1AA9900F48B96 /* RecordPrimaryKeyNoneTests.swift in Sources */,
|
||||
56AFCA321CB1AA9900F48B96 /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
562EA8341F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
5698ACD31DA8C2620056AF8C /* RecordPrimaryKeyHiddenRowIDTests.swift in Sources */,
|
||||
56AFCA331CB1AA9900F48B96 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
564448881EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
56AFCA341CB1AA9900F48B96 /* RowFromDictionaryTests.swift in Sources */,
|
||||
569C1EB61CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */,
|
||||
562EA82B1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
56DAA2D71DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */,
|
||||
5698AC4E1DA2D48A0056AF8C /* FTS3RecordTests.swift in Sources */,
|
||||
567E55EE1D2BDD3F00CC6F79 /* EncryptionTests.swift in Sources */,
|
||||
@@ -4509,11 +4543,13 @@
|
||||
56AFCA891CB1ABC800F48B96 /* Record+QueryInterfaceRequestTests.swift in Sources */,
|
||||
56AFCA8A1CB1ABC800F48B96 /* RecordPrimaryKeyNoneTests.swift in Sources */,
|
||||
56AFCA8B1CB1ABC800F48B96 /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
562EA8351F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
5698ACD41DA8C2620056AF8C /* RecordPrimaryKeyHiddenRowIDTests.swift in Sources */,
|
||||
56AFCA8C1CB1ABC800F48B96 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
564448891EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
56AFCA8D1CB1ABC800F48B96 /* RowFromDictionaryTests.swift in Sources */,
|
||||
5657AB541D108BA9006283EF /* FoundationNSNumberTests.swift in Sources */,
|
||||
562EA82C1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
56DAA2D81DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */,
|
||||
5698AC4F1DA2D48A0056AF8C /* FTS3RecordTests.swift in Sources */,
|
||||
56AFCA8F1CB1ABC800F48B96 /* DatabaseCollationTests.swift in Sources */,
|
||||
@@ -4725,11 +4761,13 @@
|
||||
56DAA2D61DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */,
|
||||
56FF45441D2C23BA00F21EF9 /* TableMappingDeleteByKeyTests.swift in Sources */,
|
||||
56A238561B9C74A90082EB20 /* RecordPrimaryKeyNoneTests.swift in Sources */,
|
||||
562EA8331F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
563363BE1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
56A238501B9C74A90082EB20 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
564448871EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
56A238461B9C74A90082EB20 /* RowFromDictionaryTests.swift in Sources */,
|
||||
569C1EB51CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */,
|
||||
562EA82A1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
564A50C81BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift in Sources */,
|
||||
56E8CE111BB4FE5B00828BEC /* StatementColumnConvertibleFetchTests.swift in Sources */,
|
||||
56300B691C53D25E005A543B /* QueryInterfaceExpressionsTests.swift in Sources */,
|
||||
@@ -4856,11 +4894,13 @@
|
||||
56D496591D81304E008276D7 /* FoundationNSDateTests.swift in Sources */,
|
||||
56D4968B1D81316E008276D7 /* NumericOverflowTests.swift in Sources */,
|
||||
56D496B31D8133E3008276D7 /* IndexInfoTests.swift in Sources */,
|
||||
562EA82F1F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
5698AC961DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
|
||||
56D4966D1D81309E008276D7 /* RecordMinimalPrimaryKeySingleTests.swift in Sources */,
|
||||
564448831EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
56D496811D813131008276D7 /* TransactionObserverSavepointsTests.swift in Sources */,
|
||||
56D496AB1D8132CA008276D7 /* DatabasePoolFunctionTests.swift in Sources */,
|
||||
562EA8261F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
56D496691D813086008276D7 /* QueryInterfaceExpressionsTests.swift in Sources */,
|
||||
562393691DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
|
||||
562205F21E420E47005860AC /* DatabasePoolSchemaCacheTests.swift in Sources */,
|
||||
@@ -5159,11 +5199,13 @@
|
||||
F3BA810C1CFB3056003DC1BA /* StatementArguments+FoundationTests.swift in Sources */,
|
||||
F3BA80B91CFB2FD1003DC1BA /* DatabasePoolBackupTests.swift in Sources */,
|
||||
F3BA811E1CFB3063003DC1BA /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
562EA8361F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
5623934C1DEDFE4500A6B01F /* IteratorCursorTests.swift in Sources */,
|
||||
F3BA80DD1CFB300E003DC1BA /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
|
||||
5644488A1EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
F3BA80521CFB2B59003DC1BA /* DatabaseQueueSchemaCacheTests.swift in Sources */,
|
||||
F3BA80BE1CFB2FD1003DC1BA /* DatabasePoolReadOnlyTests.swift in Sources */,
|
||||
562EA82D1F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
F3BA80C61CFB2FD8003DC1BA /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
F3BA81161CFB305E003DC1BA /* RowConvertible+QueryInterfaceRequestTests.swift in Sources */,
|
||||
F3BA80F41CFB301D003DC1BA /* StatementColumnConvertibleFetchTests.swift in Sources */,
|
||||
@@ -5376,11 +5418,13 @@
|
||||
F3BA81101CFB3057003DC1BA /* Row+FoundationTests.swift in Sources */,
|
||||
F3BA812C1CFB3064003DC1BA /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
5698AC991DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
|
||||
562EA8321F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
|
||||
56A8C2451D1918EF0096E9D4 /* FoundationNSUUIDTests.swift in Sources */,
|
||||
5657AB591D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
|
||||
564448861EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
|
||||
5698ACCB1DA62A2D0056AF8C /* FTS5TokenizerTests.swift in Sources */,
|
||||
56B14E821D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */,
|
||||
562EA8291F17B2AC00FA528C /* CompilationProtocolTests.swift in Sources */,
|
||||
56FF45591D2CDA5200F21EF9 /* RecordUniqueIndexTests.swift in Sources */,
|
||||
56B021CC1D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift in Sources */,
|
||||
561667041D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
|
||||
|
||||
+66
-50
@@ -294,10 +294,18 @@ public final class Database {
|
||||
var lastErrorMessage: String? { return String(cString: sqlite3_errmsg(sqliteConnection)) }
|
||||
|
||||
/// True if the database connection is currently in a transaction.
|
||||
public var isInsideTransaction: Bool { return isInsideExplicitTransaction || !savepointStack.isEmpty }
|
||||
|
||||
/// Set by BEGIN/ROLLBACK/COMMIT transaction statements.
|
||||
fileprivate var isInsideExplicitTransaction: Bool = false
|
||||
public var isInsideTransaction: Bool {
|
||||
// https://sqlite.org/c3ref/get_autocommit.html
|
||||
//
|
||||
// > The sqlite3_get_autocommit() interface returns non-zero or zero if
|
||||
// > the given database connection is or is not in autocommit mode,
|
||||
// > respectively.
|
||||
//
|
||||
// > Autocommit mode is on by default. Autocommit mode is disabled by a
|
||||
// > BEGIN statement. Autocommit mode is re-enabled by a COMMIT
|
||||
// > or ROLLBACK.
|
||||
return sqlite3_get_autocommit(sqliteConnection) == 0
|
||||
}
|
||||
|
||||
/// Set by SAVEPOINT/COMMIT/ROLLBACK/RELEASE savepoint statements.
|
||||
fileprivate var savepointStack = SavepointStack()
|
||||
@@ -471,6 +479,7 @@ public final class Database {
|
||||
guard let stmt = stmt else { return SQLITE_OK }
|
||||
guard let expandedSQLCString = sqlite3_expanded_sql(OpaquePointer(stmt)) else { return SQLITE_OK }
|
||||
let sql = String(cString: expandedSQLCString)
|
||||
sqlite3_free(expandedSQLCString)
|
||||
let database = unsafeBitCast(dbPointer, to: Database.self)
|
||||
database.configuration.trace!(sql)
|
||||
return SQLITE_OK
|
||||
@@ -487,6 +496,7 @@ public final class Database {
|
||||
guard let stmt = stmt else { return SQLITE_OK }
|
||||
guard let expandedSQLCString = sqlite3_expanded_sql(OpaquePointer(stmt)) else { return SQLITE_OK }
|
||||
let sql = String(cString: expandedSQLCString)
|
||||
sqlite3_free(expandedSQLCString)
|
||||
let database = unsafeBitCast(dbPointer, to: Database.self)
|
||||
database.configuration.trace!(sql)
|
||||
return SQLITE_OK
|
||||
@@ -1629,7 +1639,7 @@ extension Database {
|
||||
|
||||
if needsRollback {
|
||||
do {
|
||||
try rollback(underlyingError: firstError)
|
||||
try rollback()
|
||||
} catch {
|
||||
if firstError == nil {
|
||||
firstError = error
|
||||
@@ -1706,7 +1716,7 @@ extension Database {
|
||||
if needsRollback {
|
||||
do {
|
||||
if topLevelSavepoint {
|
||||
try rollback(underlyingError: firstError)
|
||||
try rollback()
|
||||
} else {
|
||||
// Rollback, and release the savepoint.
|
||||
// Rollback alone is not enough to clear the savepoint from
|
||||
@@ -1737,36 +1747,48 @@ extension Database {
|
||||
}
|
||||
}
|
||||
|
||||
private func rollback(underlyingError: Error?) throws {
|
||||
do {
|
||||
private func rollback() throws {
|
||||
// The SQLite documentation contains two related but distinct techniques
|
||||
// to handle rollbacks and errors:
|
||||
//
|
||||
// https://www.sqlite.org/lang_transaction.html#immediate
|
||||
//
|
||||
// > Response To Errors Within A Transaction
|
||||
// >
|
||||
// > If certain kinds of errors occur within a transaction, the
|
||||
// > transaction may or may not be rolled back automatically.
|
||||
// > The errors that can cause an automatic rollback include:
|
||||
// >
|
||||
// > - SQLITE_FULL: database or disk full
|
||||
// > - SQLITE_IOERR: disk I/O error
|
||||
// > - SQLITE_BUSY: database in use by another process
|
||||
// > - SQLITE_NOMEM: out or memory
|
||||
// >
|
||||
// > [...] It is recommended that applications respond to the
|
||||
// > errors listed above by explicitly issuing a ROLLBACK
|
||||
// > command. If the transaction has already been rolled back
|
||||
// > automatically by the error response, then the ROLLBACK
|
||||
// > command will fail with an error, but no harm is caused
|
||||
// > by this.
|
||||
//
|
||||
// https://sqlite.org/c3ref/get_autocommit.html
|
||||
//
|
||||
// > The sqlite3_get_autocommit() interface returns non-zero or zero if
|
||||
// > the given database connection is or is not in autocommit mode,
|
||||
// > respectively.
|
||||
// >
|
||||
// > [...] If certain kinds of errors occur on a statement within a
|
||||
// > multi-statement transaction (errors including SQLITE_FULL,
|
||||
// > SQLITE_IOERR, SQLITE_NOMEM, SQLITE_BUSY, and SQLITE_INTERRUPT) then
|
||||
// > the transaction might be rolled back automatically. The only way to
|
||||
// > find out whether SQLite automatically rolled back the transaction
|
||||
// > after an error is to use this function.
|
||||
//
|
||||
// The second technique is more robust, because we don't have to guess
|
||||
// which rollback errors should be ignored, and which rollback errors
|
||||
// should be exposed to the library user.
|
||||
if sqlite3_get_autocommit(sqliteConnection) == 0 {
|
||||
try execute("ROLLBACK TRANSACTION")
|
||||
} catch {
|
||||
// https://www.sqlite.org/lang_transaction.html#immediate
|
||||
//
|
||||
// > Response To Errors Within A Transaction
|
||||
// >
|
||||
// > If certain kinds of errors occur within a transaction, the
|
||||
// > transaction may or may not be rolled back automatically.
|
||||
// > The errors that can cause an automatic rollback include:
|
||||
// >
|
||||
// > - SQLITE_FULL: database or disk full
|
||||
// > - SQLITE_IOERR: disk I/O error
|
||||
// > - SQLITE_BUSY: database in use by another process
|
||||
// > - SQLITE_NOMEM: out or memory
|
||||
// >
|
||||
// > [...] It is recommended that applications respond to the
|
||||
// > errors listed above by explicitly issuing a ROLLBACK
|
||||
// > command. If the transaction has already been rolled back
|
||||
// > automatically by the error response, then the ROLLBACK
|
||||
// > command will fail with an error, but no harm is caused
|
||||
// > by this.
|
||||
//
|
||||
// TODO: test that isInsideTransaction, savepointStack, transaction
|
||||
// observers, etc. are in good shape when such an implicit rollback
|
||||
// happens.
|
||||
guard let underlyingError = underlyingError as? DatabaseError, [.SQLITE_FULL, .SQLITE_IOERR, .SQLITE_BUSY, .SQLITE_NOMEM].contains(underlyingError.resultCode) else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1884,9 +1906,11 @@ extension Database {
|
||||
}
|
||||
|
||||
func updateStatementWillExecute(_ statement: UpdateStatement) {
|
||||
// Grab the transaction observers that are interested in the actions
|
||||
// performed by the statement.
|
||||
let databaseEventKinds = statement.databaseEventKinds
|
||||
activeTransactionObservers = transactionObservers.filter { observer in
|
||||
return databaseEventKinds.index(where: observer.observes) != nil
|
||||
return databaseEventKinds.contains(where: observer.observes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1947,7 +1971,7 @@ extension Database {
|
||||
case .transaction(action: let action):
|
||||
switch action {
|
||||
case .begin:
|
||||
isInsideExplicitTransaction = true
|
||||
break
|
||||
case .commit:
|
||||
if case .pending = self.transactionHookState {
|
||||
// A COMMIT statement has ended a deferred transaction
|
||||
@@ -1997,7 +2021,7 @@ extension Database {
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction hook
|
||||
/// See sqlite3_commit_hook
|
||||
func willCommit() throws {
|
||||
let eventsBuffer = savepointStack.eventsBuffer
|
||||
savepointStack.clear()
|
||||
@@ -2013,12 +2037,10 @@ extension Database {
|
||||
}
|
||||
|
||||
#if SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
/// Transaction hook
|
||||
/// See sqlite3_preupdate_hook
|
||||
private func willChange(with event: DatabasePreUpdateEvent) {
|
||||
if savepointStack.isEmpty {
|
||||
// Don't notify all transactionObservers about the database event.
|
||||
// Only notify those that are interested in the event, and have been
|
||||
// isolated in updateStatementWillExecute().
|
||||
// Notify all interested transactionObservers.
|
||||
for observer in activeTransactionObservers {
|
||||
observer.databaseWillChange(with: event)
|
||||
}
|
||||
@@ -2029,12 +2051,10 @@ extension Database {
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Transaction hook
|
||||
/// See sqlite3_update_hook
|
||||
private func didChange(with event: DatabaseEvent) {
|
||||
if savepointStack.isEmpty {
|
||||
// Don't notify all transactionObservers about the database event.
|
||||
// Only notify those that are interested in the event, and have been
|
||||
// isolated in updateStatementWillExecute().
|
||||
// Notify all interested transactionObservers.
|
||||
for observer in activeTransactionObservers {
|
||||
observer.databaseDidChange(with: event)
|
||||
}
|
||||
@@ -2044,9 +2064,7 @@ extension Database {
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction hook
|
||||
private func didCommit() {
|
||||
isInsideExplicitTransaction = false
|
||||
savepointStack.clear()
|
||||
|
||||
for observer in transactionObservers {
|
||||
@@ -2055,9 +2073,7 @@ extension Database {
|
||||
cleanupTransactionObservers()
|
||||
}
|
||||
|
||||
/// Transaction hook
|
||||
private func didRollback(notifyTransactionObservers: Bool) {
|
||||
isInsideExplicitTransaction = false
|
||||
savepointStack.clear()
|
||||
|
||||
if notifyTransactionObservers {
|
||||
|
||||
@@ -538,48 +538,64 @@ extension DatabasePool : DatabaseWriter {
|
||||
/// - throws: The error thrown by the block, or any DatabaseError that would
|
||||
/// happen while establishing the read access to the database.
|
||||
public func readFromCurrentState(_ block: @escaping (Database) -> Void) throws {
|
||||
// https://www.sqlite.org/isolation.html
|
||||
//
|
||||
// > In WAL mode, SQLite exhibits "snapshot isolation". When a read
|
||||
// > transaction starts, that reader continues to see an unchanging
|
||||
// > "snapshot" of the database file as it existed at the moment in time
|
||||
// > when the read transaction started. Any write transactions that
|
||||
// > commit while the read transaction is active are still invisible to
|
||||
// > the read transaction, because the reader is seeing a snapshot of
|
||||
// > database file from a prior moment in time.
|
||||
//
|
||||
// That's exactly what we need. But what does "when read transaction
|
||||
// starts" mean?
|
||||
//
|
||||
// http://www.sqlite.org/lang_transaction.html
|
||||
//
|
||||
// > Deferred [transaction] means that no locks are acquired on the
|
||||
// > database until the database is first accessed. [...] Locks are not
|
||||
// > acquired until the first read or write operation. [...] Because the
|
||||
// > acquisition of locks is deferred until they are needed, it is
|
||||
// > possible that another thread or process could create a separate
|
||||
// > transaction and write to the database after the BEGIN on the
|
||||
// > current thread has executed.
|
||||
//
|
||||
// Now that's precise enough: SQLite defers "snapshot isolation" until
|
||||
// the first SELECT:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// UPDATE ... (1)
|
||||
// Here the change (1) is visible
|
||||
// SELECT ...
|
||||
// UPDATE ... (2)
|
||||
// Here the change (2) is not visible
|
||||
//
|
||||
// The readFromCurrentState method says that no change should be visible
|
||||
// at all. We thus have to perform a select that establishes the
|
||||
// snapshot isolation before we release the writer queue:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// SELECT anything
|
||||
// UPDATE ...
|
||||
// Here the change is not visible by GRDB user
|
||||
|
||||
// This method must be called from the writing dispatch queue:
|
||||
writer.preconditionValidQueue()
|
||||
|
||||
// The semaphore that blocks the writing dispatch queue until snapshot
|
||||
// isolation has been established:
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
|
||||
var readError: Error? = nil
|
||||
try readerPool.get { reader in
|
||||
reader.async { db in
|
||||
// https://www.sqlite.org/isolation.html
|
||||
//
|
||||
// > In WAL mode, SQLite exhibits "snapshot isolation". When a
|
||||
// > read transaction starts, that reader continues to see an
|
||||
// > unchanging "snapshot" of the database file as it existed at
|
||||
// > the moment in time when the read transaction started.
|
||||
// > Any write transactions that commit while the read
|
||||
// > transaction is active are still invisible to the read
|
||||
// > transaction, because the reader is seeing a snapshot of
|
||||
// > database file from a prior moment in time.
|
||||
//
|
||||
// This documentation is NOT accurate. SQLite actually defers
|
||||
// isolation until the first SELECT:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// UPDATE ... (1)
|
||||
// Here the change (1) is visible
|
||||
// SELECT ...
|
||||
// UPDATE ... (2)
|
||||
// Here the change (2) is not visible
|
||||
//
|
||||
// This is not the guarantee expected by this method: no change
|
||||
// at all should be visible.
|
||||
//
|
||||
// Workaround: perform an initial read before releasing the
|
||||
// writer queue:
|
||||
//
|
||||
// Reader Writer
|
||||
// BEGIN DEFERRED TRANSACTION
|
||||
// SELECT anything -- the work around
|
||||
// UPDATE ...
|
||||
// Here the change is not visible by GRDB user
|
||||
do {
|
||||
try db.beginTransaction(.deferred)
|
||||
assert(db.isInsideTransaction)
|
||||
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").cursor().next() // doesn't work with cached statement
|
||||
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").cursor().next()
|
||||
} catch {
|
||||
readError = error
|
||||
semaphore.signal() // Release the writer queue and rethrow error
|
||||
|
||||
@@ -95,15 +95,6 @@ public final class Row {
|
||||
self.init(impl: StatementCopyRowImpl(sqliteStatement: sqliteStatement, columnNames: statementRef.takeUnretainedValue().columnNames))
|
||||
}
|
||||
|
||||
/// Creates a row from the *current state* of the SQLite statement.
|
||||
///
|
||||
/// The row is implemented on top of StatementCopyRowImpl, which *copies*
|
||||
/// the values from the SQLite statement so that further iteration of the
|
||||
/// statement does not modify the row.
|
||||
convenience init(copiedFromSQLiteStatement sqliteStatement: SQLiteStatement, columnNames: [String]) {
|
||||
self.init(impl: StatementCopyRowImpl(sqliteStatement: sqliteStatement, columnNames: columnNames))
|
||||
}
|
||||
|
||||
init(impl: RowImpl) {
|
||||
self.impl = impl
|
||||
self.statementRef = nil
|
||||
|
||||
@@ -14,6 +14,28 @@ extension SQLBinaryOperator {
|
||||
static let isNot = SQLBinaryOperator("IS NOT", negated: "IS")
|
||||
}
|
||||
|
||||
// Outputs "x = y" or "x IS NULL"
|
||||
private func isEqual(_ lhs: SQLExpression, _ rhs: SQLExpression) -> SQLExpression {
|
||||
switch (lhs, rhs) {
|
||||
case (let lhs, let rhs as DatabaseValue):
|
||||
switch rhs.storage {
|
||||
case .null:
|
||||
return SQLExpressionBinary(.is, lhs, DatabaseValue.null)
|
||||
default:
|
||||
return SQLExpressionBinary(.equal, lhs, rhs)
|
||||
}
|
||||
case (let lhs as DatabaseValue, let rhs):
|
||||
switch lhs.storage {
|
||||
case .null:
|
||||
return SQLExpressionBinary(.is, rhs, DatabaseValue.null)
|
||||
default:
|
||||
return SQLExpressionBinary(.equal, lhs, rhs)
|
||||
}
|
||||
default:
|
||||
return SQLExpressionBinary(.equal, lhs, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `=` SQL operator.
|
||||
///
|
||||
/// // name = 'Arthur'
|
||||
@@ -24,11 +46,7 @@ extension SQLBinaryOperator {
|
||||
/// // name IS NULL
|
||||
/// Column("name") == nil
|
||||
public func == (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression {
|
||||
if let rhs = rhs {
|
||||
return SQLExpressionBinary(.equal, lhs.sqlExpression, rhs.sqlExpression)
|
||||
} else {
|
||||
return SQLExpressionBinary(.`is`, lhs.sqlExpression, DatabaseValue.null)
|
||||
}
|
||||
return isEqual(lhs.sqlExpression, rhs?.sqlExpression ?? DatabaseValue.null)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `=` SQL operator.
|
||||
@@ -71,11 +89,7 @@ public func == (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression {
|
||||
/// // name IS NULL
|
||||
/// nil == Column("name")
|
||||
public func == (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
if let lhs = lhs {
|
||||
return SQLExpressionBinary(.equal, lhs.sqlExpression, rhs.sqlExpression)
|
||||
} else {
|
||||
return SQLExpressionBinary(.`is`, rhs.sqlExpression, DatabaseValue.null)
|
||||
}
|
||||
return isEqual(lhs?.sqlExpression ?? DatabaseValue.null, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `=` SQL operator.
|
||||
@@ -113,7 +127,7 @@ public func == (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
/// // email = login
|
||||
/// Column("email") == Column("login")
|
||||
public func == (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
return SQLExpressionBinary(.equal, lhs.sqlExpression, rhs.sqlExpression)
|
||||
return isEqual(lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<>` SQL operator.
|
||||
@@ -126,11 +140,7 @@ public func == (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQL
|
||||
/// // name IS NOT NULL
|
||||
/// Column("name") != nil
|
||||
public func != (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression {
|
||||
if let rhs = rhs {
|
||||
return SQLExpressionBinary(.notEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
} else {
|
||||
return SQLExpressionBinary(.isNot, lhs.sqlExpression, DatabaseValue.null)
|
||||
}
|
||||
return isEqual(lhs.sqlExpression, rhs?.sqlExpression ?? DatabaseValue.null).negated
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<>` SQL operator.
|
||||
@@ -173,11 +183,7 @@ public func != (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression {
|
||||
/// // name IS NOT NULL
|
||||
/// nil != Column("name")
|
||||
public func != (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
if let lhs = lhs {
|
||||
return SQLExpressionBinary(.notEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
} else {
|
||||
return SQLExpressionBinary(.isNot, rhs.sqlExpression, DatabaseValue.null)
|
||||
}
|
||||
return isEqual(lhs?.sqlExpression ?? DatabaseValue.null, rhs.sqlExpression).negated
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<>` SQL operator.
|
||||
@@ -215,7 +221,7 @@ public func != (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
/// // email <> login
|
||||
/// Column("email") != Column("login")
|
||||
public func != (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
return SQLExpressionBinary(.notEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
return isEqual(lhs.sqlExpression, rhs.sqlExpression).negated
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
@@ -223,7 +229,7 @@ public func != (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQL
|
||||
/// // name IS 'Arthur'
|
||||
/// Column("name") === "Arthur"
|
||||
public func === (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression {
|
||||
return SQLExpressionBinary(.`is`, lhs.sqlExpression, rhs?.sqlExpression ?? DatabaseValue.null)
|
||||
return SQLExpressionBinary(.is, lhs.sqlExpression, rhs?.sqlExpression ?? DatabaseValue.null)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
@@ -240,9 +246,9 @@ public func === (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpress
|
||||
/// "Arthur" === Column("name")
|
||||
public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
if let lhs = lhs {
|
||||
return SQLExpressionBinary(.`is`, lhs.sqlExpression, rhs.sqlExpression)
|
||||
return SQLExpressionBinary(.is, lhs.sqlExpression, rhs.sqlExpression)
|
||||
} else {
|
||||
return SQLExpressionBinary(.`is`, rhs.sqlExpression, DatabaseValue.null)
|
||||
return SQLExpressionBinary(.is, rhs.sqlExpression, DatabaseValue.null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +257,7 @@ public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpres
|
||||
/// // name IS 'Arthur' COLLATE NOCASE
|
||||
/// "Arthur" === Column("name").collating(.nocase)
|
||||
public func === (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
return SQLExpressionCollate(lhs == rhs.expression, collationName: rhs.collationName)
|
||||
return SQLExpressionCollate(lhs === rhs.expression, collationName: rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
@@ -259,7 +265,7 @@ public func === (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpress
|
||||
/// // email IS login
|
||||
/// Column("email") === Column("login")
|
||||
public func === (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression {
|
||||
return SQLExpressionBinary(.`is`, lhs.sqlExpression, rhs.sqlExpression)
|
||||
return SQLExpressionBinary(.is, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS NOT` SQL operator.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDBCipher'
|
||||
s.version = '1.2'
|
||||
s.version = '1.2.2'
|
||||
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'A Swift application toolkit for SQLite databases.'
|
||||
|
||||
@@ -3,7 +3,7 @@ GRDB.swift [
|
||||
**Latest release**: July 20, 2017 • version 1.2.2 • [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
**Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Xcode 8.3+ • Swift 3.1
|
||||
|
||||
@@ -237,7 +237,7 @@ Installation
|
||||
|
||||
See [Encryption](#encryption) for the installation procedure of GRDB with SQLCipher.
|
||||
|
||||
See [Custom SQLite builds](Documentation/CustomSQLiteBuilds.md) for the installation procedure of GRDB with a customized build of SQLite 3.19.2.
|
||||
See [Custom SQLite builds](Documentation/CustomSQLiteBuilds.md) for the installation procedure of GRDB with a customized build of SQLite 3.19.3.
|
||||
|
||||
|
||||
## CocoaPods
|
||||
@@ -275,7 +275,7 @@ Any pull request that has the `make test_CarthageBuild` command successfully com
|
||||
|
||||
## Manually
|
||||
|
||||
1. [Download](https://github.com/groue/GRDB.swift/releases/tag/1.2) a copy of GRDB.swift, or clone its repository and make sure you use the latest tagged version with the `git checkout v1.2` command.
|
||||
1. [Download](https://github.com/groue/GRDB.swift/releases/tag/v1.2.2) a copy of GRDB.swift, or clone its repository and make sure you use the latest tagged version with the `git checkout v1.2.2` command.
|
||||
|
||||
2. Embed the `GRDB.xcodeproj` project in your own project.
|
||||
|
||||
@@ -4811,7 +4811,7 @@ Alternatively, perform a manual installation of GRDB and SQLCipher:
|
||||
|
||||
```sh
|
||||
cd [GRDB.swift directory]
|
||||
git checkout v1.2
|
||||
git checkout v1.2.2
|
||||
git submodule update --init SQLCipher/src
|
||||
```
|
||||
|
||||
|
||||
+1
-1
Submodule SQLiteCustom/src updated: b488b6f904...7c5ee863f3.
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.2</string>
|
||||
<string>1.2.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
- [ ] GLOB https://www.sqlite.org/lang_expr.html
|
||||
- [ ] REGEXP https://www.sqlite.org/lang_expr.html
|
||||
- [ ] CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END https://www.sqlite.org/lang_expr.html
|
||||
- [ ] See how we can use [sqlite3_get_autocommit](https://www.sqlite.org/capi3ref.html#sqlite3_get_autocommit)
|
||||
- [ ] Write regression tests for #156 and #157
|
||||
|
||||
Not sure
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
#if GRDBCIPHER
|
||||
import GRDBCipher
|
||||
#elseif GRDBCUSTOMSQLITE
|
||||
import GRDBCustomSQLite
|
||||
#else
|
||||
import GRDB
|
||||
#endif
|
||||
|
||||
// GRDB 1.2 has shipped with a change in the DatabaseReader public protocol.
|
||||
//
|
||||
// This change in a public protocol has broken the semantic versioning contract,
|
||||
// because userland types that adopt the protocol suddenly stop compiling. And
|
||||
// indeed RxGRDB had to be modified in order to accomodate GRDB 1.2.
|
||||
//
|
||||
// To prevent such breaking change, this file contains types that adopt all GRBD
|
||||
// public protocols, but experimental ones. Test pass if this file compiles
|
||||
// without any error.
|
||||
|
||||
// MARK: - Cursor
|
||||
|
||||
private class UserCursor<T> : Cursor {
|
||||
func next() throws -> T? { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension UserCursor {
|
||||
// Test presence of the Element associated type
|
||||
static var elementType: Element.Type { return Element.self }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseAggregate
|
||||
|
||||
private struct UserDatabaseAggregate1 : DatabaseAggregate {
|
||||
let a: Int?
|
||||
init() { a = nil }
|
||||
mutating func step(_ dbValues: [DatabaseValue]) throws { }
|
||||
func finalize() throws -> DatabaseValueConvertible? { preconditionFailure() }
|
||||
}
|
||||
|
||||
private class UserDatabaseAggregate2 : DatabaseAggregate {
|
||||
required init() { }
|
||||
func step(_ dbValues: [DatabaseValue]) throws { }
|
||||
func finalize() throws -> DatabaseValueConvertible? { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseReader
|
||||
|
||||
private class UserDatabaseReader : DatabaseReader {
|
||||
func read<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func add(function: DatabaseFunction) { }
|
||||
func remove(function: DatabaseFunction) { }
|
||||
func add(collation: DatabaseCollation) { }
|
||||
func remove(collation: DatabaseCollation) { }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseValueConvertible
|
||||
|
||||
private struct UserDatabaseValueConvertible1 : DatabaseValueConvertible {
|
||||
var databaseValue: DatabaseValue { preconditionFailure() }
|
||||
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UserDatabaseValueConvertible1? { preconditionFailure() }
|
||||
}
|
||||
|
||||
private class UserDatabaseValueConvertible2 : DatabaseValueConvertible {
|
||||
var databaseValue: DatabaseValue { preconditionFailure() }
|
||||
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseWriter
|
||||
|
||||
private class UserDatabaseWriter : DatabaseWriter {
|
||||
func read<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func add(function: DatabaseFunction) { }
|
||||
func remove(function: DatabaseFunction) { }
|
||||
func add(collation: DatabaseCollation) { }
|
||||
func remove(collation: DatabaseCollation) { }
|
||||
func write<T>(_ block: (Database) throws -> T) rethrows -> T { preconditionFailure() }
|
||||
func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T { preconditionFailure() }
|
||||
func readFromCurrentState(_ block: @escaping (Database) -> Void) throws { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - FTS5Tokenizer
|
||||
|
||||
#if SQLITE_ENABLE_FTS5
|
||||
private class UserFTS5Tokenizer : FTS5Tokenizer {
|
||||
func tokenize(context: UnsafeMutableRawPointer?, tokenization: FTS5Tokenization, pText: UnsafePointer<Int8>?, nText: Int32, tokenCallback: @escaping FTS5TokenCallback) -> Int32 { preconditionFailure() }
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - FTS5CustomTokenizer
|
||||
|
||||
#if SQLITE_ENABLE_FTS5
|
||||
private class UserFTS5CustomTokenizer : FTS5CustomTokenizer {
|
||||
static let name: String = "UserFTS5CustomTokenizer"
|
||||
required init(db: Database, arguments: [String]) throws { preconditionFailure() }
|
||||
func tokenize(context: UnsafeMutableRawPointer?, tokenization: FTS5Tokenization, pText: UnsafePointer<Int8>?, nText: Int32, tokenCallback: @escaping FTS5TokenCallback) -> Int32 { preconditionFailure() }
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - FTS5WrapperTokenizer
|
||||
|
||||
#if SQLITE_ENABLE_FTS5
|
||||
private class UserFTS5WrapperTokenizer : FTS5WrapperTokenizer {
|
||||
static let name: String = "UserFTS5WrapperTokenizer"
|
||||
var wrappedTokenizer: FTS5Tokenizer { preconditionFailure() }
|
||||
required init(db: Database, arguments: [String]) throws { preconditionFailure() }
|
||||
func accept(token: String, flags: FTS5TokenFlags, for tokenization: FTS5Tokenization, tokenCallback: (String, FTS5TokenFlags) throws -> ()) throws { preconditionFailure() }
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - MutablePersistable
|
||||
|
||||
private struct UserMutablePersistable1 : MutablePersistable {
|
||||
static let databaseTableName = "UserMutablePersistable1"
|
||||
func encode(to container: inout PersistenceContainer) { }
|
||||
}
|
||||
|
||||
private class UserMutablePersistable2 : MutablePersistable {
|
||||
static let databaseTableName = "UserMutablePersistable2"
|
||||
func encode(to container: inout PersistenceContainer) { }
|
||||
}
|
||||
|
||||
// MARK: - Persistable
|
||||
|
||||
private struct UserPersistable1 : Persistable {
|
||||
static let databaseTableName = "UserPersistable1"
|
||||
func encode(to container: inout PersistenceContainer) { }
|
||||
}
|
||||
|
||||
private class UserPersistable2 : Persistable {
|
||||
static let databaseTableName = "UserPersistable2"
|
||||
func encode(to container: inout PersistenceContainer) { }
|
||||
}
|
||||
|
||||
// MARK: - Request
|
||||
|
||||
private struct UserRequest1 : Request {
|
||||
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { preconditionFailure() }
|
||||
}
|
||||
|
||||
private class UserRequest2 : Request {
|
||||
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - RowConvertible
|
||||
|
||||
private struct UserRowConvertible1 : RowConvertible {
|
||||
init(row: Row) { }
|
||||
}
|
||||
|
||||
private class UserRowConvertible2 : RowConvertible {
|
||||
required init(row: Row) { }
|
||||
}
|
||||
|
||||
// MARK: - StatementColumnConvertible
|
||||
|
||||
private struct UserStatementColumnConvertible1 : StatementColumnConvertible {
|
||||
init(sqliteStatement: SQLiteStatement, index: Int32) { }
|
||||
}
|
||||
|
||||
private class UserStatementColumnConvertible2 : StatementColumnConvertible {
|
||||
required init(sqliteStatement: SQLiteStatement, index: Int32) { }
|
||||
}
|
||||
|
||||
// MARK: - TableMapping
|
||||
|
||||
private struct UserTableMapping1 : TableMapping {
|
||||
static let databaseTableName = "UserTableMapping1"
|
||||
}
|
||||
|
||||
private class UserTableMapping2 : TableMapping {
|
||||
static let databaseTableName = "UserTableMapping2"
|
||||
}
|
||||
|
||||
// MARK: - TypedRequest
|
||||
|
||||
private struct UserTypedRequest1 : TypedRequest {
|
||||
struct CustomType { }
|
||||
typealias RowDecoder = CustomType
|
||||
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { preconditionFailure() }
|
||||
}
|
||||
|
||||
private class UserTypedRequest2<T> : TypedRequest {
|
||||
typealias RowDecoder = T
|
||||
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - TransactionObserver
|
||||
|
||||
private class UserTransactionObserver : TransactionObserver {
|
||||
func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool { return false }
|
||||
func databaseDidChange(with event: DatabaseEvent) { }
|
||||
func databaseWillCommit() throws { }
|
||||
func databaseDidCommit(_ db: Database) { }
|
||||
func databaseDidRollback(_ db: Database) { }
|
||||
#if SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
func databaseWillChange(with event: DatabasePreUpdateEvent) { }
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - VirtualTableModule
|
||||
|
||||
private struct UserVirtualTableModule1 : VirtualTableModule {
|
||||
struct CustomTableDefinition { }
|
||||
let moduleName = "UserVirtualTableModule1"
|
||||
func makeTableDefinition() -> CustomTableDefinition { preconditionFailure() }
|
||||
func moduleArguments(for definition: CustomTableDefinition, in db: Database) throws -> [String] { preconditionFailure() }
|
||||
func database(_ db: Database, didCreate tableName: String, using definition: CustomTableDefinition) throws { }
|
||||
}
|
||||
|
||||
private class UserVirtualTableModule2 : VirtualTableModule {
|
||||
struct CustomTableDefinition { }
|
||||
let moduleName = "UserVirtualTableModule2"
|
||||
func makeTableDefinition() -> CustomTableDefinition { preconditionFailure() }
|
||||
func moduleArguments(for definition: CustomTableDefinition, in db: Database) throws -> [String] { preconditionFailure() }
|
||||
func database(_ db: Database, didCreate tableName: String, using definition: CustomTableDefinition) throws { }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#if GRDBCIPHER
|
||||
import GRDBCipher
|
||||
#elseif GRDBCUSTOMSQLITE
|
||||
import GRDBCustomSQLite
|
||||
#else
|
||||
import GRDB
|
||||
#endif
|
||||
|
||||
// This file contains types that subclass GRBD open classes. Test pass if this
|
||||
// file compiles without any error.
|
||||
|
||||
// MARK: - Record
|
||||
|
||||
private class UserRecord : Record {
|
||||
override init() { super.init() }
|
||||
required init(row: Row) { super.init(row: row) }
|
||||
override class var databaseTableName: String { return super.databaseTableName }
|
||||
override class var persistenceConflictPolicy: PersistenceConflictPolicy { return super.persistenceConflictPolicy }
|
||||
override class var selectsRowID: Bool { return super.selectsRowID }
|
||||
override func encode(to container: inout PersistenceContainer) { super.encode(to: &container) }
|
||||
override func didInsert(with rowID: Int64, for column: String?) { super.didInsert(with: rowID, for: column) }
|
||||
override func copy() -> Self { preconditionFailure() }
|
||||
override func insert(_ db: Database) throws { try super.insert(db) }
|
||||
override func update(_ db: Database, columns: Set<String>) throws { try super.update(db, columns: columns) }
|
||||
override func delete(_ db: Database) throws -> Bool { return try super.delete(db) }
|
||||
}
|
||||
@@ -381,9 +381,15 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age == nil)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age == DatabaseValue.null)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(nil == Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(DatabaseValue.null == Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age == Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" = \"age\")")
|
||||
@@ -436,6 +442,9 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(.nocase) == nil)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" IS NULL COLLATE NOCASE)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(.nocase) == DatabaseValue.null)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" IS NULL COLLATE NOCASE)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(collation) == "fOo")),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" = 'fOo' COLLATE localized_case_insensitive)")
|
||||
@@ -466,9 +475,15 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age != nil)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age != DatabaseValue.null)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(nil != Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(DatabaseValue.null != Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.age != Col.age)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" <> \"age\")")
|
||||
@@ -521,6 +536,9 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(.nocase) != nil)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" IS NOT NULL COLLATE NOCASE)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(.nocase) != DatabaseValue.null)),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" IS NOT NULL COLLATE NOCASE)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(Col.name.collating(collation) != "fOo")),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" <> 'fOo' COLLATE localized_case_insensitive)")
|
||||
@@ -545,9 +563,15 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(!(Col.age == nil))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(!(Col.age == DatabaseValue.null))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(!(nil == Col.age))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(!(DatabaseValue.null == Col.age))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" IS NOT NULL)")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(!(Col.age == Col.age))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"age\" <> \"age\")")
|
||||
|
||||
Reference in new issue
Block a user