Compare commits

...
426 Commits
Author SHA1 Message Date
Gwendal Roué d265e2d77b v3.6.2 2019-01-05 15:40:05 +01:00
Gwendal Roué ac40b63262 Merge pull request #464 from groue/feature/updatesChanges
Make updateChanges(_:with:) available to PersistableRecord structs
2019-01-05 14:47:35 +01:00
Gwendal Roué bac9d8e425 CHANGELOG.md 2019-01-05 14:46:38 +01:00
Gwendal Roué bf0c9b5c27 Move non-mutating updateChanges(_:with:) from PersistableRecord to PersistableRecord & AnyObject. 2019-01-05 12:35:28 +01:00
Gwendal Roué f70d04c76a Failing test for updateChanges(_:with:) for PersistableRecord struct
The problem is that the code does not compile :'(
2019-01-05 12:30:48 +01:00
Gwendal Roué 85aa899c7b Fix #462 2019-01-02 17:49:36 +01:00
Gwendal Roué 19fa05aecc Update TODO.md 2018-12-13 16:46:13 +01:00
Gwendal Roué 9c4a8fb0b2 Fix typo 2018-12-09 11:35:22 +01:00
Gwendal Roué e19f02b77e v3.6.1 2018-12-09 11:18:41 +01:00
Gwendal Roué b34030fc39 Merge pull request #458 from groue/feature/FixValueObserverOverRetain
Fix ValueObservation duration - code & doc
2018-12-09 10:37:51 +01:00
Gwendal Roué 40a5fb1195 Observer deallocation needs better tests 2018-12-09 06:17:36 +01:00
Gwendal Roué d9dd880d6d Fix flaky test 2018-12-09 05:45:14 +01:00
Gwendal Roué c51b0ba862 Fix documentation about ValueObservation.extent, and add a note in remove(transactionObserver:) documentation. 2018-12-08 17:32:18 +01:00
Gwendal Roué 197f922e7e Fix failing tests for over-retained ValueObserver 2018-12-08 17:11:53 +01:00
Gwendal Roué 25f6bd9673 Failing tests for over-retained ValueObserver 2018-12-08 17:11:30 +01:00
Gwendal Roué 909821f4e5 Add a link to Codable records 2018-12-08 14:57:20 +01:00
Gwendal Roué b211dc55c4 Put associations in the feature list
... and use the "relation" keyword: people familiar with other toolkits may search for this word https://forums.swift.org/t/new-release-grdb-3-6-0/18660/4
2018-12-08 14:36:45 +01:00
Gwendal Roué 863a762eca Wording 2018-12-08 12:23:41 +01:00
Gwendal Roué bb01da7635 Mention ValueObservation iin WhyAdoptGRDB 2018-12-08 11:32:26 +01:00
Gwendal Roué 558cdacb5b Fix typo 2018-12-08 07:50:41 +01:00
Gwendal Roué eff7dbd798 CHANGELOG 2018-12-08 07:18:22 +01:00
Gwendal Roué 1d3935baaf Merge pull request #457 from diatoming/patch-2
Typo in AssociationsBasics.md
2018-12-08 05:40:39 +01:00
diatoming b40e4e58e1 Typo in AssociationsBasics.md 2018-12-08 07:08:20 +08:00
Gwendal Roué 36d3607565 http://github.com/groue/GRDBDemo is no longer 2018-12-07 20:56:04 +01:00
Gwendal Roué d55807e2a2 Realm 3.12.0, Swift 4.2.1 2018-12-07 20:55:12 +01:00
Gwendal Roué 6447eeca17 v3.6.0 2018-12-07 18:58:30 +01:00
Gwendal Roué 1fea9c06e8 Merge branch 'development' 2018-12-07 18:30:07 +01:00
Gwendal Roué 11d3dd9538 CHANGELOG 2018-12-07 18:22:01 +01:00
Gwendal Roué f6f236512b Documentation 2018-12-07 18:08:53 +01:00
Gwendal Roué 343816ed7b Documentation 2018-12-07 18:04:16 +01:00
Gwendal Roué 59a65bf81e PULL_REQUEST_TEMPLATE 2018-12-07 17:57:50 +01:00
Gwendal Roué a5b06b5cb0 Merge branch 'master' into development 2018-12-07 17:55:00 +01:00
Gwendal Roué 802575c505 Merge pull request #456 from diatoming/patch-1
fix typo in AssociationsBasics.md
2018-12-07 13:13:04 +01:00
diatoming c433a130e5 Update AssociationsBasics.md
just fix typo
2018-12-07 19:56:28 +08:00
Gwendal Roué ca4a867803 Remove picture that breaks anchor linking 2018-12-07 08:43:59 +01:00
Gwendal Roué 37ac126d26 Documentation 2018-12-07 08:42:28 +01:00
Gwendal Roué 5badd62515 Documentation 2018-12-07 08:41:17 +01:00
Gwendal Roué 37983b8581 Documentation 2018-12-07 08:36:11 +01:00
Gwendal Roué 815a3697da Documentation 2018-12-07 08:20:18 +01:00
Gwendal Roué 32acfb2cf4 Merge pull request #455 from groue/feature/DatabaseRegionObserver
DatabaseRegionObservation
2018-12-07 08:07:28 +01:00
Gwendal Roué 9fd802b3ea Documentation 2018-12-06 18:54:09 +01:00
Gwendal Roué 21d243fc33 Documentation 2018-12-06 18:51:45 +01:00
Gwendal Roué 97936c3fad Documentation 2018-12-06 18:46:57 +01:00
Gwendal Roué 03934041c2 Fix DatabaseRegion doc layout 2018-12-06 18:41:43 +01:00
Gwendal Roué 862563fdaa Remove obsolete test 2018-12-06 16:42:20 +01:00
Gwendal Roué 73935dfa9d CHANGELOG 2018-12-06 14:02:10 +01:00
Gwendal Roué 9a3e6f0b97 CHANGELOG 2018-12-06 13:58:47 +01:00
Gwendal Roué bc5899543f Documentation 2018-12-06 13:55:08 +01:00
Gwendal Roué fd79a53a96 Documentation 2018-12-06 13:34:02 +01:00
Gwendal Roué 194624212e Move db observation documentations around 2018-12-06 13:33:17 +01:00
Gwendal Roué 1472385242 Documentation 2018-12-06 08:55:31 +01:00
Gwendal Roué 78bb086f69 Documentation 2018-12-06 08:43:44 +01:00
Gwendal Roué e3681fdde5 DatabaseRegionObservationTests 2018-12-06 08:28:43 +01:00
Gwendal Roué 6ec4556c2c DatabaseRegionObservation 2018-12-06 07:49:41 +01:00
Gwendal Roué 1e72731c07 Distinguish distinctUntilChanged from distinctUntilDatabaseChanged 2018-12-06 07:04:40 +01:00
Gwendal Roué 82329c899e Hide DatabaseWriter.remove(transactionObserver:) from Jazzy 2018-12-05 19:27:04 +01:00
Gwendal Roué 8ab6e67f07 Hide DatabaseWriter.add(observation:onError:onChange:) from Jazzy 2018-12-05 19:23:06 +01:00
Gwendal Roué 643bbc7076 Merge pull request #454 from groue/feature/distinctUntilChanged
ValueObservation.distinctUntilChanged
2018-12-05 12:06:42 +01:00
Gwendal Roué 61f2544afe Remove a breaking change introduced by #446 2018-12-05 08:47:55 +01:00
Gwendal Roué 546289bc88 CHANGELOG 2018-12-05 08:29:49 +01:00
Gwendal Roué d3d5b1d24c CHANGELOG 2018-12-05 08:28:08 +01:00
Gwendal Roué dd59186887 Documentation 2018-12-05 08:24:12 +01:00
Gwendal Roué 88d7c58522 TODO: remove some magic in GRDB 4 2018-12-05 08:02:18 +01:00
Gwendal Roué c711ca1e8f ValueObservation.distinctUntilChanged() 2018-12-05 07:58:03 +01:00
Gwendal Roué 56d49dd385 Cleanup 2018-12-02 10:12:21 +01:00
Gwendal Roué 7b97d75a80 Merge pull request #452 from groue/feature/MapReducer
ValueObservation.mapReducer
2018-12-02 07:56:50 +01:00
Gwendal Roué a8d9f2d82b CHANGELOG 2018-12-02 01:11:58 +01:00
Gwendal Roué c7d28de386 CHANGELOG 2018-12-02 01:10:13 +01:00
Gwendal Roué ce61d27a9e CHANGELOG 2018-12-02 01:02:14 +01:00
Gwendal Roué b8e3994858 ValueObservation.mapReducer
and expose more precise value reducers
2018-12-02 00:01:21 +01:00
Gwendal Roué 7c6c615969 Merge pull request #451 from groue/feature/CompactMap
ValueObservation.compactMap
2018-12-01 21:03:34 +01:00
Gwendal Roué 8c543f5078 Fix failing tests 2018-12-01 19:07:58 +01:00
Gwendal Roué 3884141fc2 map/compactMap fail preserving ValueObservation configuration 2018-12-01 19:06:16 +01:00
Gwendal Roué 2c3776d372 Fix typo 2018-12-01 18:59:01 +01:00
Gwendal Roué c1d8dcb105 Link to ValueObservation from GoodPracticesForDesigningRecordTypes 2018-12-01 17:17:54 +01:00
Gwendal Roué c89540683f README 2018-12-01 17:11:56 +01:00
Gwendal Roué 3687e11958 README 2018-12-01 17:10:17 +01:00
Gwendal Roué 90c588a9f5 README 2018-12-01 17:06:10 +01:00
Gwendal Roué 838d9204ab CHANGELOG 2018-12-01 17:02:30 +01:00
Gwendal Roué 2488007b9c README 2018-12-01 17:02:25 +01:00
Gwendal Roué 5b3412e9f7 ValueObservation.compactMap 2018-12-01 16:35:19 +01:00
Gwendal Roué f07eee3ca7 DispatchQueue creation cleanup 2018-12-01 16:22:05 +01:00
Gwendal Roué 769b247da9 Merge pull request #449 from groue/feature/fixEmptyContainersJSONEncoding
Fix JSON encoding of empty containers
2018-11-28 12:24:14 +01:00
Gwendal Roué ef54efcb75 Cleanup 2018-11-28 09:11:36 +01:00
Gwendal Roué f41112c071 Documentation 2018-11-28 08:46:48 +01:00
Gwendal Roué e8ad816de5 CHANGELOG 2018-11-28 08:41:30 +01:00
Gwendal Roué 32f1a7ae0f Fix JSON encoding of empty arrays and dictionaries 2018-11-28 08:34:32 +01:00
Gwendal Roué 3dcae6d409 Forgot that reducer factory closure throws 2018-11-25 18:35:05 +01:00
Gwendal Roué 550c016a98 Merge pull request #446 from groue/feature/ValueReducerFactory
ValueObservation: delayed reducer creation
2018-11-25 18:24:35 +01:00
Gwendal Roué e092e8b3ec CHANGELOG 2018-11-25 15:42:34 +01:00
Gwendal Roué 1b53bf9ea2 Documentation 2018-11-25 15:27:26 +01:00
Gwendal Roué 3f001ba04d ValueObservation now accept a reducer factory 2018-11-25 15:18:03 +01:00
Gwendal Roué 87c4775421 ValueObservation creates a reducer when its starts 2018-11-25 14:26:04 +01:00
Gwendal Roué 2e3f2f9d61 Tests for reducer queue labels 2018-11-25 09:35:17 +01:00
Gwendal Roué 798b727d7f Reducer queue honors qos and targetQueue configuration 2018-11-25 09:35:04 +01:00
Gwendal Roué 54361617fe Remove headers 2018-11-25 09:33:55 +01:00
Gwendal Roué 417b830b61 CHANGELOG menu 2018-11-25 07:51:08 +01:00
Gwendal Roué b757a44a77 CHANGELOG menu 2018-11-25 07:47:57 +01:00
Gwendal Roué 6b78be51e2 CHANGELOG 2018-11-24 23:22:12 +01:00
Gwendal Roué 466140e699 Merge pull request #445 from groue/feature/qos
Quality of service and target dispatch queue
2018-11-24 23:18:57 +01:00
Gwendal Roué 4e1eea5743 Run run qos and targetQueue tests on Xcode 9.3, iOS 9.0
We lack dispatchPrecondition(condition:)
2018-11-24 21:46:50 +01:00
Gwendal Roué 267b4f958d Remove useless availability check 2018-11-24 21:22:47 +01:00
Gwendal Roué 9c71061629 Tests for QoS 2018-11-24 21:14:35 +01:00
Gwendal Roué 40ba0a7e8f CHANGELOG 2018-11-24 20:57:43 +01:00
Gwendal Roué bf6a101338 dispatchPrecondition(condition:) iOS availability 2018-11-24 20:56:36 +01:00
Gwendal Roué 736db6a546 Confiiguration.qos and targetQueue 2018-11-24 20:48:17 +01:00
Gwendal Roué 6a10ad0e11 Merge pull request #444 from groue/feature/ValueObservationCombine
Combine Value Observations
2018-11-24 19:39:51 +01:00
Gwendal Roué a521c89962 Documentation 2018-11-24 19:39:15 +01:00
Gwendal Roué b155ab742a Documentation 2018-11-24 19:38:24 +01:00
Gwendal Roué 4376e7519f Documentation 2018-11-24 14:55:15 +01:00
Gwendal Roué 42f13a621a Documentation 2018-11-24 14:53:23 +01:00
Gwendal Roué 8a9ccccf93 Documentation 2018-11-24 14:47:34 +01:00
Gwendal Roué e3a8bfda6f Documentation 2018-11-24 14:37:36 +01:00
Gwendal Roué a5c291e7a8 CHANGELOG 2018-11-24 14:35:27 +01:00
Gwendal Roué 71b75ee265 Documentation 2018-11-24 14:27:41 +01:00
Gwendal Roué 3f1db5aa10 Cleanup 2018-11-24 14:22:04 +01:00
Gwendal Roué 5ff519afcb Documentation 2018-11-24 13:50:36 +01:00
Gwendal Roué 41d814b540 Tests for ValueObservation combine 2018-11-24 12:57:24 +01:00
Gwendal Roué 326ef19fe9 ValueObservation combination 2018-11-24 11:38:47 +01:00
Gwendal Roué 796644edda Fix test
Concurrency is hard
2018-11-23 07:41:31 +01:00
Gwendal Roué 03b51ee899 Second failed test :-( 2018-11-22 09:34:10 +01:00
Gwendal Roué a2af4fb99a Merge pull request #443 from groue/feature/updateChanges
In place record update
2018-11-22 08:16:09 +01:00
Gwendal Roué e95119130c Documentation tweaks 2018-11-22 08:14:00 +01:00
Gwendal Roué 9735d8b74e Record Comparison documentation 2018-11-21 23:08:53 +01:00
Gwendal Roué f4c0eaa912 updateChanges(_:with:) documentation 2018-11-21 23:03:30 +01:00
Gwendal Roué d6e7d74a12 Cleanup 2018-11-21 22:27:33 +01:00
Gwendal Roué 771c85581c Fix documentation typo 2018-11-21 22:13:07 +01:00
Gwendal Roué 1baca23500 CHANGELOG 2018-11-21 22:12:52 +01:00
Gwendal Roué cc2a2a3545 Non-mutating version of updateChanges 2018-11-21 22:09:41 +01:00
Gwendal Roué 72a2408fce CHANGELOG 2018-11-21 22:08:05 +01:00
Gwendal Roué 0cd1ca11ef TODO 2018-11-21 21:48:34 +01:00
Gwendal Roué c04e6ad86d Tests for updateChanges(_:with:) 2018-11-21 21:48:24 +01:00
Gwendal Roué 3e67a1a021 Why use fileprivate when private is enough? 2018-11-21 20:33:21 +01:00
Gwendal Roué a3e62d8734 Factor updateChanges 2018-11-21 20:28:22 +01:00
Gwendal Roué f5bfb9df95 MutablePersistableRecord.updateChanges(_:with:) 2018-11-21 08:37:51 +01:00
Gwendal Roué d45ed56b64 Fix documentation typo 2018-11-19 09:01:26 +01:00
Gwendal Roué 59175a6b4d DatabasePool: block reader until concurrent fetch has been executed 2018-11-18 17:18:29 +01:00
Gwendal Roué f4e77c7700 Fix Swift 4.1 "expression was too complex to be solved in reasonable time" error 2018-11-18 17:05:10 +01:00
Gwendal Roué cbc3467e2d Database.beginSnapshotIsolation() 2018-11-18 16:49:51 +01:00
Gwendal Roué 65cc0bb2b3 Cache frequently used statements 2018-11-18 16:49:14 +01:00
Gwendal Roué 7e548aee13 Cleanup SchemaInfo 2018-11-18 15:47:11 +01:00
Gwendal Roué 8d18b06e5d Merge pull request #442 from groue/feature/reindex
Reindex
2018-11-17 22:12:34 +01:00
Gwendal Roué 55c8d350b8 CHANGELOG 2018-11-17 19:17:25 +01:00
Gwendal Roué 064f1005e5 CHANGELOG 2018-11-17 19:12:20 +01:00
Gwendal Roué 53adad16e5 Tests for Database.reindex(collation:) 2018-11-17 18:56:38 +01:00
Gwendal Roué 466a1ad4d5 Database.reindex(collation:) 2018-11-17 18:56:29 +01:00
Gwendal Roué f80f59cc38 Tweaks to demo app 2018-11-17 18:41:46 +01:00
Gwendal Roué ead2b13362 Optimize value observation for views that feed from a single table
By removing views from the observed database region, we allow the "single-table observation optimization" to kick in.

Thank you @foxware00 for revealing this opportunity in #441 :-)
2018-11-17 16:29:31 +01:00
Gwendal Roué 0ea9a1ce0d Use SchemaInfo more 2018-11-17 15:59:09 +01:00
Gwendal Roué 3b7801efff Cache full database schema 2018-11-17 15:38:55 +01:00
Gwendal Roué 5efbbe9f0c Typo 2018-11-17 14:13:58 +01:00
Gwendal Roué d868b7e1ce Test ValueObservation with database queue and pool 2018-11-17 14:12:03 +01:00
Gwendal Roué 60358ba0c0 CHANGELOG 2018-11-17 13:43:03 +01:00
Gwendal Roué b6eb5ab399 ValueObservation: tests for region arrays 2018-11-17 13:26:14 +01:00
Gwendal Roué b9ab74cb1d ValueObservation: support region arrays (address #441) 2018-11-17 13:25:55 +01:00
Gwendal Roué d3fd838c6c DatabaseRegion cleanup and documentation
Goal: improve understanding of observation performance.
Context: https://github.com/groue/GRDB.swift/issues/441
2018-11-17 12:46:01 +01:00
Gwendal Roué 1108ba4bf2 DatabaseError gets a default message, derived from its resultCode 2018-11-16 09:07:52 +01:00
Gwendal Roué 49de0e0f49 Call sqlite3_close() even if opening failed
Thanks to https://github.com/feistydog/FeistyDB/commit/6859f622797480656f8897c2db5e620e6a98c858
2018-11-16 08:48:25 +01:00
Gwendal Roué d56b62a65f Flag ValueReducer as experimental 2018-11-10 12:31:35 +01:00
Gwendal Roué c28a4d4061 Remove public initializers of utility value reducers 2018-11-10 12:29:31 +01:00
Gwendal Roué 3971b43894 Cleanup 2018-11-05 09:08:14 +01:00
Gwendal Roué 9fc5c2680b Typo 2018-11-05 09:08:01 +01:00
Gwendal Roué 0f8156afed Cleanup demo app 2018-11-04 03:50:19 +01:00
Gwendal Roué da3f14c29a Typo 2018-11-03 16:39:36 +01:00
Gwendal Roué dbacf3acf0 Documentation 2018-11-02 18:04:48 +01:00
Gwendal Roué 961138b09b v3.5.0 2018-11-02 17:01:39 +01:00
Gwendal Roué 6c6e46b8d6 Merge branch 'development' 2018-11-02 16:55:53 +01:00
Gwendal Roué 0cbf259ed1 Merge pull request #435 from groue/feature/ValueObservation
Improved support for values observation
2018-11-02 16:47:22 +01:00
Gwendal Roué 07bf5882fe Adding more reactive engines is no longer hard 2018-11-02 16:28:06 +01:00
Gwendal Roué b3c7fec676 Documentation 2018-11-02 13:56:52 +01:00
Gwendal Roué 296a1d5b12 CHANGELOG 2018-11-02 13:18:27 +01:00
Gwendal Roué 8c5e3df546 Documentation 2018-11-02 13:04:22 +01:00
Gwendal Roué 50213c925f Documentation 2018-11-02 13:00:42 +01:00
Gwendal Roué a1a5165bd2 Documentation 2018-11-02 12:48:48 +01:00
Gwendal Roué 7d9e87088d Rename ValueObservation.isReadOnly to requiresWriteAccess 2018-11-02 12:31:26 +01:00
Gwendal Roué c300cf2a38 Documentation 2018-11-02 12:15:04 +01:00
Gwendal Roué c48d2e484a Documentation 2018-11-02 12:10:49 +01:00
Gwendal Roué 2bc8f33249 Cleanup 2018-11-02 11:49:03 +01:00
Gwendal Roué 257fc8b66a Cleanup 2018-11-02 08:35:16 +01:00
Gwendal Roué bc274a603c Documentation 2018-11-02 08:35:04 +01:00
Gwendal Roué ab7970d470 Documentation 2018-11-01 22:58:20 +01:00
Gwendal Roué 087a899f13 Rename ValueObservation.tracking(withUniquing:fetch) to ValueObservation.tracking(_:fetchDistinct) 2018-11-01 22:18:58 +01:00
Gwendal Roué 842eaf0816 ValueObservation: perform uniquing by default 2018-11-01 21:46:59 +01:00
Gwendal Roué f7b79e05f6 Attempt at addressing https://github.com/groue/GRDB.swift/issues/430 2018-11-01 16:59:39 +01:00
Gwendal Roué 1867ee91de Documentation 2018-11-01 13:38:54 +01:00
Gwendal Roué d53412d404 Documentation 2018-11-01 13:22:02 +01:00
Gwendal Roué 74ca85e52c More links to the demo app 2018-11-01 13:16:04 +01:00
Gwendal Roué 51942046b9 Avoid the "No output has been received in the last 10m0s" error on Travis 2018-11-01 13:10:52 +01:00
Gwendal Roué 38e1cc9a27 Use ValueObservation is demo application 2018-11-01 12:58:17 +01:00
Gwendal Roué 7e8ebed7a8 Documentation 2018-10-31 19:39:44 +01:00
Gwendal Roué eb95562b73 Documentation 2018-10-31 19:37:35 +01:00
Gwendal Roué 44af4e62a6 Documentation 2018-10-31 19:35:49 +01:00
Gwendal Roué 30363b4a5b Tests for ValueObservation.map 2018-10-31 19:02:47 +01:00
Gwendal Roué bb02d9d857 ValueObservation.map 2018-10-31 12:07:08 +01:00
Gwendal Roué 9babbcbcb3 README: foster ValueObservation 2018-10-31 08:59:50 +01:00
Gwendal Roué 04de6193c0 Documentation 2018-10-31 07:37:05 +01:00
Gwendal Roué 6fa72ebea1 Documentation 2018-10-30 13:44:05 +01:00
Gwendal Roué 0e51a0ff65 Documentation 2018-10-30 13:40:32 +01:00
Gwendal Roué a276a49a26 CHANGELOG 2018-10-30 13:37:58 +01:00
Gwendal Roué 741f0b2a43 CHANGELOG 2018-10-30 13:37:05 +01:00
Gwendal Roué 3d21773496 CHANGELOG 2018-10-30 13:33:24 +01:00
Gwendal Roué cca716e1ab Cleanup 2018-10-30 08:49:36 +01:00
Gwendal Roué 8e13cb4e6c Cleanup 2018-10-30 07:46:41 +01:00
Gwendal Roué c4d328783f Documentation 2018-10-30 07:24:27 +01:00
Gwendal Roué 22b5990669 Documentation 2018-10-29 23:04:00 +01:00
Gwendal Roué d3838d1d73 ValueObservation error handling 2018-10-29 21:13:14 +01:00
Gwendal Roué cdd7579104 Documentation 2018-10-29 19:40:37 +01:00
Gwendal Roué 4e3b7c14a9 Documentation 2018-10-29 19:39:44 +01:00
Gwendal Roué b4b824c360 dbQueue.start(observation) -> observation.start(in: dbQueue) 2018-10-29 19:31:04 +01:00
Gwendal Roué 6f86cbf0c4 Documentation 2018-10-29 18:48:16 +01:00
Gwendal Roué f68b1cd2c3 Documentation 2018-10-29 18:44:48 +01:00
Gwendal Roué 53f98a7bf6 Documentation 2018-10-29 18:42:04 +01:00
Gwendal Roué 77de519fcc More tests for read/write observations 2018-10-29 18:40:12 +01:00
Gwendal Roué 739c325079 Documentation 2018-10-29 18:34:11 +01:00
Gwendal Roué 10650704b5 Documentation (todo: document error handling) 2018-10-29 18:32:54 +01:00
Gwendal Roué 735394669d Documentation 2018-10-29 18:28:10 +01:00
Gwendal Roué 4e40d755f4 Documentation 2018-10-29 18:26:27 +01:00
Gwendal Roué e5f43e341b ValueScheduling.unsafe guarantees that initial value is notified on the dispatch queue which starts the observation 2018-10-29 18:23:38 +01:00
Gwendal Roué 72c5769e8b ValueScheduling.unsafe 2018-10-29 13:59:02 +01:00
Gwendal Roué 669b9c4e91 Test for the ValueReducer documented in README 2018-10-29 13:31:42 +01:00
Gwendal Roué a489959780 Typo 2018-10-29 13:10:04 +01:00
Gwendal Roué 1985b9129a Fix SPM build 2018-10-29 13:09:56 +01:00
Gwendal Roué f7712473aa Move Sequence.allSatisfy where it is used: tests 2018-10-29 12:27:39 +01:00
Gwendal Roué f582683f20 Move remove(transactionObserver:) to DatabaseReader 2018-10-29 12:26:12 +01:00
Gwendal Roué a4b35729df Documentation 2018-10-29 12:22:16 +01:00
Gwendal Roué 191607fc13 Documentation 2018-10-29 09:18:29 +01:00
Gwendal Roué 5a540e8850 Documentation 2018-10-29 09:16:42 +01:00
Gwendal Roué f59dba711c Try with "tracking" 2018-10-29 09:15:18 +01:00
Gwendal Roué 93326307fa Documentation 2018-10-29 09:00:15 +01:00
Gwendal Roué 8d6ec6297a Backport Sequence.allSatisfy in Swift 4.1 2018-10-29 08:52:59 +01:00
Gwendal Roué 1d47853abe Documentation 2018-10-29 08:47:51 +01:00
Gwendal Roué 38e4027599 Documentation 2018-10-29 08:41:22 +01:00
Gwendal Roué 29b54dd37d Documentation 2018-10-29 08:17:35 +01:00
Gwendal Roué 03d2bc43ac Documentation 2018-10-29 08:07:28 +01:00
Gwendal Roué 22ed0fb1a1 Documentation 2018-10-29 08:00:39 +01:00
Gwendal Roué 489454b0d4 add(observation:observation) -> start(observation) 2018-10-29 07:19:36 +01:00
Gwendal Roué 840f8358b5 Documentation 2018-10-29 06:51:56 +01:00
Gwendal Roué 470e1534dc Documentation 2018-10-28 22:29:15 +01:00
Gwendal Roué 158177364b Documentation 2018-10-28 22:04:39 +01:00
Gwendal Roué de2823b613 ValueObservation: StatementColumnConvertible tests 2018-10-28 19:28:19 +01:00
Gwendal Roué 0d5adfe5a9 ValueObservation: FetchableRecord & DatabaseValueConvertible tests 2018-10-28 19:16:55 +01:00
Gwendal Roué 0010be4e56 ValueObservation: row tests 2018-10-28 18:40:21 +01:00
Gwendal Roué 62f6cfe6b5 ValueObservation: count tests 2018-10-28 17:41:18 +01:00
Gwendal Roué 31e6ddeac3 ValueObservation: test scheduling 2018-10-28 17:32:31 +01:00
Gwendal Roué f2c3c213cc Read-only observation is enforced. When not read-only, savepoint is enforced. 2018-10-28 17:04:36 +01:00
Gwendal Roué f303664808 Cleanup 2018-10-28 16:20:57 +01:00
Gwendal Roué 471808fa3b More ValueObseervation tests: fetch, with and without uniquing 2018-10-28 16:13:58 +01:00
Gwendal Roué cbe505f4a4 Cleanup 2018-10-28 16:13:34 +01:00
Gwendal Roué 087989fc89 More ValueObseervation tests: extent 2018-10-28 15:57:27 +01:00
Gwendal Roué a519a4ab86 Documentation 2018-10-28 15:38:01 +01:00
Gwendal Roué 627e8ec969 Fix wrong documentation 2018-10-28 15:35:25 +01:00
Gwendal Roué 2b78479a5e More ValueReducer tests: error 2018-10-28 15:32:55 +01:00
Gwendal Roué e0a9cced4a First tests for ValueObservation: focus on reducers 2018-10-28 13:27:43 +01:00
Gwendal Roué 26ba5768b2 whitespace 2018-10-28 13:26:40 +01:00
Gwendal Roué 09581c6ae0 ValueObservation factory requires a DatabaseRegionConvertible. Introduce AnyDatabaseRegionConvertible. 2018-10-28 11:45:49 +01:00
Gwendal Roué fc3aca792f Replace InitialDispatch with ValueScheduling 2018-10-28 11:28:31 +01:00
Gwendal Roué a043c4c29e QoS are hard 2018-10-27 23:01:24 +02:00
Gwendal Roué ec5451ee70 Cleanup 2018-10-27 17:18:03 +02:00
Gwendal Roué 7c4462641e ValueObservation creation is always done with a factory initializer 2018-10-27 17:16:03 +02:00
Gwendal Roué 82efe7ca23 AnyValueReducer 2018-10-27 17:06:23 +02:00
Gwendal Roué 052d2e3008 Value (string, int, etc.) observation, with uniquing 2018-10-27 16:41:42 +02:00
Gwendal Roué de227bdce1 Bake uniquing right into ValueObservation: introduce ValueReducer 2018-10-27 16:12:42 +02:00
Gwendal Roué 697b2af61d Wrap long lines 2018-10-27 05:11:19 +02:00
Gwendal Roué ff4f6f3b12 Cleanup 2018-10-27 04:59:24 +02:00
Gwendal Roué 31b688d801 ValueObservationn has a QoS 2018-10-27 04:24:17 +02:00
Gwendal Roué f694437f5b Add missing public qualifiers 2018-10-27 04:23:45 +02:00
Gwendal Roué 69853d7901 Now that user implementations of DatabaseWriter are no longer supported...
...stop pretending we have to implement concurrentRead
on top of the deprecated readFromCurrentState.

And this fixes #419 :-)
2018-10-26 16:53:30 +02:00
Gwendal Roué abe6957c85 Typo 2018-10-26 16:42:27 +02:00
Gwendal Roué 08b103f5f5 DatabaseReader and DatabaseWriter are no longer available for user types
- stop testing compatibility with user types
- document that they are no longer available for user types (readme, changelog)
2018-10-26 16:42:14 +02:00
Gwendal Roué 9c71356e3d Honor ValueObservation.readonly 2018-10-26 09:10:26 +02:00
Gwendal Roué 2341523c41 API cleanup 2018-10-26 08:50:59 +02:00
Gwendal Roué 0df4815086 Move ValueObservation support to DatabaseReader 2018-10-25 20:39:04 +02:00
Gwendal Roué fe0f238f32 Cleanup 2018-10-25 08:49:57 +02:00
Gwendal Roué fda04a105d ValueObservation: extract callbacks 2018-10-25 08:39:52 +02:00
Gwendal Roué e5d97c15ad Looking for a good API 2018-10-25 08:05:55 +02:00
Gwendal Roué ce95ff7278 Move towards observation from reader 2018-10-24 19:17:11 +02:00
Gwendal Roué 33927e7f4d FetchResultsObserver 2018-10-23 13:24:46 +02:00
Gwendal Roué 6a4d9fb8fc Merge pull request #431 from KyleLeneau/codeable-json-sync-playground
Working on a Codable JSON sync example
2018-10-17 19:14:49 +02:00
Kyle LeNeau cf33d78f49 Working on a Codable JSON sync example 2018-10-14 12:49:37 -07:00
Gwendal Roué 0d89aa911b Documentation 2018-10-09 08:35:17 +02:00
Gwendal Roué d521a99d87 Typo fix 2018-10-09 08:10:56 +02:00
Gwendal Roué a848d864ce Documentation 2018-10-08 21:59:04 +02:00
Gwendal Roué 759c1088a1 v3.4.0 2018-10-08 21:37:58 +02:00
Gwendal Roué 2d004a1a26 Merge branch 'development' 2018-10-08 21:22:10 +02:00
Gwendal Roué 35e1de495e Merge pull request #428 from groue/feature/SQLite-3.25.2
Upgrade custom SQLite builds to version 3.25.2
2018-10-08 21:19:51 +02:00
Gwendal Roué 697709c82f thank you note 2018-10-08 19:19:45 +02:00
Gwendal Roué 9ad476235d CHANGELOG 2018-10-08 19:17:02 +02:00
Gwendal Roué dadc5c3c58 Fix a test for syntax error that fails with SQLite 3.25.2 2018-10-08 19:16:54 +02:00
Gwendal Roué 3be3a51cdc Fix a compiler warning 2018-10-08 19:13:12 +02:00
Gwendal Roué 7bdbfb77dd Upgrade SQLite version in documentation 2018-10-08 19:11:24 +02:00
Gwendal Roué 8e0c01ef70 SQLite 3.25.2 2018-10-08 19:03:41 +02:00
Gwendal Roué 1c5cecf568 Merge pull request #423 from groue/feature/annotation
Association Aggregates
2018-10-08 13:59:14 +02:00
Gwendal Roué 9330468f92 Documentation 2018-10-08 09:10:48 +02:00
Gwendal Roué fcbea047cc Documentation 2018-10-08 09:08:37 +02:00
Gwendal Roué 619b73ea76 Documentation 2018-10-08 09:04:14 +02:00
Gwendal Roué 597d745e37 Documentation 2018-10-08 09:02:53 +02:00
Gwendal Roué 52ffb4a02c Documentation 2018-10-08 08:59:56 +02:00
Gwendal Roué c007c04afb Documentation 2018-10-08 08:58:21 +02:00
Gwendal Roué 4b92968912 Documentation 2018-10-08 08:56:36 +02:00
Gwendal Roué 2938a95270 Inline documentation 2018-10-08 08:24:14 +02:00
Gwendal Roué 5b2e9cdaa5 Fix link 2018-10-07 20:01:39 +02:00
Gwendal Roué 5736cd2740 CHANGELOG 2018-10-07 19:59:35 +02:00
Gwendal Roué 6b05617d8d Documentation 2018-10-07 19:10:37 +02:00
Gwendal Roué 58470fa959 Documentation 2018-10-07 18:50:50 +02:00
Gwendal Roué 43c04268ee Documentation 2018-10-07 18:47:21 +02:00
Gwendal Roué 3ba8d7ae60 Documentation 2018-10-07 18:45:17 +02:00
Gwendal Roué 97c22cde40 Documentation 2018-10-07 18:26:10 +02:00
Gwendal Roué 8a983274af Documentation 2018-10-07 18:25:33 +02:00
Gwendal Roué 445ec18d6e Documentation 2018-10-07 18:20:22 +02:00
Gwendal Roué a441b1d24d Documentation 2018-10-07 18:18:51 +02:00
Gwendal Roué 23743680d2 Documentation 2018-10-07 18:11:52 +02:00
Gwendal Roué afaabfe872 Documentation 2018-10-07 18:09:53 +02:00
Gwendal Roué 53114ea491 Documentation 2018-10-07 18:05:41 +02:00
Gwendal Roué 12745b2882 Documentation 2018-10-07 18:03:38 +02:00
Gwendal Roué 19291e2501 Documentation 2018-10-07 17:55:49 +02:00
Gwendal Roué 3890d2659f Documentation 2018-10-07 17:51:51 +02:00
Gwendal Roué 68a8592bcd Documentation 2018-10-07 17:42:55 +02:00
Gwendal Roué 445187c276 Documentation 2018-10-07 17:37:55 +02:00
Gwendal Roué 55707e67d4 Documentation 2018-10-07 17:31:58 +02:00
Gwendal Roué 82435db722 Documentation 2018-10-07 17:29:59 +02:00
Gwendal Roué a47a0c9d2d Typo 2018-10-07 17:17:41 +02:00
Gwendal Roué 5a24726cf1 Documentation 2018-10-07 17:08:24 +02:00
Gwendal Roué 7ecacaaccc Documentation 2018-10-07 16:34:49 +02:00
Gwendal Roué 704da35576 aliased(CodingKey), annotated(with: aggregate, ...), count and isEmpty are now properties 2018-10-07 16:20:13 +02:00
Gwendal Roué 2774aaf292 aggregate alias cleanup 2018-10-07 15:40:38 +02:00
Gwendal Roué 8ffeb28b02 Tests for association aggregate operators 2018-10-07 15:20:24 +02:00
Gwendal Roué 5f92209c59 AssociationAggregates: logic, arithmetic, and comparison operators 2018-10-07 12:22:48 +02:00
Gwendal Roué 4f8e97a07c AssociationAggregate is now generic on its anchor type only 2018-10-07 12:08:25 +02:00
Gwendal Roué 39bc140dc8 Rename Annotation to AssociationAggregate 2018-10-07 11:39:46 +02:00
Gwendal Roué 0838d5903e Documentation 2018-10-06 15:46:47 +02:00
Gwendal Roué a0cd603c61 Nicer SQL generation for isEmpty annotation 2018-10-06 14:50:08 +02:00
Gwendal Roué 3ef8083043 testAnnotationWithJoiningMethodAndTableAliasAndSQLSnippet 2018-10-06 14:29:48 +02:00
Gwendal Roué 35ed13c940 Test for annotations in HAVING clauses 2018-10-06 14:15:35 +02:00
Gwendal Roué 1da41c7fe5 TODO 2018-10-05 18:50:34 +02:00
Gwendal Roué 01069ee998 fix typo 2018-10-05 18:50:34 +02:00
Gwendal Roué ebbf858da4 Documentation 2018-10-05 18:50:34 +02:00
Gwendal Roué 047a95f2c9 Improve sample code 2018-10-05 18:50:34 +02:00
Gwendal Roué 7508811e40 Fix typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 2ae8e236c0 Aggregates are no longer a missing association feature :-) 2018-10-05 18:50:34 +02:00
Gwendal Roué a13903e7a1 Documentation 2018-10-05 18:50:34 +02:00
Gwendal Roué c25bc1d5fa Documentation 2018-10-05 18:50:34 +02:00
Gwendal Roué d004372b63 More cleanup 2018-10-05 18:50:34 +02:00
Gwendal Roué 789248e369 minor 2018-10-05 18:50:34 +02:00
Gwendal Roué 3404cc574b CHANGELOG 2018-10-05 18:50:34 +02:00
Gwendal Roué 2ca049c2e4 Cleanup 2018-10-05 18:50:34 +02:00
Gwendal Roué 89054c8165 typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 24e8ee2d00 Stabilize annotation aliases, and allow aggregate any expression 2018-10-05 18:50:34 +02:00
Gwendal Roué f69c79bc1a typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 82765aba1d typo 2018-10-05 18:50:34 +02:00
Gwendal Roué bcc177ff7d typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 3bfef630f9 typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 6a6d58da6c typo 2018-10-05 18:50:34 +02:00
Gwendal Roué 6e7065de36 Annotation documentation 2018-10-05 18:50:34 +02:00
Gwendal Roué f60152ed2e Add Inflections.swift to GRDBWatchOS 2018-10-05 18:50:34 +02:00
Gwendal Roué f6b0c0cc65 Rename test 2018-10-05 18:50:34 +02:00
Gwendal Roué c16b2bcb57 The count annotation has to be distinct 2018-10-05 18:50:34 +02:00
Gwendal Roué 5d70ef93c8 Test that filter(key:), orderByPrimaryKey(), and groupByPrimaryKey() capture the table name 2018-10-05 18:50:34 +02:00
Gwendal Roué 68d76eca01 Annotations: avg, min, max, sum 2018-10-05 18:50:33 +02:00
Gwendal Roué 83453e1b11 Make private a test helper class 2018-10-05 18:50:33 +02:00
Gwendal Roué 903694d095 First annotation: HasManyAssociaton.count 2018-10-05 18:50:33 +02:00
Gwendal Roué 168d2850ab Introduce groupByPrimaryKey() 2018-10-05 18:50:33 +02:00
Gwendal Roué fc692bdb8a Merge pull request #427 from groue/feature/cursor-reset
Have cursors reset SQLite statements in deinit
2018-10-05 12:23:08 +02:00
Gwendal Roué d963e688be CHANGELOG 2018-10-05 08:24:34 +02:00
Gwendal Roué 6157ab0583 Have cursors reset their statement when they are deinitialized
This is the real fix for #424. GRDB used to keep unfinished SQLite statements around. Now cursors properly reset their statement when they are done. We no longer have to clear the statement cache before a backup.
2018-10-05 08:13:23 +02:00
Gwendal Roué ad61c72988 Remove two invalid tests that use cursor outside of their protected dispatch queue 2018-10-05 08:04:37 +02:00
Gwendal Roué dd4b651938 Merge pull request #425 from groue/feature/robust-backup
Fix "destination database is in use " error during database backup
2018-10-04 15:59:43 +02:00
Gwendal Roué 7cd50872cf Merge branch 'master' into development 2018-10-04 13:40:43 +02:00
Gwendal Roué fc5e92954b SQLCipher, too, can't erase a database if there are cached prepared statements. 2018-10-04 13:34:35 +02:00
Gwendal Roué 6c7ac25fb8 Remove Carthage from suggested contributions (#408 and #262 have helped a lot) 2018-10-04 13:20:51 +02:00
Gwendal Roué 86cff20f99 New suggested contribution: "Records: Splitting Database Encoding from Ability to Write in the Database" 2018-10-04 13:14:29 +02:00
Gwendal Roué 7a628bf23f Add minimal failing test for #424 2018-10-04 08:35:02 +02:00
Gwendal Roué 9e8d08f579 CHANGELOG 2018-10-04 07:59:50 +02:00
Gwendal Roué 8c3606fe4b Fix failing test for #424 2018-10-04 07:58:36 +02:00
Gwendal Roué 01c9e9e1e1 Failing test for #424 2018-10-03 13:55:55 +02:00
Gwendal Roué ff28c02f21 Merge branch 'master' into development 2018-10-03 13:00:02 +02:00
Gwendal Roué 1426c7fd38 New suggested contribution: Custom FTS5 Auxiliary Functions 2018-10-03 12:57:21 +02:00
Gwendal Roué 366460bc62 Merge pull request #422 from groue/feature/AssociationMerge
Refining Association Requests
2018-09-30 16:39:33 +02:00
Gwendal Roué 16c62999fa More merging tests (and fix a bug with ordering) 2018-09-30 15:10:54 +02:00
Gwendal Roué 2cd3a7e0c9 High-level test for association request refining
Here we test the sample code in AssociationBasics.md
2018-09-30 14:51:52 +02:00
Gwendal Roué 9958e7b96c Documentation and cleanup 2018-09-30 13:57:31 +02:00
Gwendal Roué 8319c70315 CHANGELOG 2018-09-30 13:32:44 +02:00
Gwendal Roué 45ff5f2fa1 One less known issue with associations :-) 2018-09-30 13:23:35 +02:00
Gwendal Roué df51d2887a Documentation tweaks 2018-09-30 13:22:05 +02:00
Gwendal Roué 9c37237f7b New "Refining Association Requests" documentation chapter 2018-09-30 13:16:57 +02:00
Gwendal Roué 6ecb7a40d0 associations are not merged when they don't have the same key 2018-09-30 06:48:20 +02:00
Gwendal Roué 52ec6c6cd2 Merge associations: 2018-09-30 06:35:15 +02:00
Gwendal Roué ba11d7be66 Merge associations: SQL tests 2018-09-30 05:46:44 +02:00
Gwendal Roué 4c58fd5111 Merge associations: scope tests WIP 2018-09-29 20:28:28 +02:00
Gwendal Roué 4bde81db4f Merge associations: scope tests WIP 2018-09-29 15:18:53 +02:00
Gwendal Roué 37a9999b35 Merge associations: including wins over joining 2018-09-29 14:37:53 +02:00
Gwendal Roué 33b40637a8 Merge associations 2018-09-29 14:16:56 +02:00
Gwendal Roué e7fd075936 Early detection of association key conflict 2018-09-29 12:40:11 +02:00
Gwendal Roué cc4a9fa2e2 Demo screenshot fixes 2018-09-23 15:48:41 +02:00
Gwendal Roué 56f3bdc390 Demo screenshot fixes 2018-09-23 15:48:08 +02:00
Gwendal Roué ba5537692f Demo screenshot fixes 2018-09-23 15:47:18 +02:00
Gwendal Roué 5595046341 Fix documentation 2018-09-23 12:39:21 +02:00
Gwendal Roué ad844f6ba5 Merge branch 'development' 2018-09-23 10:41:13 +02:00
Gwendal Roué baf8dbc881 v3.3.1 2018-09-23 10:39:55 +02:00
Gwendal Roué ad672395de Fix screenshot 2018-09-23 10:18:28 +02:00
Gwendal Roué 923fab769f final tweaks 2018-09-23 09:59:29 +02:00
Gwendal Roué 4e3dc03422 inner links 2018-09-23 07:09:37 +02:00
Gwendal Roué d96212ca59 CHANGELOG 2018-09-22 20:46:13 +02:00
Gwendal Roué d16022a33a README 2018-09-22 20:38:27 +02:00
Gwendal Roué 5cb22125aa README 2018-09-22 20:35:14 +02:00
Gwendal Roué 6ee77df2dd Layout 2018-09-22 20:31:03 +02:00
Gwendal Roué ea54b06e28 Layout 2018-09-22 20:30:27 +02:00
Gwendal Roué 6b33c08b26 Demo app README 2018-09-22 15:01:22 +02:00
Gwendal Roué cb16bf549f Demo app README 2018-09-22 14:57:22 +02:00
Gwendal Roué 9a8b60a8a7 PlayerEditionViewController saves in the database 2018-09-22 14:55:32 +02:00
Gwendal Roué dec965d610 Demo app README 2018-09-22 14:06:00 +02:00
Gwendal Roué adf3e65971 Demo app README 2018-09-22 14:01:45 +02:00
Gwendal Roué c437e4a2ef Demo app README 2018-09-22 13:47:38 +02:00
Gwendal Roué 4dd9d2e1fe Demo app README.md 2018-09-22 13:46:37 +02:00
Gwendal Roué 185c3cbbf9 Update documentation inner links 2018-09-22 13:41:46 +02:00
Gwendal Roué ffbf4d2c87 Layout 2018-09-22 13:34:41 +02:00
Gwendal Roué 464cd0db7d Layout 2018-09-22 13:32:53 +02:00
Gwendal Roué e2e00f9b40 Layout 2018-09-22 13:30:16 +02:00
Gwendal Roué 2c2c75b0f4 Layout 2018-09-22 13:29:47 +02:00
Gwendal Roué 8ef7547c8e Promote demo app in main README.md 2018-09-22 13:21:11 +02:00
Gwendal Roué d82daaa398 CHANGELOG 2018-09-22 13:00:34 +02:00
Gwendal Roué a5a8b2ac40 Fix failing test for custom FTS5 tokenizer in DatabasePool
Tokenizer are now added to new reader connections.
2018-09-22 13:00:34 +02:00
Gwendal Roué bdcbee37f4 Failing test for custom FTS5 tokenizer in DatabasePool 2018-09-22 13:00:34 +02:00
Gwendal Roué 70508f5daa Split long line 2018-09-22 12:59:50 +02:00
Gwendal Roué 3c44180c47 PlayerEditionViewController UI tweaks 2018-09-22 12:54:25 +02:00
Gwendal Roué 3d179acc00 Demo app code cleanup
- Make Player columns private
- Simplify view controllers relationships
2018-09-22 12:32:55 +02:00
Gwendal Roué dd9ca2317c More SQL generation ideas 2018-09-20 08:22:34 +02:00
128 changed files with 13809 additions and 1440 deletions

No files matched your search

+4 -9
View File
@@ -1,18 +1,13 @@
<!-- Please describe your pull request here. -->
### One more thing…
### Pull Request Checklist
<!--
When relevant, please check as many checkboxes in this list as possible.
Documentation makes sure that you are not the only one who knows about the changes. Tests make sure your changes will be supported in the future.
Write documentation and tests if you can, because if nobody else has the time to do it, the pull request will simply be rejected.
Ask for help and guidance when needed.
Please verify that your pull request checks those boxes:
-->
- [ ] This pull request is submitted against the `development` branch.
- [ ] Inline documentation has been updated.
- [ ] README.md or another dedicated guide has been updated.
- [ ] Changes are tested, for all flavors of GRDB, GRDBCipher, and GRDBCustomSQLite.
- [ ] Updated CHANGELOG.md
- [ ] CHANGELOG.md has been updated.
+388 -4
View File
@@ -1,6 +1,390 @@
Release Notes
=============
All notable changes to this project will be documented in this file.
GRDB adheres to [Semantic Versioning](https://semver.org/).
#### 3.x Releases
- `3.6.x` Releases - [3.6.0](#360) | [3.6.1](#361) | [3.6.2](#362)
- `3.5.x` Releases - [3.5.0](#350)
- `3.4.x` Releases - [3.4.0](#340)
- `3.3.x` Releases - [3.3.0](#330) | [3.3.1](#331)
- `3.3.0` Betas - [3.3.0-beta1](#330-beta1)
- `3.2.x` Releases - [3.2.0](#320)
- `3.1.x` Releases - [3.1.0](#310)
- `3.0.x` Releases - [3.0.0](#300)
#### 2.x Releases
- `2.10.x` Releases - [2.10.0](#2100)
- `2.9.x` Releases - [2.9.0](#290)
- `2.8.x` Releases - [2.8.0](#280)
- `2.7.x` Releases - [2.7.0](#270)
- `2.6.x` Releases - [2.6.0](#260) | [2.6.1](#261)
- `2.5.x` Releases - [2.5.0](#250)
- `2.4.x` Releases - [2.4.0](#240) | [2.4.1](#241) | [2.4.2](#242)
- `2.3.x` Releases - [2.3.0](#230) | [2.3.1](#231)
- `2.2.x` Releases - [2.2.0](#220)
- `2.1.x` Releases - [2.1.0](#210)
- `2.0.x` Releases - [2.0.0](#200) | [2.0.1](#201) | [2.0.2](#202) | [2.0.3](#203)
#### 1.x Releases
- `1.3.x` Releases - [1.3.0](#130)
- `1.2.x` Releases - [1.2.0](#120) | [1.2.1](#121) | [1.2.2](#122)
- `1.1.x` Releases - [1.1.0](#110)
- `1.0.x` Releases - [1.0.0](#100)
#### 0.x Releases
- [0.110.0](#01100), ...
### 3.6.2
Released January 5, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.6.1...v3.6.2)
### Fixed
- [#464](https://github.com/groue/GRDB.swift/pull/464): Make updateChanges(_:with:) available to PersistableRecord structs
## 3.6.1
Released December 9, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.6.0...v3.6.1)
### Fixed
- [#458](https://github.com/groue/GRDB.swift/pull/458): Fix ValueObservation duration - code & doc
## 3.6.0
Released December 7, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.5.0...v3.6.0)
This release comes with:
- A nice sugar for updating records (my personal favorite of this release):
```swift
// Does not hit the database if player is not modified
try player.update(db) {
$0.score = 1000
$0.hasAward = true
}
```
- Enhanced [ValueObservation](README.md#valueobservation), with methods such as `compactMap`, `combine`, ...
- Observation of specific transactions, with the new [DatabaseRegionObservation](README.md#databaseregionobservation).
- Various other improvements listed below.
### Fixed
- [#449](https://github.com/groue/GRDB.swift/pull/449): Fix JSON encoding of empty containers
### New
- [#442](https://github.com/groue/GRDB.swift/pull/442): Reindex
- [#443](https://github.com/groue/GRDB.swift/pull/443): In place record update
- [#445](https://github.com/groue/GRDB.swift/pull/445): Quality of service and target dispatch queue
- [#446](https://github.com/groue/GRDB.swift/pull/446): ValueObservation: delayed reducer creation
- [#444](https://github.com/groue/GRDB.swift/pull/444): Combine Value Observations
- [#451](https://github.com/groue/GRDB.swift/pull/451): ValueObservation.compactMap
- [#452](https://github.com/groue/GRDB.swift/pull/452): ValueObservation.mapReducer
- [#454](https://github.com/groue/GRDB.swift/pull/454): ValueObservation.distinctUntilChanged
- [#455](https://github.com/groue/GRDB.swift/pull/455): DatabaseRegionObservation
- ValueObservation methods which used to accept a variadic list of observed regions now also accept an array.
- ValueReducer, the protocol that fuels ValueObservation, is flagged [**:fire: EXPERIMENTAL**](README.md#what-are-experimental-features). It will remain so until more experience has been acquired.
### Documentation Diff
- [Record Comparison](README.md#record-comparison): this chapter has been updated for the new `updateChanges(_:with:)` method.
- [ValueObservation](README.md#valueobservation): this chapter has been updated for the new `ValueObservation.combine`, `ValueObservation.compactMap`, and `Value.distinctUntilChanged` methods.
- [DatabaseRegionObservation](README.md#databaseregionobservation): this chapter describes the new `DatabaseRegionObservation` type.
### API diff
```diff
extension Database {
+ func reindex(collation: Database.CollationName) throws
+ func reindex(collation: DatabaseCollation) throws
}
extension MutablePersistableRecord {
+ mutating func updateChanges(_ db: Database, with change: (inout Self) throws -> Void) throws -> Bool
}
extension PersistableRecord {
+ func updateChanges(_ db: Database, with change: (Self) throws -> Void) throws -> Bool
}
struct ValueObservation<Reducer> {
+ static func tracking(
+ _ regions: [DatabaseRegionConvertible],
+ reducer: @escaping (Database) throws -> Reducer)
+ -> ValueObservation
}
+extension ValueObservation where Reducer == Void {
+ static func tracking<Value>(
+ _ regions: [DatabaseRegionConvertible],
+ fetch: @escaping (Database) throws -> Value)
+ -> ValueObservation<ValueReducers.Raw<Value>>
+ static func combine<R1: ValueReducer, ...>(_ o1: ValueObservation<R1>, ...)
+ -> ValueObservation<...>
+}
+extension ValueObservation where Reducer: ValueReducer {
+ func compactMap<T>(_ transform: @escaping (Reducer.Value) -> T?)
+ -> ValueObservation<CompactMapValueReducer<Reducer, T>>
+}
+ extension ValueObservation where Reducer: ValueReducer, Reducer.Value: Equatable {
+ public func distinctUntilChanged()
+ -> ValueObservation<DistinctUntilChangedValueReducer<Reducer>>
+ }
+extension ValueObservation {
+ func mapReducer<R>(_ transform: @escaping (Database, Reducer) throws -> R)
+ -> ValueObservation<R>
+}
struct Configuration {
+ var qos: DispatchQoS
+ var targetQueue: DispatchQueue?
}
+struct DatabaseRegionObservation {
+ var extent: Database.TransactionObservationExtent
+ init(tracking regions: DatabaseRegionConvertible...)
+ init(tracking regions: [DatabaseRegionConvertible])
+ func start(in dbWriter: DatabaseWriter, onChange: @escaping (Database) -> Void) throws -> TransactionObserver
+}
```
## 3.5.0
Released November 2, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.4.0...v3.5.0)
This release comes with **[ValueObservation](README.md#valueobservation)**, a new type which tracks the results of database requests, and notifies fresh values whenever the database changes:
```swift
let observer = ValueObversation
.trackingOne(Player.filter(key: 42))
.start(in: dbQueue) { player: Player? in
print("Player has changed")
}
```
ValueObservation also aims at providing support for third-party code that needs to react to database changes. For example, [RxSwiftCommunity/RxGRDB#46](https://github.com/RxSwiftCommunity/RxGRDB/pull/46) is the pull request which implements RxGRDB, the companion library based on [RxSwift](https://github.com/ReactiveX/RxSwift), on top of ValueObservation.
### New
- [#435](https://github.com/groue/GRDB.swift/pull/435): Improved support for values observation
- It is now possible to observe database change from a [DatabaseReader](https://groue.github.io/GRDB.swift/docs/3.5/Protocols/DatabaseReader.html).
### Breaking Change
It used to be possible to define custom types that adopt the [DatabaseReader and DatabaseWriter protocols](README.md#databasewriter-and-databasereader-protocols), with a major drawback: it was impossible to add concurrency-related APIs to GRDB without breaking user code. Now all types that adopt those protocols are defined by GRDB: DatabaseQueue, DatabasePool, DatabaseSnapshot, AnyDatabaseReader, and AnyDatabaseWriter. **Expanding this set is no longer supported.**
### Documentation Diff
- [ValueObservation](README.md#valueobservation): this new chapter describes the new way to observe database values.
### API diff
```diff
protocol DatabaseReader: class {
+ func add<Reducer: ValueReducer>(
+ observation: ValueObservation<Reducer>,
+ onError: ((Error) -> Void)?,
+ onChange: @escaping (Reducer.Value) -> Void)
+ throws -> TransactionObserver
+ func remove(transactionObserver: TransactionObserver)
}
protocol DatabaseWriter: DatabaseReader {
- func remove(transactionObserver: TransactionObserver)
}
+protocol DatabaseRegionConvertible {
+ func databaseRegion(_ db: Database) throws -> DatabaseRegion
+}
+
+extension DatabaseRegion: DatabaseRegionConvertible { }
+
+struct AnyDatabaseRegionConvertible: DatabaseRegionConvertible {
+ init(_ region: @escaping (Database) throws -> DatabaseRegion)
+ init(_ region: DatabaseRegionConvertible)
+}
-protocol FetchRequest { ... }
+protocol FetchRequest: DatabaseRegionConvertible { ... }
+enum ValueScheduling {
+ case mainQueue
+ case onQueue(DispatchQueue, startImmediately: Bool)
+ case unsafe(startImmediately: Bool)
+}
+protocol ValueReducer {
+ associatedtype Fetched
+ associatedtype Value
+ func fetch(_ db: Database) throws -> Fetched
+ mutating func value(_ fetched: Fetched) -> Value?
+}
+
+extension ValueReducer {
+ func map<T>(_ transform: @escaping (Value) -> T?) -> MapValueReducer<Self, T>
+}
+
+struct AnyValueReducer<Fetched, Value>: ValueReducer {
+ init(fetch: @escaping (Database) throws -> Fetched, value: @escaping (Fetched) -> Value?)
+ init<Reducer: ValueReducer>(_ reducer: Reducer) where Reducer.Fetched == Fetched, Reducer.Value == Value
+}
+struct ValueObservation<Reducer> {
+ var extent: Database.TransactionObservationExtent
+ var requiresWriteAccess: Bool
+ var scheduling: ValueScheduling
+ static func tracking(_ regions: DatabaseRegionConvertible..., reducer: Reducer) -> ValueObservation
+}
+
+extension ValueObservation where Reducer: ValueReducer {
+ func map<T>(_ transform: @escaping (Reducer.Value) -> T)
+ -> ValueObservation<MapValueReducer<Reducer, T>>
+ func start(
+ in reader: DatabaseReader,
+ onError: ((Error) -> Void)? = nil,
+ onChange: @escaping (Reducer.Value) -> Void) throws -> TransactionObserver
+}
+
+extension ValueObservation where Reducer == Void {
+ static func tracking<Value>(
+ _ regions: DatabaseRegionConvertible...,
+ fetch: @escaping (Database) throws -> Value)
+ -> ValueObservation<ValueReducers.Raw<Value>>
+
+ static func tracking<Value>(
+ _ regions: DatabaseRegionConvertible...,
+ fetchDistinct: @escaping (Database) throws -> Value)
+ -> ValueObservation<ValueReducers.Distinct<Value>>
+ where Value: Equatable
+
+ static func trackingCount<Request: FetchRequest>(_ request: Request)
+ -> ValueObservation<ValueReducers.Raw<Int>>
+ static func trackingAll<Request: FetchRequest>(_ request: Request)
+ -> ValueObservation<ValueReducers.Raw<[Request.RowDecoder]>>
+ static func trackingOne<Request: FetchRequest>(_ request: Request)
+ -> ValueObservation<ValueReducers.Raw<Request.RowDecoder?>>
+}
```
## 3.4.0
Released October 8, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.3.1...v3.4.0)
This release comes with **Association Aggregates**. They let you compute values out of collections of associated records, such as their count, or the maximum value of an associated record column.
### Fixed
- [#425](https://github.com/groue/GRDB.swift/pull/425): Fix "destination database is in use " error during database backup
- [#427](https://github.com/groue/GRDB.swift/pull/427): Have cursors reset SQLite statements in deinit
### New
- [#422](https://github.com/groue/GRDB.swift/pull/422): Refining Association Requests
- [#423](https://github.com/groue/GRDB.swift/pull/423): Association Aggregates
- [#428](https://github.com/groue/GRDB.swift/pull/428): Upgrade custom SQLite builds to version 3.25.2 (thanks to [@swiftlyfalling](https://github.com/swiftlyfalling/SQLiteLib))
### Documentation Diff
- [Refining Association Requests](Documentation/AssociationsBasics.md#refining-association-requests): this new chapter describes how you can craft complex associated requests in a modular way.
- [Association Aggregates](Documentation/AssociationsBasics.md#association-aggregates): this chapter describes the main new feature of this release.
### API diff
```diff
protocol AggregatingRequest {
- func group(_ expressions: [SQLExpressible]) -> Self
+ func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
}
+extension AggregatingRequest {
+ func group(_ expressions: [SQLExpressible]) -> Self
+}
+extension TableRequest where Self: AggregatingRequest {
+ func groupByPrimaryKey() -> Self {
+}
+struct AssociationAggregate<RowDecoder> {
+ func aliased(_ name: String) -> AssociationAggregate<RowDecoder>
+ func aliased(_ key: CodingKey) -> AssociationAggregate<RowDecoder>
+}
+extension HasManyAssociation where Origin: TableRecord, Destination: TableRecord {
+ var count: AssociationAggregate<Origin>
+ var isEmpty: AssociationAggregate<Origin>
+ func average(_ expression: SQLExpressible) -> AssociationAggregate<Origin>
+ func max(_ expression: SQLExpressible) -> AssociationAggregate<Origin>
+ func min(_ expression: SQLExpressible) -> AssociationAggregate<Origin>
+ func sum(_ expression: SQLExpressible) -> AssociationAggregate<Origin>
+}
+extension QueryInterfaceRequest {
+ func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<RowDecoder>
+}
+extension QueryInterfaceRequest where RowDecoder: TableRecord {
+ func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> QueryInterfaceRequest<RowDecoder>
+ func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> QueryInterfaceRequest<RowDecoder>
+ func having(_ aggregate: AssociationAggregate<RowDecoder>) -> QueryInterfaceRequest<RowDecoder>
+}
+extension TableRecord {
+ static func annotated(with aggregates: AssociationAggregate<Self>...) -> QueryInterfaceRequest<Self>
+ static func annotated(with aggregates: [AssociationAggregate<Self>]) -> QueryInterfaceRequest<Self>
+ static func having(_ aggregate: AssociationAggregate<Self>) -> QueryInterfaceRequest<Self>
+}
+extension SQLSpecificExpressible {
+ func aliased(_ key: CodingKey) -> SQLSelectable
+}
```
## 3.3.1
Released September 23, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.3.0...v3.3.1)
### Fixed
- [#414](https://github.com/groue/GRDB.swift/pull/414): Fix database pool use of FTS5 tokenizers
### Documentation Diff
- Enhanced visibility of the [Demo Application](DemoApps/GRDBDemoiOS)
## 3.3.0
Released September 16, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v3.3.0-beta1...v3.3.0)
@@ -1094,7 +1478,7 @@ Released July 19, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare
It used to generate `= NULL` which would not behave as expected.
## 1.2
## 1.2.0
Released July 13, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v1.1...v1.2)
@@ -1193,7 +1577,7 @@ Released July 13, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare
```
## 1.1
## 1.1.0
Released July 1, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v1.0...v1.1)
@@ -1255,9 +1639,9 @@ Released July 1, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare/
```
## 1.0 :tada:
## 1.0.0
Released June 20, 2017
Released June 20, 2017 :tada:
**GRDB 1.0 comes with enhancements, and API stability.**
+41 -24
View File
@@ -72,10 +72,9 @@ Legend:
The ideas, in alphabetical order:
- [Associations]
- [Carthage]
- [CloudKit]
- [Concurrency]
- [Database Observation]
- [Custom FTS5 Auxiliary Functions]
- [Date and Time Functions]
- [Decode NSDecimalNumber from Text Columns]
- [Documentation]
@@ -86,6 +85,8 @@ The ideas, in alphabetical order:
- [JSON]
- [Linux]
- [More SQL Generation]
- [Reactive Database Observation]
- [Records: Splitting Database Encoding from Ability to Write in the Database]
- [SQL Console in the Debugger]
- [SQLCipher in a Shared App Container]
- [Static Library]
@@ -99,15 +100,6 @@ The ideas, in alphabetical order:
Associations can be enhanced in several ways. See the "Known Issues" and "Future Directions" chapter of the [Associations Guide](Documentation/AssociationsBasics.md)
### Carthage
:question: Unknown Difficulty
[Carthage](https://github.com/Carthage/Carthage) can build GRDB frameworks, but it can also inexplicably fail. This installation method is thus currently **unsupported**, which means that support has to be found directly in the [Carthage repo](https://github.com/Carthage/Carthage/issues), or on [Stack Overflow](http://stackoverflow.com). See [#262](https://github.com/groue/GRDB.swift/pull/262) for more information.
I would be a nice improvement if GRDB Carthage builds were made robust.
### CloudKit
:bowtie: Public API Challenge :question: Unknown Difficulty :fire: Experimental
@@ -155,22 +147,17 @@ And this creates improvement opportunities:
- The introduction of an "ultra-safe" concurrency mode. Maybe something that restricts all database accesses to the main thread, like [FCModel](https://github.com/marcoarment/FCModel). Maybe in a separate companion library.
### Database Observation
### Custom FTS5 Auxiliary Functions
:muscle: Hard
:question: Unknown Difficulty
[Database Observation](README#database-changes-observation) is currently available in three flavors:
The SQLite documentation provides [this description](https://www.sqlite.org/fts5.html) of FTS5 auxiliary functions:
- The [TransactionObserver](README.md#transactionobserver-protocol) protocol: versatile, but low-level and challenging in terms of concurrency, especially when used in conjunction with database pools.
> An application may use FTS5 auxiliary functions to retrieve extra information regarding the matched row. For example, an auxiliary function may be used to retrieve a copy of a column value for a matched row with all instances of the matched term surrounded by html <b></b> tags.
- [FetchedRecordsController]: high-level and easier to use.
Applications can define their own [custom FTS5 auxiliary functions](https://www.sqlite.org/fts5.html#custom_auxiliary_functions) with SQLite, but GRDB does not yet provide any Swift API for that.
- [RxGRDB]: high-level and easier to use, depends on [RxSwift](https://github.com/ReactiveX/RxSwift).
Suggested contributions are:
- Enhancements to FetchedRecordsController (see below).
- More choices of reactive engines.
See issue [#421](https://github.com/groue/GRDB.swift/issues/421) for more information.
### Date and Time Functions
@@ -252,7 +239,7 @@ let stringRequest = Player.select(Column("name"), as: String.self)
let rowRequest = SQLRequest<Row>("SELECT ...")
```
This limitation does not apply to [RxGRDB], the reactive sibling of FetchedRecordsController. It would be nice if FetchedRecordsController would become just as versatile.
This limitation does not apply to [ValueObservation] and [RxGRDB]. It would be nice if FetchedRecordsController would become just as versatile.
### FetchedRecordsController Support for Sections
@@ -297,14 +284,38 @@ Swift on Linux is currently focused on the server (Vapor, Perfect, Kitura). Whil
There are several SQLite features that GRDB could natively support:
- [ALTER TABLE ... RENAME COLUMN ... TO ...](https://www.sqlite.org/lang_altertable.html)
- [ATTACH DATABASE](https://www.sqlite.org/lang_attach.html)
- [UPSERT](https://www.sqlite.org/lang_UPSERT.html)
- [INSERT INTO ... SELECT ...](https://www.sqlite.org/lang_insert.html)
- [WITH RECURSIVE ...](https://www.sqlite.org/lang_with.html)
- [RTree](https://sqlite.org/rtree.html)
- [Windows Functions](https://www.sqlite.org/windowfunctions.html)
- [More ideas](https://www.sqlite.org/lang.html)
### Reactive Database Observation
:baby: Starter Task
We already have the [RxGRDB] companion library, which offers [RxSwift](https://github.com/ReactiveX/RxSwift) bindings.
We need more choices of reactive engines.
### Records: Splitting Database Encoding from Ability to Write in the Database
:baby: Starter Task :pencil: Documentation
Record types that know how to encode themselves in the database (converting themselves into columns and database values) currently are granted with [persistence methods] which can write in the database. Those record types all adopt the [PersistableRecord] protocol.
But encoding a record grants other features, such as [Record Comparison], or [Requesting Associated Records].
This is a problem: one should not have to grant a type with persistence methods, when one just needs read-only features.
The fix is to split database encoding from persistence methods. See [#426](https://github.com/groue/GRDB.swift/issues/426) for more information.
### SQL Console in the Debugger
:question: Unknown Difficulty :hammer: Tooling
@@ -362,9 +373,9 @@ Features that blur this focus are non-goals:
[Ask Questions]: #ask-questions
[Associations]: #associations
[Carthage]: #carthage
[CloudKit]: #cloudkit
[Codable Records]: README.md#codable-records
[Custom FTS5 Auxiliary Functions]: #custom-fts5-auxiliary-functions
[Database Observation]: #database-observation
[Date and Time Functions]: #date-and-time-functions
[Decode NSDecimalNumber from Text Columns]: #decode-nsdecimalnumber-from-text-columns
@@ -379,6 +390,7 @@ Features that blur this focus are non-goals:
[JSON]: #json
[Linux]: #linux
[More SQL Generation]: #more-sql-generation
[Records: Splitting Database Encoding from Ability to Write in the Database]: #records-splitting-database-encoding-from-ability-to-write-in-the-database
[Non-Goals]: #non-goals
[Report Bugs]: #report-bugs
[RxGRDB]: http://github.com/RxSwiftCommunity/RxGRDB
@@ -391,3 +403,8 @@ Features that blur this focus are non-goals:
[Suggest an Enhancement]: #suggest-an-enhancement
[Suggested Contributions]: #suggested-contributions
[Typed Expressions]: #typed-expressions
[persistence methods]: README.md#persistence-methods
[PersistableRecord]: README.md#persistablerecord-protocol
[Record Comparison]: README.md#record-comparison
[Requesting Associated Records]: Documentation/AssociationsBasics.md#requesting-associated-records
[ValueObservation]: README.md#valueobservation
@@ -8,11 +8,10 @@ struct AppDatabase {
/// Creates a fully initialized database at path
static func openDatabase(atPath path: String) throws -> DatabaseQueue {
// Connect to the database
// See https://github.com/groue/GRDB.swift/#database-connections
dbQueue = try DatabaseQueue(path: path)
// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
let dbQueue = try DatabaseQueue(path: path)
// Use DatabaseMigrator to define the database schema
// See https://github.com/groue/GRDB.swift/#migrations
// Define the database schema
try migrator.migrate(dbQueue)
return dbQueue
@@ -20,8 +19,7 @@ struct AppDatabase {
/// The DatabaseMigrator that defines the database schema.
///
/// This migrator is exposed so that migrations can be tested.
// See https://github.com/groue/GRDB.swift/#migrations
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#migrations
static var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
@@ -29,11 +27,10 @@ struct AppDatabase {
// Create a table
// See https://github.com/groue/GRDB.swift#create-tables
try db.create(table: "player") { t in
// An integer primary key auto-generates unique IDs
t.column("id", .integer).primaryKey()
t.autoIncrementedPrimaryKey("id")
// Sort player names in a localized case insensitive fashion by default
// See https://github.com/groue/GRDB.swift/#unicode
// See https://github.com/groue/GRDB.swift/blob/master/README.md#unicode
t.column("name", .text).notNull().collate(.localizedCaseInsensitiveCompare)
t.column("score", .integer).notNull()
@@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
dbQueue = try AppDatabase.openDatabase(atPath: databaseURL.path)
// Be a nice iOS citizen, and don't consume too much memory
// See https://github.com/groue/GRDB.swift/#memory-management
// See https://github.com/groue/GRDB.swift/blob/master/README.md#memory-management
dbQueue.setupMemoryManagement(in: application)
}
}
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -14,7 +12,7 @@
<scene sceneID="Juk-Ad-tZ2">
<objects>
<tableViewController id="iNr-Oe-muq" customClass="PlayerEditionViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="vlV-lc-eQA">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" dataMode="static" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="vlV-lc-eQA">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -25,11 +23,11 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2gb-gB-918" id="iyM-TJ-JB4">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Name" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="m5m-Zs-j0z">
<rect key="frame" x="26" y="12" width="333" height="20"/>
<rect key="frame" x="16" y="12" width="343" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
<connections>
@@ -38,7 +36,7 @@
</textField>
</subviews>
<constraints>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="leading" secondItem="iyM-TJ-JB4" secondAttribute="leadingMargin" constant="10" id="9cK-nj-70V"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="leading" secondItem="iyM-TJ-JB4" secondAttribute="leadingMargin" id="9cK-nj-70V"/>
<constraint firstAttribute="trailingMargin" secondItem="m5m-Zs-j0z" secondAttribute="trailing" id="JsE-8v-XAS"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="centerY" secondItem="iyM-TJ-JB4" secondAttribute="centerY" id="psG-tW-QrM"/>
</constraints>
@@ -48,11 +46,11 @@
<rect key="frame" x="0.0" y="44" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vp3-Ft-Gth" id="ccO-0O-u72">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Score" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="rZ9-Fa-cyr">
<rect key="frame" x="26" y="12" width="333" height="20"/>
<rect key="frame" x="16" y="12" width="343" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="done"/>
</textField>
@@ -60,7 +58,7 @@
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="rZ9-Fa-cyr" secondAttribute="trailing" id="Gso-FU-Ct1"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="centerY" secondItem="ccO-0O-u72" secondAttribute="centerY" id="UqA-ea-emb"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="leading" secondItem="ccO-0O-u72" secondAttribute="leadingMargin" constant="10" id="WrY-St-72v"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="leading" secondItem="ccO-0O-u72" secondAttribute="leadingMargin" id="WrY-St-72v"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
+43 -6
View File
@@ -1,28 +1,65 @@
import GRDB
struct Player: Codable, FetchableRecord, MutablePersistableRecord {
// A plain Player struct
struct Player {
// Prefer Int64 for auto-incremented database ids
var id: Int64?
var name: String
var score: Int
}
enum Columns: String, ColumnExpression {
// MARK: - Persistence
// Turn Player into a Codable Record.
// See https://github.com/groue/GRDB.swift/blob/master/README.md#records
extension Player: Codable, FetchableRecord, MutablePersistableRecord {
// Add ColumnExpression to Codable's CodingKeys so that we can use them
// as database columns.
//
// See https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types
// for more information about CodingKeys.
private enum CodingKeys: String, CodingKey, ColumnExpression {
case id, name, score
}
/// Update player id after successful insertion
// Update a player id after it has been inserted in the database.
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
// MARK: - Database access
// Define some useful player requests.
// See https://github.com/groue/GRDB.swift/blob/master/README.md#requests
extension Player {
private static let names = ["Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David", "Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette", "Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl", "Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole", "Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul", "Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain", "Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann", "Zazie", "Zoé"]
static func orderedByName() -> QueryInterfaceRequest<Player> {
return Player.order(CodingKeys.name)
}
static func orderedByScore() -> QueryInterfaceRequest<Player> {
return Player.order(CodingKeys.score.desc, CodingKeys.name)
}
}
// MARK: - Player Randomization
extension Player {
private static let names = [
"Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David",
"Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette",
"Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl",
"Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole",
"Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul",
"Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain",
"Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann",
"Zazie", "Zoé"]
static func randomName() -> String {
return names[Int(arc4random_uniform(UInt32(names.count)))]
return names.randomElement()!
}
static func randomScore() -> Int {
return 10 * Int(arc4random_uniform(101))
return 10 * Int.random(in: 0...100)
}
}
@@ -1,13 +1,16 @@
import UIKit
protocol PlayerEditionViewControllerDelegate: class {
func playerEditionControllerDidComplete(_ controller: PlayerEditionViewController)
}
class PlayerEditionViewController: UITableViewController {
weak var delegate: PlayerEditionViewControllerDelegate?
enum Presentation {
/// Modal presentation: edition ends with the "Commit" segue.
case modal
/// Push presentation: edition ends when user hits the back button.
case push
}
var player: Player! { didSet { configureView() } }
var commitButtonHidden: Bool = false { didSet { configureView() } }
var presentation: Presentation! { didSet { configureView() } }
@IBOutlet fileprivate weak var cancelBarButtonItem: UIBarButtonItem!
@IBOutlet fileprivate weak var commitBarButtonItem: UIBarButtonItem!
@@ -31,13 +34,14 @@ class PlayerEditionViewController: UITableViewController {
} else {
scoreTextField.text = "\(player.score)"
}
if commitButtonHidden {
navigationItem.leftBarButtonItem = nil
navigationItem.rightBarButtonItem = nil
} else {
switch presentation! {
case .modal:
navigationItem.leftBarButtonItem = cancelBarButtonItem
navigationItem.rightBarButtonItem = commitBarButtonItem
case .push:
navigationItem.leftBarButtonItem = nil
navigationItem.rightBarButtonItem = nil
}
}
}
@@ -55,17 +59,21 @@ extension PlayerEditionViewController {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Commit" {
applyChanges()
saveChanges()
}
}
override func willMove(toParent parent: UIViewController?) {
super.willMove(toParent: parent)
if parent == nil {
// Self is popping from its navigation controller
applyChanges()
delegate?.playerEditionControllerDidComplete(self)
switch presentation! {
case .modal:
break
case .push:
if parent == nil {
// Self is popping from its navigation controller
saveChanges()
}
}
}
@@ -98,12 +106,16 @@ extension PlayerEditionViewController: UITextFieldDelegate {
return false
}
private func applyChanges() {
private func saveChanges() {
guard var player = self.player else {
return
}
player.name = nameTextField.text ?? ""
player.score = scoreTextField.text.flatMap { Int($0) } ?? 0
self.player = player
try! dbQueue.inDatabase { db in
try player.save(db)
}
}
}
@@ -1,94 +1,92 @@
import UIKit
import GRDB
/// PlayersViewController displays the list of players.
class PlayersViewController: UITableViewController {
enum PlayerOrdering {
private enum PlayerOrdering {
case byName
case byScore
var request: QueryInterfaceRequest<Player> {
switch self {
case .byName:
return Player.order(Player.Columns.name)
case .byScore:
return Player.order(Player.Columns.score.desc, Player.Columns.name)
}
}
}
var playersController: FetchedRecordsController<Player>!
var playerOrdering: PlayerOrdering = .byScore {
@IBOutlet private weak var newPlayerButtonItem: UIBarButtonItem!
private var playersController: FetchedRecordsController<Player>!
private var playerCountObserver: TransactionObserver?
private var playerOrdering: PlayerOrdering = .byScore {
didSet {
try! playersController.setRequest(playerOrdering.request)
configureNavigationItem()
try! playersController.setRequest(playersRequest)
configureOrderingBarButtonItem()
}
}
private var playersRequest: QueryInterfaceRequest<Player> {
switch playerOrdering {
case .byName:
return Player.orderedByName()
case .byScore:
return Player.orderedByScore()
}
}
@IBOutlet weak var newPlayerButtonItem: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
configureTableView()
configureToolbar()
configureNavigationItem()
configureTableView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isToolbarHidden = false
}
}
// MARK: - Navigation
extension PlayersViewController : PlayerEditionViewControllerDelegate {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Edit" {
let player = playersController.record(at: tableView.indexPathForSelectedRow!)
let controller = segue.destination as! PlayerEditionViewController
controller.title = player.name
controller.player = player
controller.delegate = self // See playerEditionControllerDidComplete
controller.commitButtonHidden = true
}
else if segue.identifier == "New" {
setEditing(false, animated: true)
let navigationController = segue.destination as! UINavigationController
let controller = navigationController.viewControllers.first as! PlayerEditionViewController
controller.title = "New Player"
controller.player = Player(id: nil, name: "", score: 0)
private func configureToolbar() {
toolbarItems = [
UIBarButtonItem(barButtonSystemItem: .trash, target: self, action: #selector(deletePlayers)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "💣", style: .plain, target: self, action: #selector(stressTest)),
]
}
private func configureNavigationItem() {
navigationItem.leftBarButtonItems = [editButtonItem, newPlayerButtonItem]
configureOrderingBarButtonItem()
configureTitle()
}
private func configureOrderingBarButtonItem() {
switch playerOrdering {
case .byScore:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Score ⬇︎",
style: .plain,
target: self, action: #selector(sortByName))
case .byName:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Name ⬆︎",
style: .plain,
target: self, action: #selector(sortByScore))
}
}
@IBAction func cancelPlayerEdition(_ segue: UIStoryboardSegue) {
// Player creation: cancel button was tapped
}
@IBAction func commitPlayerEdition(_ segue: UIStoryboardSegue) {
// Player creation: commit button was tapped
let controller = segue.source as! PlayerEditionViewController
try! dbQueue.write { db in
try controller.player.save(db)
private func configureTitle() {
// Track changes in the number of players
playerCountObserver = try! ValueObservation
.trackingCount(playersRequest)
.start(in: dbQueue) { [unowned self] count in
switch count {
case 0: self.navigationItem.title = "No Player"
case 1: self.navigationItem.title = "1 Player"
default: self.navigationItem.title = "\(count) Players"
}
}
}
func playerEditionControllerDidComplete(_ controller: PlayerEditionViewController) {
// Player edition: user has finished editing the player
try! dbQueue.write { db in
try controller.player.save(db)
}
}
}
// MARK: - UITableViewDataSource
extension PlayersViewController {
private func configureTableView() {
playersController = try! FetchedRecordsController(dbQueue, request: playerOrdering.request)
// Track changes in the database players
playersController = try! FetchedRecordsController(dbQueue, request: playersRequest)
// Animate changes in the table view
playersController.trackChanges(
willChange: { [unowned self] _ in
self.tableView.beginUpdates()
@@ -123,9 +121,47 @@ extension PlayersViewController {
self.tableView.endUpdates()
})
// Initial fetch
try! playersController.performFetch()
}
}
// MARK: - Navigation
extension PlayersViewController {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Edit" {
let player = playersController.record(at: tableView.indexPathForSelectedRow!)
let controller = segue.destination as! PlayerEditionViewController
controller.title = player.name
controller.player = player
controller.presentation = .push
}
else if segue.identifier == "New" {
setEditing(false, animated: true)
let navigationController = segue.destination as! UINavigationController
let controller = navigationController.viewControllers.first as! PlayerEditionViewController
controller.title = "New Player"
controller.player = Player(id: nil, name: "", score: 0)
controller.presentation = .modal
}
}
@IBAction func cancelPlayerEdition(_ segue: UIStoryboardSegue) {
// Player creation cancelled
}
@IBAction func commitPlayerEdition(_ segue: UIStoryboardSegue) {
// Player creation committed
}
}
// MARK: - UITableViewDataSource
extension PlayersViewController {
override func numberOfSections(in tableView: UITableView) -> Int {
return playersController.sections.count
}
@@ -151,7 +187,7 @@ extension PlayersViewController {
private func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
let player = playersController.record(at: indexPath)
if player.name.isEmpty {
cell.textLabel?.text = "(anonymous)"
cell.textLabel?.text = "-"
} else {
cell.textLabel?.text = player.name
}
@@ -163,33 +199,6 @@ extension PlayersViewController {
// MARK: - Actions
extension PlayersViewController {
private func configureNavigationItem() {
navigationItem.leftBarButtonItems = [editButtonItem, newPlayerButtonItem]
switch playerOrdering {
case .byScore:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Score ⬇︎",
style: .plain,
target: self, action: #selector(sortByName))
case .byName:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Name ⬆︎",
style: .plain,
target: self, action: #selector(sortByScore))
}
}
private func configureToolbar() {
toolbarItems = [
UIBarButtonItem(barButtonSystemItem: .trash, target: self, action: #selector(deletePlayers)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "💣", style: .plain, target: self, action: #selector(stressTest)),
]
}
@IBAction func sortByName() {
setEditing(false, animated: true)
playerOrdering = .byName
@@ -231,16 +240,16 @@ extension PlayersViewController {
}
} else {
// Insert a player
if arc4random_uniform(2) == 0 {
if Bool.random() {
var player = Player(id: nil, name: Player.randomName(), score: Player.randomScore())
try player.insert(db)
}
// Delete a random player
if arc4random_uniform(2) == 0 {
if Bool.random() {
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
}
// Update some players
for var player in try Player.fetchAll(db) where arc4random_uniform(2) == 0 {
for var player in try Player.fetchAll(db) where Bool.random() {
player.score = Player.randomScore()
try player.update(db)
}
+32
View File
@@ -0,0 +1,32 @@
Demo Application
================
<img align="right" src="https://github.com/groue/GRDB.swift/raw/master/Documentation/Images/GRDBDemoScreenshot.png" width="50%">
**This demo application shows you:**
- how to setup a database in an iOS app
- how to define a simple [Codable Record](../../README.md#codable-records)
- how to track database changes and animate a table view with [FetchedRecordsController](../../README.md#fetchedrecordscontroller).
**Files of interest:**
- [AppDelegate.swift](GRDBDemoiOS/AppDelegate.swift)
`AppDelegate` creates, on application startup, a unique instance of [DatabaseQueue](../../README.md#database-queues) available for the whole application.
- [AppDatabase.swift](GRDBDemoiOS/AppDatabase.swift)
`AppDatabase` defines the database for the whole application. It uses [DatabaseMigrator](../../README.md#migrations) in order to setup the database schema.
- [Player.swift](GRDBDemoiOS/Player.swift)
`Player` is a [Record](../../README.md#records) type, able to read and write in the database. It conforms to the standard Codable protocol in order to gain all advantages of [Codable Records](../../README.md#codable-records).
- [PlayersViewController.swift](GRDBDemoiOS/PlayersViewController.swift)
`PlayersViewController` displays a list of players. It keeps its title up-to-date with [ValueObservation](../../README.md#valueobservation), and animates its table view according to database changes with [FetchedRecordsController](../../README.md#fetchedrecordscontroller).
- [PlayerEditionViewController.swift](GRDBDemoiOS/PlayerEditionViewController.swift)
`PlayerEditionViewController` can create or edit a player, and save it in the database.
+565 -32
View File
@@ -22,10 +22,16 @@ GRDB Associations
- [Sorting Associations]
- [Columns Selected by an Association]
- [Table Aliases]
- [Refining Association Requests]
- [Fetching Values from Associations]
- [The Structure of a Joined Request]
- [Decoding a Joined Request with a Decodable Record]
- [Decoding a Joined Request with FetchableRecord]
- [Association Aggregates]
- [Available Association Aggregates]
- [Annotating a Request with Aggregates]
- [Filtering a Request with Aggregates]
- [Isolation of Multiple Aggregates]
- [DerivableRequest Protocol]
- [Known Issues]
- [Future Directions]
@@ -557,8 +563,8 @@ Your help is needed. You have to instruct GRDB which foreign key to use:
```swift
struct Book: TableRecord {
// Define foreign keys
static let authorForeignKey = ForeignKey(["authorId"]))
static let translatorForeignKey = ForeignKey(["translatorId"]))
static let authorForeignKey = ForeignKey(["authorId"])
static let translatorForeignKey = ForeignKey(["translatorId"])
// Use foreign keys to define associations:
static let author = belongsTo(Person.self, using: authorForeignKey)
@@ -583,8 +589,8 @@ struct Book: TableRecord {
case id, title, authorId, translatorId
}
static let authorForeignKey = ForeignKey([Columns.authorId]))
static let translatorForeignKey = ForeignKey([Columns.translatorId]))
static let authorForeignKey = ForeignKey([Columns.authorId])
static let translatorForeignKey = ForeignKey([Columns.translatorId])
}
```
@@ -592,7 +598,7 @@ When the destination table of a foreign key does not define any primary key, you
```swift
struct Book: TableRecord {
static let authorForeignKey = ForeignKey(["authorId"], to: ["id"]))
static let authorForeignKey = ForeignKey(["authorId"], to: ["id"])
static let author = belongsTo(Person.self, using: authorForeignKey)
}
```
@@ -614,6 +620,7 @@ Fetch requests do not visit the database until you fetch values from them. This
- [Sorting Associations]
- [Columns Selected by an Association]
- [Table Aliases]
- [Refining Association Requests]
## Requesting Associated Records
@@ -1016,6 +1023,113 @@ let request = Book.aliased(bookAlias)
> ```
## Refining Association Requests
You can join and include an association several times in a single request. This can help you craft complex requests in a modular way.
Let's say, for example, that your application needs all books, along with their Spanish authors, sorted by author name and then by title. That's already pretty complex.
This request can be built in a single shot:
```swift
let authorAlias = TableAlias()
let request = Book
.including(required: Book.author
.filter(Column("countryCode") == "ES")
.aliased(authorAlias))
.order(authorAlias[Column("name")], Column("title"))
```
The same request can also be built in three distinct steps, as below:
```swift
// 1. include author
var request = Book.including(required: Book.author)
// 2. filter by author country
request = request.joining(required: Book.author.filter(Column("countryCode") == "ES"))
// 3. sort by author name and then title
let authorAlias = TableAlias()
request = request
.joining(optional: Book.author.aliased(authorAlias))
.order(authorAlias[Column("name")], Column("title"))
```
See how the `Book.author` has been joined or included, on each step, independently, for a different purpose. We can wrap those steps in an extension to the `QueryInterfaceRequest<Book>` type:
```swift
extension QueryInterfaceRequest where T == Book {
func filter(authorCountryCode: String) -> QueryInterfaceRequest<Book> {
let filteredAuthor = Book.author.filter(Column("countryCode") == countryCode)
return joining(required: filteredAuthor)
}
func orderedByAuthorNameAndTitle() -> QueryInterfaceRequest<Book> {
let authorAlias = TableAlias()
return joining(optional: Book.author.aliased(authorAlias))
.order(authorAlias[Column("name")], Column("title"))
}
}
```
And now our complex request looks much simpler:
```swift
let request = Book
.including(required: Book.author)
.filter(authorCountryCode: "ES")
.orderedByAuthorNameAndTitle()
```
When you join or include an association several times, with the same **[association key](#the-structure-of-a-joined-request)**, GRDB will apply the following rules:
- `including` wins over `joining`:
```swift
// Equivalent to Record.including(optional: association)
Record
.including(optional: association)
.joining(optional: association)
```
- `required` wins over `optional`:
```swift
// Equivalent to Record.including(required: association)
Record
.including(required: association)
.including(optional: association)
```
- All [filters](#filtering-associations) are applied:
```swift
// Equivalent to Record.including(required: association.filter(condition1 && condition2))
Record
.including(required: association.filter(condition1))
.including(optional: association.filter(condition1))
```
- The last [ordering](#sorting-associations) wins:
```swift
// Equivalent to Record.including(required: association.order(ordering2))
Record
.including(required: association.order(ordering1))
.including(optional: association.order(ordering2))
```
- The last [selection](#columns-selected-by-an-association) wins:
```swift
// Equivalent to Record.including(required: association.select(selection2))
Record
.including(required: association.select(selection1))
.including(optional: association.select(selection2))
```
Fetching Values from Associations
=================================
@@ -1285,6 +1399,444 @@ let country: Country? = row["country"]
You can also perform custom navigation in the tree by using *row scopes*. See [Row Adapters] for more information.
## Association Aggregates
It is possible to fetch aggregated values from a **[HasMany]** association:
Counting associated records, fetching the minimum, maximum, average value of an associated record column, computing the sum of an associated record column, these are all aggregation operations.
When you need to compute aggregates **from a single record**, you use regular aggregating methods, detailed in the [Fetching Aggregated Values] chapter. For example:
```swift
let author: Author = ...
let bookCount = try author.books.fetchCount(db) // Int
let request = author.books.select(max(yearColumn))
let maxBookYear = try Int.fetchOne(db, request) // Int?
```
When you need to compute aggregates **from several record**, in a single shot, you'll use an **association aggregate**. Those are the topic of this chapter.
For example, you'll use the `isEmpty` aggregate when you want, say, to fetch all authors who wrote no book at all:
```swift
let lazyAuthors: [Author] = try Author.having(Author.books.isEmpty).fetchAll(db)
let productiveAuthors: [Author] = try Author.having(Author.books.isEmpty == false).fetchAll(db)
```
And you'll use the `count` aggregate in order to fetch all authors along with the number of books they wrote:
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var bookCount: Int
}
let request = Author.annotated(with: Author.books.count)
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
for info in authorInfos {
print("\(info.author.name) wrote \(info.bookCount) book(s).")
}
```
### Available Association Aggregates
**HasMany** associations let you build the following association aggregates:
- `books.count`
- `books.isEmpty`
- `books.min(column)`
- `books.max(column)`
- `books.average(column)`
- `books.sum(column)`
### Annotating a Request with Aggregates
The `annotated(with:)` method appends aggregated values to the selected columns of a request. You can append as many aggregates values as needed, from one or several associations.
In order to access those values, you fetch records that have matching properties.
For example:
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var bookCount: Int
var maxBookYear: Int?
}
// SELECT author.*,
// COUNT(DISTINCT book.rowid) AS bookCount,
// MAX(book.year) AS maxBookYear,
// FROM author
// LEFT JOIN book ON book.authorId = author.id
// GROUP BY author.id
let request = Author.annotated(with:
Author.books.count,
Author.books.max(Column("year")))
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
for info in authorInfos {
print(info.author.name)
print("- number of books: \(info.bookCount)")
print("- last book published on: \(info.maxBookYear)")
}
```
As seen in the above example, some aggregated values are given a **default name**, such as "bookCount" or "maxBookYear". The default name is built from the aggregating method, the **[association key](#the-structure-of-a-joined-request)**, and the aggregated column name:
| Method | Key | Column | Default name |
| --------- | --- | ------ | ------------- |
| `Author.books.isEmpty ` | `book` | - | - |
| `Author.books.count ` | `book` | - | `bookCount` |
| `Author.books.min(Column("year"))` | `book` | `year` | `minBookYear` |
| `Author.books.max(Column("year"))` | `book` | `year` | `maxBookYear` |
| `Author.books.average(Column("price"))` | `book` | `price` | `averageBookPrice` |
| `Author.books.sum(Column("awards")) ` | `book` | `awards` | `bookAwardsSum` |
You give a custom name to an aggregated value with the `aliased` method:
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var numberOfBooks: Int
}
// SELECT author.*, COUNT(DISTINCT book.rowid) AS numberOfBooks
// FROM author
// LEFT JOIN book ON book.authorId = author.id
// GROUP BY author.id
let request = Author.annotated(with: Author.books.count.aliased("numberOfBooks"))
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
The `aliased` method also accept coding keys:
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var numberOfBooks: Int
static func fetchAll(_ db: Database) throws -> [AuthorInfo] {
let request = Author.annotated(with: Author.books.count.aliased(CodingKey.numberOfBooks))
return try AuthorInfo.fetchAll(db, request)
}
}
```
Custom names help consuming complex aggregates that have no name by default:
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var workCount: Int
}
// SELECT author.*,
// (COUNT(DISTINCT book.rowid) + COUNT(DISTINCT painting.rowid)) AS workCount
// FROM author
// LEFT JOIN book ON book.authorId = author.id
// LEFT JOIN painting ON painting.authorId = author.id
// GROUP BY author.id
let aggregate = Author.books.count + Author.paintings.count
let request = Author.annotated(with: aggregate.aliased("workCount"))
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
### Filtering a Request with Aggregates
The `having(_:)` method filters a request according to an aggregated value. You can append as many aggregate conditions as needed, from one or several associations.
- Authors who did not write any book:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) = 0
```
</details>
```swift
let request = Author.having(Author.books.isEmpty)
```
- Authors who wrote at least one book:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) > 0
```
</details>
```swift
let request = Author.having(Author.books.isEmpty == false)
```
- Authors who wrote at least two books:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) >= 2
```
</details>
```swift
let request = Author.having(Author.books.count >= 2)
```
- Authors who wrote at least one book after 2010:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING MAX(book.year) >= 2010
```
</details>
```swift
let request = Author.having(Author.books.max(Column("year")) >= 2010)
```
- Authors who wrote at least one book of kind "novel":
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id AND book.kind = 'novel'
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) > 0
```
</details>
```swift
let novels = Author.books.filter(Column("kind") == "novel")
let request = Author.having(novels.isEmpty == false)
```
- Authors who wrote more books than they made paintings:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
LEFT JOIN painting ON painting.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) > COUNT(DISTINCT painting.rowid)
```
</details>
```swift
let request = Author.having(Author.books.count > Author.paintings.count)
```
- Authors who wrote no book, but made at least one painting:
<details>
<summary>SQL</summary>
```sql
SELECT author.*
FROM author
LEFT JOIN book ON book.authorId = author.id
LEFT JOIN painting ON painting.authorId = author.id
GROUP BY author.id
HAVING ((COUNT(DISTINCT book.rowid) = 0) AND (COUNT(DISTINCT painting.rowid) > 0))
```
</details>
```swift
let request = Author.having(Author.books.isEmpty && !Author.paintings.isEmpty)
```
### Isolation of Multiple Aggregates
When you compute multiple aggregates, make sure they use as many distinct **[association keys](#the-structure-of-a-joined-request)** as there are distinct populations of associated records.
In the example below, we use compute two aggregates from the same association `Author.books`. Both aggregates are computed on the same population of associated records, and so we want them to share the same association key:
- Authors with the publishing year of their first and last book:
<details>
<summary>SQL</summary>
```sql
SELECT author.*,
MIN(book.year) AS minBookYear,
MAX(book.year) AS maxBookYea
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
```
</details>
```swift
struct Author: TableRecord {
static let books = hasMany(Book.self) // association key "book"
}
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var minBookYear: Int?
var maxBookYear: Int?
}
let request = Author.annotated(with:
Author.books.min(Column("year")), // association key "book"
Author.books.max(Column("year"))) // association key "book"
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
In this other example, the `Author.books` and `Author.paintings` have the distinct `book` and `painting` keys. They don't interfere, and provide the expected results:
- Authors with their number of books and paintings:
<details>
<summary>SQL</summary>
```sql
SELECT author.*,
(COUNT(DISTINCT book.rowid) + COUNT(DISTINCT painting.rowid)) AS workCount
FROM author
LEFT JOIN book ON book.authorId = author.id
LEFT JOIN painting ON painting.authorId = author.id
GROUP BY author.id
```
</details>
```swift
struct Author: TableRecord {
static let books = hasMany(Book.self) // association key "book"
static let paintings = hasMany(Painting.self) // association key "painting"
}
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var workCount: Int
}
let aggregate = Author.books.count + // association key "book"
Author.paintings.count // association key "painting"
let request = Author.annotated(with: aggregate.aliased("workCount"))
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
But in the following example, we use the same association `Author.books` twice, in order to compute aggregates on two distinct populations of associated books. We must provide explicit keys in order to make sure both aggregates are computed independently:
- Authors with their number of novels and theatre plays:
<details>
<summary>SQL</summary>
```sql
SELECT author.*,
COUNT(DISTINCT book1.rowid) AS novelCount,
COUNT(DISTINCT book2.rowid) AS theatrePlayCount
FROM author
LEFT JOIN book book1 ON book1.authorId = author.id AND book1.kind = 'novel'
LEFT JOIN book book2 ON book2.authorId = author.id AND book2.kind = 'theatrePlay'
GROUP BY author.id
```
</details>
```swift
struct Author: TableRecord {
static let books = hasMany(Book.self) // association key "book"
}
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var novelCount: Int
var theatrePlayCount: Int
}
let novelCount = Author.books
.filter(Column("kind") == "novel")
.forKey("novel") // association key "novel"
.count
let theatrePlayCount = Author.books
.filter(Column("kind") == "theatrePlay")
.forKey("theatrePlay") // association key "theatrePlay"
.count
let request = Author.annotated(with: novelCount, theatrePlayCount)
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
When one doesn't use distinct association keys for novels and theatre plays, GRDB will not count two distinct sets of associated books, and will not fetch the expected results:
<details>
<summary>SQL</summary>
```sql
SELECT author.*,
COUNT(DISTINCT book.rowid) AS novelCount,
COUNT(DISTINCT book.rowid) AS theatrePlayCount
FROM author
LEFT JOIN book ON book.authorId = author.id
AND (book.kind = 'novel' AND book.kind = 'theatrePlay')
GROUP BY author.id
```
</details>
```swift
// WRONG: not counting distinct sets of associated books
let novelCount = Author.books // association key "book"
.filter(Column("kind") == "novel")
.count
.aliased("novelCount")
let theatrePlayCount = Author.books // association key "book"
.filter(Column("kind") == "theatrePlay")
.count
.aliased("theatrePlayCount")
let request = Author.annotated(with: novelCount, theatrePlayCount)
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
## DerivableRequest Protocol
The `DerivableRequest` protocol is adopted by both [query interface requests] such as `Author.all()` and associations such as `Book.author`. It is intended for you to use as a customization point when you want to extend the built-in GRDB apis.
@@ -1333,26 +1885,6 @@ let request = Book
This code compiles, but you'll get a runtime fatal error "Not implemented: chaining a required association behind an optional association". Future versions of GRDB may allow such requests.
**You can't join two associations with the same [association key](#the-structure-of-a-joined-request) at the same level:**
```swift
// NOT IMPLEMENTED
let request = Book
.including(required: Book.author) // key "author"
.including(required: Book.author) // key "author"
```
This code compiles, but you'll get a runtime fatal error "The association key `author` is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.". Future versions of GRDB may allow such requests.
To join the same table twice, and make sure GRDB does not modify the fetched results in some future release, make sure no two associations have the same name on a given level:
```swift
// OK
let request = Book
.including(required: Book.author.forKey("firstAuthor"))
.including(required: Book.author.forKey("secondAuthor"))
```
## Future Directions
@@ -1362,12 +1894,6 @@ The APIs that have been described above do not cover the whole topic of joined r
- One can not yet express requests such as "all authors with all their books".
- A common use case of associations is aggregations, such as fetching all authors with the number of books they have written:
```swift
let request = Author.annotate(with: Author.books.count)
```
- There's no HasOneThrough and HasManyThrough association, which would allow to skip intermediate bridge records when building requests.
Those features are not present yet because they hide several very tough challenges. Come [discuss](http://twitter.com/groue) for more information, or if you wish to help turning those features into reality.
@@ -1383,7 +1909,7 @@ This documentation owns a lot to the [Active Record Associations](http://guides.
**GRDB**
Copyright (C) 2018 Gwendal Roué
Copyright (C) 2019 Gwendal Roué
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -1440,11 +1966,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[Sorting Associations]: #sorting-associations
[Columns Selected by an Association]: #columns-selected-by-an-association
[Table Aliases]: #table-aliases
[Refining Association Requests]: #refining-association-requests
[The Structure of a Joined Request]: #the-structure-of-a-joined-request
[Decoding a Joined Request with a Decodable Record]: #decoding-a-joined-request-with-a-decodable-record
[Decoding a Hierarchical Decodable Record]: #decoding-a-hierarchical-decodable-record
[Decoding a Joined Request with FetchableRecord]: #decoding-a-joined-request-with-fetchablerecord
[Custom Requests]: ../README.md#custom-requests
[Association Aggregates]: #association-aggregates
[Available Association Aggregates]: #available-association-aggregates
[Annotating a Request with Aggregates]: #annotating-a-request-with-aggregates
[Filtering a Request with Aggregates]: #filtering-a-request-with-aggregates
[Isolation of Multiple Aggregates]: #isolation-of-multiple-aggregates
[DerivableRequest Protocol]: #derivablerequest-protocol
[Known Issues]: #known-issues
[Future Directions]: #future-directions
@@ -1453,3 +1985,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[TableRecord]: ../README.md#tablerecord-protocol
[association requests]: #building-requests-from-associations
[Good Practices for Designing Record Types]: GoodPracticesForDesigningRecordTypes.md
[Fetching Aggregated Values]: ../README.md#fetching-aggregated-values
+2 -2
View File
@@ -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.24.0](https://www.sqlite.org/changes.html).**
**You can build GRDB with a custom build of [SQLite 3.25.2](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 directory]
git checkout v3.3.0
git checkout v3.6.2
git submodule update --init SQLiteCustom/src
````
+9 -6
View File
@@ -446,14 +446,16 @@ Now you'll write instead:
```swift
// GRDB 3
dbQueue.rx
.fetch(from: [request, ...]) { db in try fetchResult(db) }
ValueObservation
.tracking([request, ...], fetch: { db in try fetchResult(db) })
.rx
.fetch(in: dbQueue)
.subscribe(...)
```
It's just a syntactic change, without any impact on the runtime.
RxGRDB for GRDB 3 also introduces a new protocol, [DatabaseRegionConvertible], that allows a better encapsulation of complex requests, and a streamlined observable definition.
GRDB 3.6 also introduces a new protocol, [DatabaseRegionConvertible], that allows a better encapsulation of complex requests, and a streamlined observable definition.
For example:
@@ -478,8 +480,9 @@ dbQueue.rx
// GRDB 3: Track a team and its players
struct TeamInfoRequest: DatabaseRegionConvertible { ... }
let request = TeamInfoRequest(teamId: 1)
dbQueue.rx
.fetch(from: [request]) { try request.fetchOne($0) }
ValueObservation.tracking(request, fetch: { try request.fetchOne($0) })
.rx
.fetch(in: dbQueue)
.subscribe(onNext: { teamInfo: TeamInfo? in
...
})
@@ -526,5 +529,5 @@ If you have time, you may dig deeper in GRDB 3 with those updated documentation
[record protocols]: ../README.md#record-protocols-overview
[Custom requests]: ../README.md#custom-requests
[query interface]: ../README.md#the-query-interface
[DatabaseRegionConvertible]: https://github.com/groue/RxGRDB/blob/master/README.md#databaseregionconvertible-protocol
[DatabaseRegionConvertible]: https://github.com/groue/GRDB.swift#the-databaseregionconvertible-protocol
[conditional conformances]: https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md
@@ -308,11 +308,13 @@ This synchronization is not automatic with GRDB: records do not "auto-update". T
Instead, have a look at [Database Observation]:
> :bulb: **Tip**: Use [FetchedRecordsController] when a table or collection views should remained synchronized with the database, in an animated way.
> :bulb: **Tip**: [ValueObservation] performs automated tracking of database changes.
>
> :bulb: **Tip**: Use [RxGRDB] when your application needs to react to all changes in the results of a database request.
> :bulb: **Tip**: [FetchedRecordsController] performs automated tracking of database changes, and can animate the cells of a table or collection view.
>
> :bulb: **Tip**: Use [TransactionObserver], the low-level protocol for database observation, for your most advanced needs.
> :bulb: **Tip**: [RxGRDB] performs automated tracking of database changes, in the [RxSwift](https://github.com/ReactiveX/RxSwift) way.
>
> :bulb: **Tip**: [TransactionObserver] provides low-level database observation, for your most advanced needs.
>
> :bulb: **Tip**: Don't try to write complex methods that both modify the database and the values in memory at the same time. Instead, modify the database with plain record types, and rely on database observation for automatically refreshing values, even complex ones.
@@ -337,6 +339,7 @@ Instead, have a look at [Database Observation]:
[Concurrency Guide]: ../README.md#concurrency
[PersistableRecord]: ../README.md#persistablerecord-protocol
[Database Observation]: ../README.md#database-changes-observation
[ValueObservation]: ../README.md#valueobservation
[FetchedRecordsController]: ../README.md#fetchedrecordscontroller
[RxGRDB]: http://github.com/RxSwiftCommunity/RxGRDB
[TransactionObserver]: ../README.md#transactionobserver-protocol
Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

-1
View File
@@ -28,7 +28,6 @@ To release a new GRDB version:
- `pod trunk push --allow-warnings GRDBPlus.podspec`
- `pod trunk push --allow-warnings GRDBCipher.podspec`
- `make doc`, and update index.html in the `gh-pages` branch
- Update http://github.com/groue/GRDBDemo
- Update http://github.com/groue/WWDCCompanion
- Update [performance comparison](https://github.com/groue/GRDB.swift/wiki/Performance):
+6 -2
View File
@@ -86,6 +86,8 @@ extension Place: PersistableRecord { ... }
try place.delete(db)
```
For your convenience, those record protocols can be derived from the [Decodable and Encodable](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types) protocols of the standard library. [Codable records] are even given free support for JSON columns and other niceties.
Being a protocol-oriented library that welcomes immutable types, GRDB records are unlike records in other ORM libraries. Particularly, records do not auto-update, and records are not uniqued. We'll see below that the lack of those features can be replaced with **database change notifications**, with many advantages.
@@ -113,7 +115,7 @@ let players = try Player.fetchAll(db)
**Fetched records behave just like an in-memory cache of the database content.** Your application is free to decide, on its own, how it should handle the lifetime of those cached values: by ignoring future database changes, by observing database changes and react accordingly, or in any way deemed relevant.
There are several ways to be notified of database changes. You can build on top of the low-level [TransactionObserver] protocol. Or you can use [FetchedRecordsController], which looks a lot like Core Data's NSFetchedResultsController, and is able to animate table and collection views. And don't forget [RxGRDB], a set of reactive extensions based on [RxSwift]:
There are several ways to be notified of database changes. You can build on top of the fundamental but low-level [TransactionObserver] protocol. Usually, you'll use [ValueObservation], which notifies fresh values after each database change, or [FetchedRecordsController], which animates table and collection views. And don't forget [RxGRDB], a set of reactive extensions based on [RxSwift]:
```swift
Player.all().rx
@@ -250,7 +252,7 @@ extension Player {
let players = try Player.customRequest(...).fetchAll(db)
```
Those custom requests are welcome in database observation tools like [FetchedRecordsController] and [RxGRDB]:
Those custom requests are welcome in database observation tools like [ValueObservation] and [RxGRDB]:
```swift
Player.customRequest(...).rx
@@ -273,6 +275,7 @@ Happy GRDB! :gift:
[DatabasePool]: ../README.md#database-pools
[Diesel]: http://diesel.rs
[FCModel]: https://github.com/marcoarment/FCModel
[ValueObservation]: ../README.md#valueobservation
[FetchedRecordsController]: ../README.md#fetchedrecordscontroller
[Fluent]: https://github.com/vapor/fluent
[FMDB]: http://github.com/ccgus/fmdb
@@ -290,3 +293,4 @@ Happy GRDB! :gift:
[TransactionObserver]: ../README.md#transactionobserver-protocol
[query interface]: ../README.md#the-query-interface
[associations]: AssociationsBasics.md
[Codable records]: ../README.md#codable-records
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
s.version = '3.3.0'
s.version = '3.6.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
+240 -6
View File
@@ -49,6 +49,29 @@
560D92481C672C4B00F4F92B /* PersistableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92441C672C4B00F4F92B /* PersistableRecord.swift */; };
560D924B1C672C4B00F4F92B /* TableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92461C672C4B00F4F92B /* TableRecord.swift */; };
560D924C1C672C4B00F4F92B /* TableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92461C672C4B00F4F92B /* TableRecord.swift */; };
5613ED3521A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3421A95A5C00DC7A68 /* ValueObservation+Map.swift */; };
5613ED3621A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3421A95A5C00DC7A68 /* ValueObservation+Map.swift */; };
5613ED3721A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3421A95A5C00DC7A68 /* ValueObservation+Map.swift */; };
5613ED3F21A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3E21A95A8B00DC7A68 /* ValueObservation+Combine.swift */; };
5613ED4021A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3E21A95A8B00DC7A68 /* ValueObservation+Combine.swift */; };
5613ED4121A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED3E21A95A8B00DC7A68 /* ValueObservation+Combine.swift */; };
5613ED4421A95B2C00DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4321A95B2C00DC7A68 /* ValueReducer.swift */; };
5613ED4521A95B2C00DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4321A95B2C00DC7A68 /* ValueReducer.swift */; };
5613ED4621A95B2C00DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4321A95B2C00DC7A68 /* ValueReducer.swift */; };
5613ED4821A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4721A95C1200DC7A68 /* ValueObservation+Row.swift */; };
5613ED4921A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4721A95C1200DC7A68 /* ValueObservation+Row.swift */; };
5613ED4A21A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4721A95C1200DC7A68 /* ValueObservation+Row.swift */; };
5613ED4C21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4B21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED4D21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4B21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED4E21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4B21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED5021A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4F21A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED5121A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4F21A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED5221A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED4F21A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED5421A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5321A95DD000DC7A68 /* ValueObservation+Count.swift */; };
5613ED5521A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5321A95DD000DC7A68 /* ValueObservation+Count.swift */; };
5613ED5621A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5321A95DD000DC7A68 /* ValueObservation+Count.swift */; };
5613EDA621A96A9300DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613EDA521A96A9200DC7A68 /* ValueObservationCombineTests.swift */; };
5613EDA721A96A9300DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613EDA521A96A9200DC7A68 /* ValueObservationCombineTests.swift */; };
561667051D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
5616AAF1207CD45E00AC3664 /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5616AAF0207CD45E00AC3664 /* RequestProtocols.swift */; };
5616AAF2207CD45E00AC3664 /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5616AAF0207CD45E00AC3664 /* RequestProtocols.swift */; };
@@ -116,6 +139,40 @@
5634B10A1CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */; };
5636E9BC1D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
5636E9BF1D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
563B06AB217EF0CC00B38F35 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06AA217EF0CC00B38F35 /* ValueObservation.swift */; };
563B06AC217EF0CC00B38F35 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06AA217EF0CC00B38F35 /* ValueObservation.swift */; };
563B06AD217EF0CC00B38F35 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06AA217EF0CC00B38F35 /* ValueObservation.swift */; };
563B06BD2185CCD300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06BC2185CCD300B38F35 /* ValueObservationReducerTests.swift */; };
563B06BE2185CCD300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06BC2185CCD300B38F35 /* ValueObservationReducerTests.swift */; };
563B06C32185D29F00B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C02185D29F00B38F35 /* ValueObservationExtentTests.swift */; };
563B06C42185D29F00B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C02185D29F00B38F35 /* ValueObservationExtentTests.swift */; };
563B06C52185D29F00B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C12185D29F00B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06C62185D29F00B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C12185D29F00B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06C72185D29F00B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C22185D29F00B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06C82185D29F00B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C22185D29F00B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06CA2185D2E500B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C92185D2E500B38F35 /* ValueObservationFetchTests.swift */; };
563B06CB2185D2E500B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06C92185D2E500B38F35 /* ValueObservationFetchTests.swift */; };
563B06F721861D8400B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F621861D8300B38F35 /* ValueObservationCountTests.swift */; };
563B06F821861D8400B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F621861D8300B38F35 /* ValueObservationCountTests.swift */; };
563B0705218627F800B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B0704218627F700B38F35 /* ValueObservationRowTests.swift */; };
563B0706218627F800B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B0704218627F700B38F35 /* ValueObservationRowTests.swift */; };
563B071521862C4700B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071421862C4600B38F35 /* ValueObservationRecordTests.swift */; };
563B071621862C4700B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071421862C4600B38F35 /* ValueObservationRecordTests.swift */; };
563B071821862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071721862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563B071921862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071721862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563EF415215F87EB007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF414215F87EB007DAACD /* OrderedDictionary.swift */; };
563EF416215F87EB007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF414215F87EB007DAACD /* OrderedDictionary.swift */; };
563EF417215F87EB007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF414215F87EB007DAACD /* OrderedDictionary.swift */; };
563EF42D2161180D007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF42C2161180D007DAACD /* AssociationAggregate.swift */; };
563EF42E2161180D007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF42C2161180D007DAACD /* AssociationAggregate.swift */; };
563EF42F2161180D007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF42C2161180D007DAACD /* AssociationAggregate.swift */; };
563EF43F216131D1007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF43E216131D1007DAACD /* AssociationAggregateTests.swift */; };
563EF440216131D1007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF43E216131D1007DAACD /* AssociationAggregateTests.swift */; };
563EF44A2161F179007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4492161F179007DAACD /* Inflections.swift */; };
563EF44B2161F179007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4492161F179007DAACD /* Inflections.swift */; };
563EF45321631E21007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45221631E21007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45421631E21007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45221631E21007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45D2163309F007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4492161F179007DAACD /* Inflections.swift */; };
56439B331F4CA1DC0066043F /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB86191BA988F2001F9168 /* FMDatabase.m */; };
56439B341F4CA1DC0066043F /* InsertRecordClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56BB86121BA9886D001F9168 /* InsertRecordClassTests.swift */; };
56439B351F4CA1DC0066043F /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB861B1BA988F2001F9168 /* FMDatabaseAdditions.m */; };
@@ -144,6 +201,27 @@
5644DE6E20F8C32E001FFDDE /* DatabaseValueConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE6C20F8C32E001FFDDE /* DatabaseValueConversion.swift */; };
5644DE6F20F8C32E001FFDDE /* DatabaseValueConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE6C20F8C32E001FFDDE /* DatabaseValueConversion.swift */; };
564A50C81BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift */; };
564CE43121AA901800652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43021AA901800652B19 /* ValueObserver.swift */; };
564CE43221AA901800652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43021AA901800652B19 /* ValueObserver.swift */; };
564CE43321AA901800652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43021AA901800652B19 /* ValueObserver.swift */; };
564CE4D621B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4D521B2DEB500652B19 /* ValueObservation+CompactMap.swift */; };
564CE4D721B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4D521B2DEB500652B19 /* ValueObservation+CompactMap.swift */; };
564CE4D821B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4D521B2DEB500652B19 /* ValueObservation+CompactMap.swift */; };
564CE4E621B2E06700652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E521B2E06700652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4E721B2E06800652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E521B2E06700652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4E921B2E06F00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E821B2E06F00652B19 /* ValueObservationMapTests.swift */; };
564CE4EA21B2E06F00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E821B2E06F00652B19 /* ValueObservationMapTests.swift */; };
564CE52021B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE51F21B3129900652B19 /* ValueObservation+MapReducer.swift */; };
564CE52121B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE51F21B3129900652B19 /* ValueObservation+MapReducer.swift */; };
564CE52221B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE51F21B3129900652B19 /* ValueObservation+MapReducer.swift */; };
564CE59D21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE59621B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE59E21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE59621B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE59F21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE59621B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE5AC21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5AB21B8FAB400652B19 /* DatabaseRegionObservation.swift */; };
564CE5AD21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5AB21B8FAB400652B19 /* DatabaseRegionObservation.swift */; };
564CE5AE21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5AB21B8FAB400652B19 /* DatabaseRegionObservation.swift */; };
564CE5BE21B8FFA300652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5BD21B8FFA300652B19 /* DatabaseRegionObservationTests.swift */; };
564CE5BF21B8FFA300652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5BD21B8FFA300652B19 /* DatabaseRegionObservationTests.swift */; };
564E73DF203D50B9000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73DE203D50B9000C443C /* JoinSupportTests.swift */; };
564E73E0203D50B9000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73DE203D50B9000C443C /* JoinSupportTests.swift */; };
564F9C1E1F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */; };
@@ -847,6 +925,14 @@
560D92441C672C4B00F4F92B /* PersistableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistableRecord.swift; sourceTree = "<group>"; };
560D92461C672C4B00F4F92B /* TableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRecord.swift; sourceTree = "<group>"; };
560FC5101CAEEDF10014AA8E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
5613ED3421A95A5C00DC7A68 /* ValueObservation+Map.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Map.swift"; sourceTree = "<group>"; };
5613ED3E21A95A8B00DC7A68 /* ValueObservation+Combine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Combine.swift"; sourceTree = "<group>"; };
5613ED4321A95B2C00DC7A68 /* ValueReducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValueReducer.swift; sourceTree = "<group>"; };
5613ED4721A95C1200DC7A68 /* ValueObservation+Row.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Row.swift"; sourceTree = "<group>"; };
5613ED4B21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+FetchableRecord.swift"; sourceTree = "<group>"; };
5613ED4F21A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DatabaseValueConvertible.swift"; sourceTree = "<group>"; };
5613ED5321A95DD000DC7A68 /* ValueObservation+Count.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Count.swift"; sourceTree = "<group>"; };
5613EDA521A96A9200DC7A68 /* ValueObservationCombineTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCombineTests.swift; sourceTree = "<group>"; };
561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDecimalNumberTests.swift; sourceTree = "<group>"; };
5616AAF0207CD45E00AC3664 /* RequestProtocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestProtocols.swift; sourceTree = "<group>"; };
562393171DECC02000A6B01F /* RowFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFetchTests.swift; sourceTree = "<group>"; };
@@ -876,10 +962,33 @@
563363F81C960711000BE133 /* PerformanceRealmTests.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceRealmTests.realm; sourceTree = "<group>"; };
5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverSavepointsTests.swift; sourceTree = "<group>"; };
5636E9BB1D22574100B9B05F /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
563B06AA217EF0CC00B38F35 /* ValueObservation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValueObservation.swift; sourceTree = "<group>"; };
563B06BC2185CCD300B38F35 /* ValueObservationReducerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValueObservationReducerTests.swift; sourceTree = "<group>"; };
563B06C02185D29F00B38F35 /* ValueObservationExtentTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationExtentTests.swift; sourceTree = "<group>"; };
563B06C12185D29F00B38F35 /* ValueObservationSchedulingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationSchedulingTests.swift; sourceTree = "<group>"; };
563B06C22185D29F00B38F35 /* ValueObservationReadonlyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationReadonlyTests.swift; sourceTree = "<group>"; };
563B06C92185D2E500B38F35 /* ValueObservationFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationFetchTests.swift; sourceTree = "<group>"; };
563B06F621861D8300B38F35 /* ValueObservationCountTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCountTests.swift; sourceTree = "<group>"; };
563B0704218627F700B38F35 /* ValueObservationRowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRowTests.swift; sourceTree = "<group>"; };
563B071421862C4600B38F35 /* ValueObservationRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRecordTests.swift; sourceTree = "<group>"; };
563B071721862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationDatabaseValueConvertibleTests.swift; sourceTree = "<group>"; };
563EF414215F87EB007DAACD /* OrderedDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderedDictionary.swift; sourceTree = "<group>"; };
563EF42C2161180D007DAACD /* AssociationAggregate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociationAggregate.swift; sourceTree = "<group>"; };
563EF43E216131D1007DAACD /* AssociationAggregateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociationAggregateTests.swift; sourceTree = "<group>"; };
563EF4492161F179007DAACD /* Inflections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Inflections.swift; sourceTree = "<group>"; };
563EF45221631E21007DAACD /* QueryInterfacePromiseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfacePromiseTests.swift; sourceTree = "<group>"; };
56439B501F4CA1DC0066043F /* GRDBOSXPerformanceComparisonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXPerformanceComparisonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAfterNextTransactionCommitTests.swift; sourceTree = "<group>"; };
5644DE6C20F8C32E001FFDDE /* DatabaseValueConversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseValueConversion.swift; sourceTree = "<group>"; };
564A50C61BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCollationTests.swift; sourceTree = "<group>"; };
564CE43021AA901800652B19 /* ValueObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValueObserver.swift; sourceTree = "<group>"; };
564CE4D521B2DEB500652B19 /* ValueObservation+CompactMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+CompactMap.swift"; sourceTree = "<group>"; };
564CE4E521B2E06700652B19 /* ValueObservationCompactMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCompactMapTests.swift; sourceTree = "<group>"; };
564CE4E821B2E06F00652B19 /* ValueObservationMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationMapTests.swift; sourceTree = "<group>"; };
564CE51F21B3129900652B19 /* ValueObservation+MapReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+MapReducer.swift"; sourceTree = "<group>"; };
564CE59621B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DistinctUntilChanged.swift"; sourceTree = "<group>"; };
564CE5AB21B8FAB400652B19 /* DatabaseRegionObservation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservation.swift; sourceTree = "<group>"; };
564CE5BD21B8FFA300652B19 /* DatabaseRegionObservationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservationTests.swift; sourceTree = "<group>"; };
564E73DE203D50B9000C443C /* JoinSupportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinSupportTests.swift; sourceTree = "<group>"; };
564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAggregateTests.swift; sourceTree = "<group>"; };
564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = "<group>"; };
@@ -1056,8 +1165,8 @@
56B6EF55208CB4E3002F0ACB /* ColumnExpressionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColumnExpressionTests.swift; sourceTree = "<group>"; };
56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = "<group>"; };
56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.1.2/Realm.framework"; sourceTree = "<group>"; };
56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.1.2/RealmSwift.framework"; sourceTree = "<group>"; };
56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.2.1/Realm.framework"; sourceTree = "<group>"; };
56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.2.1/RealmSwift.framework"; sourceTree = "<group>"; };
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.xcconfig; sourceTree = "<group>"; };
56B9649C1DA51B4C0002DA19 /* FTS5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5.swift; sourceTree = "<group>"; };
56B964B01DA51D010002DA19 /* FTS5TokenizerDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5TokenizerDescriptor.swift; sourceTree = "<group>"; };
@@ -1299,6 +1408,25 @@
name = PersistableRecord;
sourceTree = "<group>";
};
5613ED4221A95AFB00DC7A68 /* ValueObservation */ = {
isa = PBXGroup;
children = (
563B06AA217EF0CC00B38F35 /* ValueObservation.swift */,
5613ED3E21A95A8B00DC7A68 /* ValueObservation+Combine.swift */,
564CE4D521B2DEB500652B19 /* ValueObservation+CompactMap.swift */,
5613ED5321A95DD000DC7A68 /* ValueObservation+Count.swift */,
5613ED4F21A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */,
564CE59621B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift */,
5613ED4B21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift */,
5613ED3421A95A5C00DC7A68 /* ValueObservation+Map.swift */,
564CE51F21B3129900652B19 /* ValueObservation+MapReducer.swift */,
5613ED4721A95C1200DC7A68 /* ValueObservation+Row.swift */,
564CE43021AA901800652B19 /* ValueObserver.swift */,
5613ED4321A95B2C00DC7A68 /* ValueReducer.swift */,
);
path = ValueObservation;
sourceTree = "<group>";
};
56176C581EACC2D8000F3F2B /* GRDBTests */ = {
isa = PBXGroup;
children = (
@@ -1312,6 +1440,7 @@
56300B5C1C53C38F005A543B /* QueryInterface */,
56A238251B9C74A90082EB20 /* Record */,
56176C9F1EACEE15000F3F2B /* Support */,
563B06BF2185CD1700B38F35 /* ValueObservation */,
);
path = GRDBTests;
sourceTree = "<group>";
@@ -1380,6 +1509,7 @@
56300B601C53C42C005A543B /* FetchableRecord+QueryInterfaceRequestTests.swift */,
56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */,
5698AC021D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift */,
563EF45221631E21007DAACD /* QueryInterfacePromiseTests.swift */,
56300B5D1C53C38F005A543B /* QueryInterfaceRequestTests.swift */,
56300B841C54DC95005A543B /* Record+QueryInterfaceRequestTests.swift */,
566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */,
@@ -1431,9 +1561,29 @@
name = DatabaseQueue;
sourceTree = "<group>";
};
563B06BF2185CD1700B38F35 /* ValueObservation */ = {
isa = PBXGroup;
children = (
5613EDA521A96A9200DC7A68 /* ValueObservationCombineTests.swift */,
564CE4E521B2E06700652B19 /* ValueObservationCompactMapTests.swift */,
563B06F621861D8300B38F35 /* ValueObservationCountTests.swift */,
563B071721862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */,
563B06C02185D29F00B38F35 /* ValueObservationExtentTests.swift */,
563B06C92185D2E500B38F35 /* ValueObservationFetchTests.swift */,
564CE4E821B2E06F00652B19 /* ValueObservationMapTests.swift */,
563B06C22185D29F00B38F35 /* ValueObservationReadonlyTests.swift */,
563B071421862C4600B38F35 /* ValueObservationRecordTests.swift */,
563B06BC2185CCD300B38F35 /* ValueObservationReducerTests.swift */,
563B0704218627F700B38F35 /* ValueObservationRowTests.swift */,
563B06C12185D29F00B38F35 /* ValueObservationSchedulingTests.swift */,
);
name = ValueObservation;
sourceTree = "<group>";
};
5653EABF20944B1300F46237 /* Association */ = {
isa = PBXGroup;
children = (
563EF43E216131D1007DAACD /* AssociationAggregateTests.swift */,
5653EAD420944B4E00F46237 /* AssociationBelongsToDecodableRecordTests.swift */,
5653EACE20944B4D00F46237 /* AssociationBelongsToFetchableRecordTests.swift */,
5653EAC720944B4C00F46237 /* AssociationBelongsToRowScopeTests.swift */,
@@ -1456,6 +1606,7 @@
isa = PBXGroup;
children = (
5653EAFA20944C7B00F46237 /* Association.swift */,
563EF42C2161180D007DAACD /* AssociationAggregate.swift */,
5653EAFE20944C7C00F46237 /* AssociationQuery.swift */,
5653EAFC20944C7B00F46237 /* AssociationRequest.swift */,
5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */,
@@ -1470,10 +1621,12 @@
5659F4861EA8D94E004A4992 /* Utils */ = {
isa = PBXGroup;
children = (
5659F4871EA8D94E004A4992 /* Utils.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
563EF4492161F179007DAACD /* Inflections.swift */,
563EF414215F87EB007DAACD /* OrderedDictionary.swift */,
5659F4971EA8D989004A4992 /* Pool.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
5659F49F1EA8D997004A4992 /* Result.swift */,
5659F4871EA8D94E004A4992 /* Utils.swift */,
);
path = Utils;
sourceTree = "<group>";
@@ -1578,6 +1731,7 @@
560A37A91C90084600949E71 /* DatabasePool */,
563363BB1C93FD32000BE133 /* DatabaseQueue */,
56EA86931C91DFE7002BB4DF /* DatabaseReaderTests.swift */,
564CE5BD21B8FFA300652B19 /* DatabaseRegionObservationTests.swift */,
56C3F7521CF9F12400F6A361 /* DatabaseSavepointTests.swift */,
566A8424204120B700E50BFD /* DatabaseSnapshotTests.swift */,
56A238131B9C74A90082EB20 /* DatabaseTests.swift */,
@@ -1675,6 +1829,7 @@
56A238741B9C75030082EB20 /* DatabaseQueue.swift */,
563363BF1C942C04000BE133 /* DatabaseReader.swift */,
569EF0E1200D2D8400A9FA45 /* DatabaseRegion.swift */,
564CE5AB21B8FAB400652B19 /* DatabaseRegionObservation.swift */,
5695311E1C907A8C00CF1A2B /* DatabaseSchemaCache.swift */,
566A84192041146100E50BFD /* DatabaseSnapshot.swift */,
56A238751B9C75030082EB20 /* DatabaseValue.swift */,
@@ -1894,6 +2049,7 @@
56A2389F1B9C753B0082EB20 /* Record */,
DC37743319C8CFCE004FCF85 /* Supporting Files */,
5659F4861EA8D94E004A4992 /* Utils */,
5613ED4221A95AFB00DC7A68 /* ValueObservation */,
);
path = GRDB;
sourceTree = "<group>";
@@ -2330,25 +2486,32 @@
56D51D061EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
565490CE1D5AE252005622CB /* NSNull.swift in Sources */,
565490E41D5AE252005622CB /* TableRecord.swift in Sources */,
564CE5AE21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */,
565490CF1D5AE252005622CB /* NSNumber.swift in Sources */,
566475C01D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
56CEB51F1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
565490E21D5AE252005622CB /* Record.swift in Sources */,
5656BF5120C723E300F98521 /* QueryOrdering.swift in Sources */,
565490C11D5AE236005622CB /* FetchRequest.swift in Sources */,
5613ED4621A95B2C00DC7A68 /* ValueReducer.swift in Sources */,
5698AD1C1DAAD17F0056AF8C /* FTS5Tokenizer.swift in Sources */,
56CEB5171EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
56B964B71DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */,
5613ED5221A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5653EB0B20944C7C00F46237 /* Association.swift in Sources */,
564CE59F21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
56F5ABDA1D814330001F60CB /* NSData.swift in Sources */,
56D121601ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
564F9C341F07611900877A00 /* DatabaseFunction.swift in Sources */,
566475A81D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
5659F4961EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
5613ED3721A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */,
5659F48E1EA8D94E004A4992 /* Utils.swift in Sources */,
564CE43321AA901800652B19 /* ValueObserver.swift in Sources */,
56CEB5671EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
5653EB272094A14400F46237 /* QueryInterfaceRequest+Association.swift in Sources */,
565490B91D5AE236005622CB /* DatabasePool.swift in Sources */,
563B06AD217EF0CC00B38F35 /* ValueObservation.swift in Sources */,
5674A6EF1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */,
56CEB5601EAA359A00BFAF62 /* SQLOrdering.swift in Sources */,
@@ -2357,17 +2520,23 @@
565490D91D5AE252005622CB /* Migration.swift in Sources */,
56CEB5001EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
5698AD271DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
5613ED4121A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */,
5653EB1120944C7C00F46237 /* AssociationRequest.swift in Sources */,
C96C0F2D2084A45A006B2981 /* SQLiteDateParser.swift in Sources */,
566A841C2041146100E50BFD /* DatabaseSnapshot.swift in Sources */,
5613ED4A21A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */,
565490D51D5AE252005622CB /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
565490C51D5AE236005622CB /* SerializedDatabase.swift in Sources */,
56F3E7691E67F8C100BF0F01 /* Fixits-0.101.1.swift in Sources */,
5698AC7E1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
564CE52221B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */,
5653EB1A20944C7C00F46237 /* ForeignKey.swift in Sources */,
5698AC3D1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
563EF45D2163309F007DAACD /* Inflections.swift in Sources */,
565490BF1D5AE236005622CB /* DatabaseValueConvertible.swift in Sources */,
566B91191FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
5613ED4E21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
5613ED5621A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */,
56CEB5591EAA359A00BFAF62 /* SQLExpression.swift in Sources */,
5674A6FF1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */,
56E06F181E85906E008AE2A4 /* Fixits-0.102.0.swift in Sources */,
@@ -2421,14 +2590,17 @@
565490DE1D5AE252005622CB /* QueryInterfaceQuery.swift in Sources */,
56F5ABDD1D814330001F60CB /* UUID.swift in Sources */,
565490CB1D5AE252005622CB /* (null) in Sources */,
563EF417215F87EB007DAACD /* OrderedDictionary.swift in Sources */,
565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */,
5653EB1720944C7C00F46237 /* AssociationQuery.swift in Sources */,
565490B81D5AE236005622CB /* DatabaseError.swift in Sources */,
564CE4D821B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */,
56BF6D3C1DEF47DA006039A3 /* Fixits-0-90-1.swift in Sources */,
56DAA2E11DE9C827006E10C8 /* Cursor.swift in Sources */,
5653EB0520944C7C00F46237 /* BelongsToAssociation.swift in Sources */,
5644DE6F20F8C32E001FFDDE /* DatabaseValueConversion.swift in Sources */,
565490BC1D5AE236005622CB /* DatabaseSchemaCache.swift in Sources */,
563EF42F2161180D007DAACD /* AssociationAggregate.swift in Sources */,
565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */,
565490CD1D5AE252005622CB /* Date.swift in Sources */,
5653EB0820944C7C00F46237 /* ForeignKeyRequest.swift in Sources */,
@@ -2458,6 +2630,7 @@
files = (
56BF6D401DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5636E9BF1D22574100B9B05F /* FetchRequest.swift in Sources */,
563EF42E2161180D007DAACD /* AssociationAggregate.swift in Sources */,
56BB6EAC1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
56300B791C53F592005A543B /* QueryInterfaceRequest.swift in Sources */,
56CEB5561EAA359A00BFAF62 /* SQLExpression.swift in Sources */,
@@ -2472,7 +2645,9 @@
56CEB5481EAA359A00BFAF62 /* Column.swift in Sources */,
5653EB262094A14400F46237 /* QueryInterfaceRequest+Association.swift in Sources */,
5605F1641C672E4000235C62 /* Date.swift in Sources */,
5613ED4921A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */,
566B91361FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
564CE43221AA901800652B19 /* ValueObserver.swift in Sources */,
5605F1721C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
56CEB5141EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
566475CF1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */,
@@ -2483,6 +2658,7 @@
5698AC3A1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
5664759D1D97D8A000FF74B8 /* SQLCollection.swift in Sources */,
5674048A1CEF84C8003ED5CC /* RowAdapter.swift in Sources */,
563EF416215F87EB007DAACD /* OrderedDictionary.swift in Sources */,
563363C51C942C37000BE133 /* DatabaseWriter.swift in Sources */,
5698AD1B1DAAD17D0056AF8C /* FTS5Tokenizer.swift in Sources */,
56F3E7661E67F8C100BF0F01 /* Fixits-0.101.1.swift in Sources */,
@@ -2504,6 +2680,7 @@
56D51D031EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
5653EB1620944C7C00F46237 /* AssociationQuery.swift in Sources */,
560D924C1C672C4B00F4F92B /* TableRecord.swift in Sources */,
564CE52121B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */,
5653EC132098738B00F46237 /* SQLGenerationContext.swift in Sources */,
5657AB121D10899D006283EF /* URL.swift in Sources */,
5616AAF2207CD45E00AC3664 /* RequestProtocols.swift in Sources */,
@@ -2522,6 +2699,9 @@
566B91161FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
56FC987B1D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */,
56A238881B9C75030082EB20 /* Row.swift in Sources */,
5613ED4D21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
564CE4D721B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */,
563EF44B2161F179007DAACD /* Inflections.swift in Sources */,
56CEB4F41EAA2EFA00BFAF62 /* FetchableRecord.swift in Sources */,
569531201C907A8C00CF1A2B /* DatabaseSchemaCache.swift in Sources */,
5605F15E1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */,
@@ -2533,6 +2713,7 @@
5605F1661C672E4000235C62 /* NSNull.swift in Sources */,
569EF0E3200D2D8400A9FA45 /* DatabaseRegion.swift in Sources */,
56A238841B9C75030082EB20 /* DatabaseQueue.swift in Sources */,
563B06AC217EF0CC00B38F35 /* ValueObservation.swift in Sources */,
5698AC7B1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
56A238821B9C75030082EB20 /* DatabaseError.swift in Sources */,
56D1215D1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
@@ -2542,15 +2723,21 @@
5644DE6E20F8C32E001FFDDE /* DatabaseValueConversion.swift in Sources */,
C96C0F2C2084A459006B2981 /* SQLiteDateParser.swift in Sources */,
5605F1681C672E4000235C62 /* NSNumber.swift in Sources */,
5613ED5521A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */,
564CE5AD21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */,
56CEB5041EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
5656BF5020C723E300F98521 /* QueryOrdering.swift in Sources */,
5605F1741C672E4000235C62 /* StandardLibrary.swift in Sources */,
560D92481C672C4B00F4F92B /* PersistableRecord.swift in Sources */,
5613ED4521A95B2C00DC7A68 /* ValueReducer.swift in Sources */,
5613ED5121A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
560D92431C672C3E00F4F92B /* StatementColumnConvertible.swift in Sources */,
5613ED3621A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */,
566475A51D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
5653EB0720944C7C00F46237 /* ForeignKeyRequest.swift in Sources */,
5657AABC1D107001006283EF /* NSData.swift in Sources */,
31A778841C6A4E0600F507F6 /* FetchedRecordsController.swift in Sources */,
5613ED4021A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */,
56A238861B9C75030082EB20 /* DatabaseValue.swift in Sources */,
56CEB55D1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */,
566B91261FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
@@ -2558,6 +2745,7 @@
56CEB5641EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56873BEF1F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
564F9C311F07611600877A00 /* DatabaseFunction.swift in Sources */,
564CE59E21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
56B964A01DA51B4C0002DA19 /* FTS5.swift in Sources */,
5674A6F01F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
);
@@ -2567,6 +2755,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
563B06C82185D29F00B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
6340BF841E5E3F7900832805 /* RecordPersistenceConflictPolicy.swift in Sources */,
56300B861C54DC95005A543B /* Record+QueryInterfaceRequestTests.swift in Sources */,
56F26C1C1CEE3F32007969C4 /* RowAdapterTests.swift in Sources */,
@@ -2575,6 +2764,7 @@
56A238561B9C74A90082EB20 /* RecordPrimaryKeyNoneTests.swift in Sources */,
562EA8331F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
563363BE1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */,
563EF45421631E21007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
56A238501B9C74A90082EB20 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
564448871EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
56A238461B9C74A90082EB20 /* RowFromDictionaryTests.swift in Sources */,
@@ -2593,12 +2783,14 @@
56A2385A1B9C74A90082EB20 /* RecordPrimaryKeySingleTests.swift in Sources */,
562756471E963AAC0035B653 /* DatabaseWriterTests.swift in Sources */,
569531381C919DF700CF1A2B /* DatabasePoolFunctionTests.swift in Sources */,
563B06F821861D8400B38F35 /* ValueObservationCountTests.swift in Sources */,
56A238481B9C74A90082EB20 /* RowCopiedFromStatementTests.swift in Sources */,
56EA63C6209C7CE3009715B8 /* DerivableRequestTests.swift in Sources */,
5674A71A1F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
5698AC071D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */,
56C3F7561CF9F12400F6A361 /* DatabaseSavepointTests.swift in Sources */,
56B021CD1D8C0D3900B239BB /* MutablePersistableRecordPersistenceConflictPolicyTests.swift in Sources */,
563B0706218627F800B38F35 /* ValueObservationRowTests.swift in Sources */,
569531271C9087B700CF1A2B /* DatabaseQueueSchemaCacheTests.swift in Sources */,
56B14E831D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */,
562393341DEDFC5700A6B01F /* AnyCursorTests.swift in Sources */,
@@ -2626,11 +2818,13 @@
567F45AC1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
5657AB621D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
5657AB6A1D108BA9006283EF /* FoundationURLTests.swift in Sources */,
563B06C42185D29F00B38F35 /* ValueObservationExtentTests.swift in Sources */,
564FCE5F20F7E11B00202B90 /* DatabaseValueConversionErrorTests.swift in Sources */,
5653EADF20944B4F00F46237 /* AssociationHasOneSQLDerivationTests.swift in Sources */,
56F3E74D1E66F83A00BF0F01 /* ResultCodeTests.swift in Sources */,
56EB0AB31BCD787300A3DC55 /* DataMemoryTests.swift in Sources */,
56B6EF57208CB4E3002F0ACB /* ColumnExpressionTests.swift in Sources */,
563B071621862C4700B38F35 /* ValueObservationRecordTests.swift in Sources */,
56176C7F1EACCD2F000F3F2B /* EncryptionTests.swift in Sources */,
56741EAC1E66A8B3003E422D /* FetchRequestTests.swift in Sources */,
5672DE5C1CDB72520022BA81 /* DatabaseQueueBackupTests.swift in Sources */,
@@ -2641,6 +2835,7 @@
564E73E0203D50B9000C443C /* JoinSupportTests.swift in Sources */,
5674A7121F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
5657AB521D108BA9006283EF /* FoundationNSNumberTests.swift in Sources */,
563B071921862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5665F85E203EE6030084C6C0 /* ColumnInfoTests.swift in Sources */,
56A238441B9C74A90082EB20 /* RawRepresentable+DatabaseValueConvertibleTests.swift in Sources */,
560A37AC1C90085D00949E71 /* DatabasePoolConcurrencyTests.swift in Sources */,
@@ -2650,7 +2845,9 @@
565D5D721BBC694D00DC9BD4 /* Row+FoundationTests.swift in Sources */,
5623936D1DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
567A80571D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
563B06CB2185D2E500B38F35 /* ValueObservationFetchTests.swift in Sources */,
5623935B1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
5613EDA721A96A9300DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5674A72D1F30A9090095F066 /* FetchableRecordDecodableTests.swift in Sources */,
566A84412041914000E50BFD /* MutablePersistableRecordChangesTests.swift in Sources */,
56176C701EACCCC9000F3F2B /* FTS5WrapperTokenizerTests.swift in Sources */,
@@ -2678,6 +2875,7 @@
56A238621B9C74A90082EB20 /* RecordEditedTests.swift in Sources */,
5653EAE120944B4F00F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
5653EAE720944B4F00F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
563EF440216131D1007DAACD /* AssociationAggregateTests.swift in Sources */,
5695312A1C908A5B00CF1A2B /* DatabasePoolSchemaCacheTests.swift in Sources */,
5653EADB20944B4F00F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
5698ACA21DA4B0430056AF8C /* FTS4TableBuilderTests.swift in Sources */,
@@ -2685,7 +2883,9 @@
56A238401B9C74A90082EB20 /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
564F9C221F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
56A8C2481D1918F00096E9D4 /* FoundationUUIDTests.swift in Sources */,
564CE5BF21B8FFA300652B19 /* DatabaseRegionObservationTests.swift in Sources */,
5653EAEF20944B4F00F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
564CE4E721B2E06800652B19 /* ValueObservationCompactMapTests.swift in Sources */,
56A2383C1B9C74A90082EB20 /* DatabaseErrorTests.swift in Sources */,
5690C32A1D23E6D800E59934 /* FoundationDateComponentsTests.swift in Sources */,
5657AB3A1D108BA9006283EF /* FoundationDataTests.swift in Sources */,
@@ -2704,12 +2904,14 @@
5623931C1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
5653EAD720944B4F00F46237 /* AssociationChainRowScopesTests.swift in Sources */,
562393641DEE06D300A6B01F /* CursorTests.swift in Sources */,
563B06C62185D29F00B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5657AB5A1D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
56300B6C1C53D3E8005A543B /* TableRecord+QueryInterfaceRequestTests.swift in Sources */,
5674A7231F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
56F0B9921B6001C600A2F135 /* FoundationNSDateTests.swift in Sources */,
56A238381B9C74A90082EB20 /* DatabaseTests.swift in Sources */,
5653EAED20944B4F00F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE4EA21B2E06F00652B19 /* ValueObservationMapTests.swift in Sources */,
56300B5F1C53C38F005A543B /* QueryInterfaceRequestTests.swift in Sources */,
5634B10A1CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */,
560C97C81BFD0B8400BF8471 /* DatabaseFunctionTests.swift in Sources */,
@@ -2717,6 +2919,7 @@
56A2383A1B9C74A90082EB20 /* DatabaseQueueInMemoryTests.swift in Sources */,
56A5E40A1BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift in Sources */,
5653EAF520944B4F00F46237 /* AssociationParallelSQLTests.swift in Sources */,
563B06BE2185CCD300B38F35 /* ValueObservationReducerTests.swift in Sources */,
56FF455A1D2CDA5200F21EF9 /* RecordUniqueIndexTests.swift in Sources */,
56B7F42A1BE14A1900E39BBF /* CGFloatTests.swift in Sources */,
5605F1881C69111300235C62 /* DatabaseRegionTests.swift in Sources */,
@@ -2732,6 +2935,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
563B06C72185D29F00B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
6340BF801E5E3F7900832805 /* RecordPersistenceConflictPolicy.swift in Sources */,
56D496771D81309E008276D7 /* RecordInitializersTests.swift in Sources */,
56D496651D813076008276D7 /* DatabaseMigratorTests.swift in Sources */,
@@ -2740,6 +2944,7 @@
56D496B31D8133E3008276D7 /* IndexInfoTests.swift in Sources */,
562EA82F1F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5698AC961DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
563EF45321631E21007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
56D4966D1D81309E008276D7 /* RecordMinimalPrimaryKeySingleTests.swift in Sources */,
564448831EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
56D496811D813131008276D7 /* TransactionObserverSavepointsTests.swift in Sources */,
@@ -2758,12 +2963,14 @@
56D4968C1D81316E008276D7 /* RawRepresentable+DatabaseValueConvertibleTests.swift in Sources */,
56D496981D81317B008276D7 /* DatabaseValueTests.swift in Sources */,
56D4966B1D81309E008276D7 /* MutablePersistableRecordDeleteTests.swift in Sources */,
563B06F721861D8400B38F35 /* ValueObservationCountTests.swift in Sources */,
56D4965B1D81304E008276D7 /* FoundationNSDecimalNumberTests.swift in Sources */,
562756431E963AAC0035B653 /* DatabaseWriterTests.swift in Sources */,
56EA63C5209C7CE3009715B8 /* DerivableRequestTests.swift in Sources */,
56D496BF1D8135D4008276D7 /* TableDefinitionTests.swift in Sources */,
5674A7171F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
56D496801D813131008276D7 /* StatementColumnConvertibleFetchTests.swift in Sources */,
563B0705218627F800B38F35 /* ValueObservationRowTests.swift in Sources */,
56D4966E1D81309E008276D7 /* RecordPrimaryKeyMultipleTests.swift in Sources */,
56D496891D81316E008276D7 /* DatabaseValueConvertibleFetchTests.swift in Sources */,
56D4967C1D8130DB008276D7 /* CGFloatTests.swift in Sources */,
@@ -2791,11 +2998,13 @@
56D4968A1D81316E008276D7 /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
56D496601D81304E008276D7 /* FoundationNSUUIDTests.swift in Sources */,
567F45A81F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
563B06C32185D29F00B38F35 /* ValueObservationExtentTests.swift in Sources */,
56D4968D1D81316E008276D7 /* DatabaseFunctionTests.swift in Sources */,
564FCE5E20F7E11B00202B90 /* DatabaseValueConversionErrorTests.swift in Sources */,
5653EADE20944B4F00F46237 /* AssociationHasOneSQLDerivationTests.swift in Sources */,
56D496661D813086008276D7 /* QueryInterfaceRequestTests.swift in Sources */,
56F3E7491E66F83A00BF0F01 /* ResultCodeTests.swift in Sources */,
563B071521862C4700B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF56208CB4E3002F0ACB /* ColumnExpressionTests.swift in Sources */,
5698ACD71DA925420056AF8C /* RowTestCase.swift in Sources */,
56176C7D1EACCD2D000F3F2B /* EncryptionTests.swift in Sources */,
@@ -2806,6 +3015,7 @@
56D496581D81304E008276D7 /* FoundationDateTests.swift in Sources */,
562205F31E420E47005860AC /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
564E73DF203D50B9000C443C /* JoinSupportTests.swift in Sources */,
563B071821862F4C00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5674A70F1F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
56D496711D81309E008276D7 /* RecordPrimaryKeySingleTests.swift in Sources */,
5665F85D203EE6030084C6C0 /* ColumnInfoTests.swift in Sources */,
@@ -2815,7 +3025,9 @@
5653EAF220944B4F00F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
56D496851D813147008276D7 /* StatementArgumentsTests.swift in Sources */,
56D496B81D813465008276D7 /* DataMemoryTests.swift in Sources */,
563B06CA2185D2E500B38F35 /* ValueObservationFetchTests.swift in Sources */,
56D496541D812F5B008276D7 /* SQLExpressionLiteralTests.swift in Sources */,
5613EDA621A96A9300DC7A68 /* ValueObservationCombineTests.swift in Sources */,
56D496961D81317B008276D7 /* PersistableRecordTests.swift in Sources */,
5698AC9E1DA4B0430056AF8C /* FTS4TableBuilderTests.swift in Sources */,
5674A72A1F30A9090095F066 /* FetchableRecordDecodableTests.swift in Sources */,
@@ -2843,6 +3055,7 @@
56A5EF0F1EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
56D496B61D813434008276D7 /* DatabaseRegionTests.swift in Sources */,
5653EAE020944B4F00F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
563EF43F216131D1007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EAE620944B4F00F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
562393181DECC02000A6B01F /* RowFetchTests.swift in Sources */,
5653EADA20944B4F00F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
@@ -2850,7 +3063,9 @@
56D496741D81309E008276D7 /* RecordCopyTests.swift in Sources */,
56D496791D81309E008276D7 /* RecordWithColumnNameManglingTests.swift in Sources */,
56D4966C1D81309E008276D7 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
564CE5BE21B8FFA300652B19 /* DatabaseRegionObservationTests.swift in Sources */,
564F9C1E1F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
564CE4E621B2E06700652B19 /* ValueObservationCompactMapTests.swift in Sources */,
5653EAEE20944B4F00F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
56D496861D813147008276D7 /* UpdateStatementTests.swift in Sources */,
56D4965D1D81304E008276D7 /* FoundationNSNumberTests.swift in Sources */,
@@ -2869,12 +3084,14 @@
56D496B41D8133F8008276D7 /* DatabaseTests.swift in Sources */,
56D496951D81317B008276D7 /* MutablePersistableRecordTests.swift in Sources */,
5653EAD620944B4F00F46237 /* AssociationChainRowScopesTests.swift in Sources */,
563B06C52185D29F00B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5698AC801DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */,
56D496821D813131008276D7 /* TransactionObserverTests.swift in Sources */,
56D496941D81317B008276D7 /* SchedulingWatchdogTests.swift in Sources */,
5674A7201F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
56D496551D812F83008276D7 /* FoundationDataTests.swift in Sources */,
56D4966A1D813086008276D7 /* TableRecord+QueryInterfaceRequestTests.swift in Sources */,
564CE4E921B2E06F00652B19 /* ValueObservationMapTests.swift in Sources */,
5653EAEC20944B4F00F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
562206071E420EA4005860AC /* DatabasePoolConcurrencyTests.swift in Sources */,
5698ACB61DA6285E0056AF8C /* FTS3TokenizerTests.swift in Sources */,
@@ -2882,6 +3099,7 @@
5653EAD820944B4F00F46237 /* AssociationBelongsToRowScopeTests.swift in Sources */,
562205F11E420E47005860AC /* DatabasePoolReleaseMemoryTests.swift in Sources */,
5653EAF420944B4F00F46237 /* AssociationParallelSQLTests.swift in Sources */,
563B06BD2185CCD300B38F35 /* ValueObservationReducerTests.swift in Sources */,
56D496971D81317B008276D7 /* DatabaseReaderTests.swift in Sources */,
56D496911D81316E008276D7 /* RowFromStatementTests.swift in Sources */,
56071A411DB54ED000CA6E47 /* FetchedRecordsControllerTests.swift in Sources */,
@@ -2898,12 +3116,18 @@
buildActionMask = 2147483647;
files = (
56873BEC1F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
563EF42D2161180D007DAACD /* AssociationAggregate.swift in Sources */,
5613ED4C21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
56BF6D3D1DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5616AAF1207CD45E00AC3664 /* RequestProtocols.swift in Sources */,
5613ED4421A95B2C00DC7A68 /* ValueReducer.swift in Sources */,
5636E9BC1D22574100B9B05F /* FetchRequest.swift in Sources */,
56BB6EA91D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
563EF44A2161F179007DAACD /* Inflections.swift in Sources */,
566B91091FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
566B91231FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
5613ED3F21A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */,
563B06AB217EF0CC00B38F35 /* ValueObservation.swift in Sources */,
56CEB5111EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
5659F4901EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
566A841A2041146100E50BFD /* DatabaseSnapshot.swift in Sources */,
@@ -2911,22 +3135,27 @@
56CEB4F11EAA2EFA00BFAF62 /* FetchableRecord.swift in Sources */,
56300B781C53F592005A543B /* QueryInterfaceRequest.swift in Sources */,
5605F18D1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */,
5613ED5421A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */,
566B91331FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
56D1215A1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
566475D31D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
56CEB5611EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56CEB4FA1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
564CE59D21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
5698AD351DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
566B91131FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
5605F1591C672E4000235C62 /* CGFloat.swift in Sources */,
5674A7031F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
564CE52021B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */,
5659F4A01EA8D997004A4992 /* Result.swift in Sources */,
5605F1631C672E4000235C62 /* Date.swift in Sources */,
5605F1711C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
56A2387B1B9C75030082EB20 /* Configuration.swift in Sources */,
566475CC1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */,
5698AC371D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
563EF415215F87EB007DAACD /* OrderedDictionary.swift in Sources */,
564F9C2D1F075DD200877A00 /* DatabaseFunction.swift in Sources */,
564CE5AC21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */,
5659F4981EA8D989004A4992 /* Pool.swift in Sources */,
5674A6F41F307F600095F066 /* PersistableRecord+Encodable.swift in Sources */,
56CEB54C1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */,
@@ -2942,6 +3171,7 @@
5653EB252094A14400F46237 /* QueryInterfaceRequest+Association.swift in Sources */,
5605F1691C672E4000235C62 /* NSString.swift in Sources */,
560D92401C672C3E00F4F92B /* DatabaseValueConvertible.swift in Sources */,
564CE4D621B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */,
56A8C2301D1914540096E9D4 /* UUID.swift in Sources */,
56CEB5011EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
56CEB55A1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */,
@@ -2955,13 +3185,16 @@
5671FC201DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
56A238A41B9C753B0082EB20 /* Record.swift in Sources */,
56CEB5451EAA359A00BFAF62 /* Column.swift in Sources */,
5613ED5021A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5657AB0F1D10899D006283EF /* URL.swift in Sources */,
560D924B1C672C4B00F4F92B /* TableRecord.swift in Sources */,
5613ED4821A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */,
56DAA2DB1DE9C827006E10C8 /* Cursor.swift in Sources */,
5674A6EB1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
560A37A41C8F625000949E71 /* DatabasePool.swift in Sources */,
56B7F43A1BEB42D500E39BBF /* Migration.swift in Sources */,
5605F1931C6B1A8700235C62 /* QueryInterfaceQuery.swift in Sources */,
5613ED3521A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */,
566B912B1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
56A2388B1B9C75030082EB20 /* Statement.swift in Sources */,
5690C3401D23E82A00E59934 /* Data.swift in Sources */,
@@ -2976,6 +3209,7 @@
56B964B91DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */,
5653EB1520944C7C00F46237 /* AssociationQuery.swift in Sources */,
563363C01C942C04000BE133 /* DatabaseReader.swift in Sources */,
564CE43121AA901800652B19 /* ValueObserver.swift in Sources */,
5605F1651C672E4000235C62 /* NSNull.swift in Sources */,
56CEB5191EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
5653EB1820944C7C00F46237 /* ForeignKey.swift in Sources */,
@@ -3090,7 +3324,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1.2",
"$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.2.1",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
@@ -3113,7 +3347,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1.2",
"$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.2.1",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
+1 -1
View File
@@ -20,7 +20,7 @@
location = "group:Issue156.playground">
</FileRef>
<FileRef
location = "group:/Users/groue/Documents/git/groue/GRDB.swift/Playgrounds/CustomizedDecodingOfDatabaseRows.playground">
location = "group:CustomizedDecodingOfDatabaseRows.playground">
</FileRef>
<FileRef
location = "group:Associations.playground">
+28 -1
View File
@@ -1,4 +1,5 @@
import Foundation
import Dispatch
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
@@ -136,11 +137,28 @@ public struct Configuration {
/// Default: 5
public var maximumReaderCount: Int = 5
/// The quality of service class for the work performed by the database.
///
/// The quality of service is ignored if you supply a target queue.
///
/// Default: .default (.unspecified on macOS < 10.10)
public var qos: DispatchQoS
/// The target queue for the work performed by the database.
///
/// Default: nil
public var targetQueue: DispatchQueue? = nil
// MARK: - Factory Configuration
/// Creates a factory configuration
public init() { }
public init() {
if #available(OSX 10.10, *) {
qos = .default
} else {
qos = .unspecified
}
}
// MARK: - Not Public
@@ -153,6 +171,15 @@ public struct Configuration {
let readWriteFlags = readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
return threadingMode.SQLiteOpenFlags | readWriteFlags
}
func makeDispatchQueue(defaultLabel: String, purpose: String? = nil) -> DispatchQueue {
let label = (self.label ?? defaultLabel) + (purpose.map { "." + $0 } ?? "")
if let targetQueue = targetQueue {
return DispatchQueue(label: label, target: targetQueue)
} else {
return DispatchQueue(label: label, qos: qos)
}
}
}
/// A tracing function that takes an SQL string.
+58 -41
View File
@@ -26,7 +26,7 @@ extension Database {
/// Returns whether a table exists.
public func tableExists(_ name: String) throws -> Bool {
return try exists(type: "table", name: name)
return try exists(type: .table, name: name)
}
/// Returns whether a table is an internal SQLite table.
@@ -53,30 +53,21 @@ extension Database {
/// Returns whether a view exists.
public func viewExists(_ name: String) throws -> Bool {
return try exists(type: "view", name: name)
return try exists(type: .view, name: name)
}
/// Returns whether a trigger exists.
public func triggerExists(_ name: String) throws -> Bool {
return try exists(type: "trigger", name: name)
return try exists(type: .trigger, name: name)
}
private func exists(type: String, name: String) throws -> Bool {
private func exists(type: SchemaObjectType, name: String) throws -> Bool {
// SQlite identifiers are case-insensitive, case-preserving:
// http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html
let name = name.lowercased()
if try makeSelectStatement("SELECT 1 FROM sqlite_master WHERE type = ? AND LOWER(name) = ?")
.makeCursor(arguments: [type, name])
.isEmpty() == false
{ return true }
if try makeSelectStatement("SELECT 1 FROM sqlite_temp_master WHERE type = ? AND LOWER(name) = ?")
.makeCursor(arguments: [type, name])
.isEmpty() == false
{ return true }
return false
return try schema()
.names(ofType: type)
.contains { $0.lowercased() == name }
}
/// The primary key for table named `tableName`.
@@ -271,27 +262,19 @@ extension Database {
/// Returns the actual name of the database table
func canonicalTableName(_ tableName: String) throws -> String {
if let canonicalTableName = schemaCache.canonicalTableName(tableName) {
return canonicalTableName
}
guard let canonicalTableName = try String.fetchOne(self, """
SELECT name FROM (
SELECT name, type FROM sqlite_master
UNION
SELECT name, type FROM sqlite_temp_master)
WHERE type = 'table' AND LOWER(name) = ?
""", arguments: [tableName.lowercased()])
else {
guard let name = try schema().canonicalName(tableName, ofType: .table) else {
throw DatabaseError(message: "no such table: \(tableName)")
}
schemaCache.set(canonicalTableName: canonicalTableName, forTable: tableName)
return canonicalTableName
return name
}
func schema() throws -> SchemaInfo {
return try SchemaInfo(self)
if let schemaInfo = schemaCache.schemaInfo {
return schemaInfo
}
let schemaInfo = try SchemaInfo(self)
schemaCache.schemaInfo = schemaInfo
return schemaInfo
}
}
@@ -585,24 +568,58 @@ public struct ForeignKeyInfo {
}
}
enum SchemaObjectType: String {
case index
case table
case trigger
case view
}
struct SchemaInfo: Equatable {
var objects: [SchemaKey: String?]
private var objects: Set<SchemaObject>
init(_ db: Database) throws {
objects = try Dictionary(uniqueKeysWithValues: Row
.fetchAll(db, "SELECT type, name, tbl_name, sql FROM sqlite_master")
.map { row in (SchemaKey(row: row), row["sql"]) })
objects = try Set(SchemaObject.fetchCursor(db, """
SELECT type, name, tbl_name, sql, 0 AS isTemporary FROM sqlite_master \
UNION \
SELECT type, name, tbl_name, sql, 1 FROM sqlite_temp_master
"""))
}
struct SchemaKey: Codable, Hashable, FetchableRecord {
/// All names for a given type
func names(ofType type: SchemaObjectType) -> Set<String> {
return objects.reduce(into: []) { (set, key) in
if key.type == type.rawValue {
set.insert(key.name)
}
}
}
/// Returns the canonical name of the object:
///
/// try db.execute("CREATE TABLE FooBar (...)")
/// try db.schema().canonicalName("foobar", ofType: .table) // "FooBar"
func canonicalName(_ name: String, ofType type: SchemaObjectType) -> String? {
let name = name.lowercased()
return objects.first { $0.name.lowercased() == name }?.name
}
private struct SchemaObject: Codable, Hashable, FetchableRecord {
var type: String
var name: String
var tbl_name: String?
var sql: String?
var isTemporary: Bool
#if !swift(>=4.2)
var hashValue: Int {
return type.hashValue ^ name.hashValue ^ (tbl_name?.hashValue ?? 0)
}
var hashValue: Int {
var hash = type.hashValue
hash ^= name.hashValue
hash ^= (tbl_name?.hashValue ?? 0)
hash ^= (sql?.hashValue ?? 0)
hash ^= isTemporary.hashValue
return hash
}
#endif
}
}
+63 -2
View File
@@ -202,6 +202,16 @@ extension Database {
var sqliteConnection: SQLiteConnection? = nil
let code = sqlite3_open_v2(path, &sqliteConnection, flags, nil)
guard code == SQLITE_OK else {
// https://www.sqlite.org/c3ref/open.html
// > Whether or not an error occurs when it is opened, resources
// > associated with the database connection handle should be
// > released by passing it to sqlite3_close() when it is no
// > longer required.
//
// https://www.sqlite.org/c3ref/close.html
// > Calling sqlite3_close() or sqlite3_close_v2() with a NULL
// > pointer argument is a harmless no-op.
sqlite3_close(sqliteConnection)
throw DatabaseError(resultCode: code)
}
if let sqliteConnection = sqliteConnection {
@@ -539,8 +549,8 @@ extension Database {
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
// Assume those pragmas never fail
try! execute("PRAGMA query_only = 1")
defer { try! execute("PRAGMA query_only = 0") }
try! internalCachedUpdateStatement("PRAGMA query_only = 1").execute()
defer { try! internalCachedUpdateStatement("PRAGMA query_only = 0").execute() }
return try block()
}
}
@@ -704,6 +714,56 @@ extension Database {
public func beginTransaction(_ kind: TransactionKind? = nil) throws {
let kind = kind ?? configuration.defaultTransactionKind
try execute("BEGIN \(kind.rawValue) TRANSACTION")
assert(isInsideTransaction)
}
/// Begins a database transaction and take a snapshot of the last committed
/// database state.
func beginSnapshotIsolation() 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
//
// 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
try beginTransaction(.deferred)
try internalCachedSelectStatement("SELECT rootpage FROM sqlite_master LIMIT 1").makeCursor().next()
}
/// Rollbacks a database transaction.
@@ -811,6 +871,7 @@ extension Database {
throw DatabaseError(resultCode: code, message: dbDest.lastErrorMessage)
}
// The schema of the destination database has changed:
dbDest.clearSchemaCache()
}
}
+14 -6
View File
@@ -141,20 +141,28 @@ public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible
// CustomStringConvertible
extension ResultCode {
/// :nodoc:
public var description: String {
var errorString: String? {
// sqlite3_errstr was added in SQLite 3.7.15 http://www.sqlite.org/changes.html#version_3_7_15
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
#if GRDBCUSTOMSQLITE || GRDBCIPHER
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
return String(cString: sqlite3_errstr(rawValue))
#else
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, iOSApplicationExtension 8.2, *) {
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
return String(cString: sqlite3_errstr(rawValue))
} else {
return "\(rawValue)"
return nil
}
#endif
}
/// :nodoc:
public var description: String {
if let errorString = errorString {
return "\(rawValue) (\(errorString))"
} else {
return "\(rawValue)"
}
}
}
/// DatabaseError wraps an SQLite error.
@@ -199,7 +207,7 @@ public struct DatabaseError : Error, CustomStringConvertible, CustomNSError {
/// Creates a Database Error
public init(resultCode: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
self.extendedResultCode = resultCode
self.message = message
self.message = message ?? resultCode.errorString
self.sql = sql
self.arguments = arguments
}
+85 -166
View File
@@ -17,6 +17,7 @@ public final class DatabasePool: DatabaseWriter {
private var functions = Set<DatabaseFunction>()
private var collations = Set<DatabaseCollation>()
private var tokenizerRegistrations: [(Database) -> Void] = []
var snapshotCount = ReadWriteBox(0)
@@ -51,7 +52,8 @@ public final class DatabasePool: DatabaseWriter {
path: path,
configuration: configuration,
schemaCache: SimpleDatabaseSchemaCache(),
label: (configuration.label ?? "GRDB.DatabasePool") + ".writer")
defaultLabel: "GRDB.DatabasePool",
purpose: "writer")
// Activate WAL Mode unless readonly
if !configuration.readonly {
@@ -88,7 +90,8 @@ public final class DatabasePool: DatabaseWriter {
path: path,
configuration: self.readerConfig,
schemaCache: SimpleDatabaseSchemaCache(),
label: (self.readerConfig.label ?? "GRDB.DatabasePool") + ".reader.\(readerCount)")
defaultLabel: "GRDB.DatabasePool",
purpose: "reader.\(readerCount)")
reader.sync { self.setupDatabase($0) }
return reader
})
@@ -105,12 +108,22 @@ public final class DatabasePool: DatabaseWriter {
#endif
private func setupDatabase(_ db: Database) {
for function in self.functions {
for function in functions {
db.add(function: function)
}
for collation in self.collations {
for collation in collations {
db.add(collation: collation)
}
for registration in tokenizerRegistrations {
registration(db)
}
}
/// Blocks the current thread until all database connections have
/// executed the *body* block.
fileprivate func forEachConnection(_ body: (Database) -> Void) {
writer.sync(body)
readerPool.forEach { $0.sync(body) }
}
}
@@ -148,11 +161,7 @@ extension DatabasePool {
///
/// See also setupMemoryManagement(application:)
public func releaseMemory() {
// TODO: test that this method blocks the current thread until all database accesses are completed.
writer.sync { $0.releaseMemory() }
readerPool.forEach { reader in
reader.sync { $0.releaseMemory() }
}
forEachConnection { $0.releaseMemory() }
readerPool.clear()
}
@@ -379,50 +388,6 @@ extension DatabasePool : DatabaseReader {
/// happen while establishing the read access to the database.
@available(*, deprecated, message: "Use concurrentRead instead")
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
// Check that we're on the writer queue...
writer.execute { db in
// ... and that no transaction is opened.
@@ -438,79 +403,36 @@ extension DatabasePool : DatabaseReader {
// isolation has been established:
let semaphore = DispatchSemaphore(value: 0)
var readError: Error? = nil
try readerPool.get { reader in
reader.async { db in
do {
try db.beginTransaction(.deferred)
assert(db.isInsideTransaction)
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
} catch {
readError = error
semaphore.signal() // Release the writer queue and rethrow error
return
}
semaphore.signal() // We can release the writer queue now that we are isolated for good
// Reset the schema cache before running user code in snapshot isolation
db.schemaCache = SimpleDatabaseSchemaCache()
block(db)
var snapshotIsolationError: Error? = nil
let (reader, releaseReader) = try readerPool.get()
reader.async { db in
defer {
_ = try? db.commit() // Ignore commit error
releaseReader()
}
do {
try db.beginSnapshotIsolation()
} catch {
snapshotIsolationError = error
semaphore.signal() // Release the writer queue and rethrow error
return
}
semaphore.signal() // We can release the writer queue now that we are isolated for good
// Reset the schema cache before running user code in snapshot isolation
db.schemaCache = SimpleDatabaseSchemaCache()
block(db)
}
_ = semaphore.wait(timeout: .distantFuture)
if let readError = readError {
if let error = snapshotIsolationError {
// TODO: write a test for this
throw readError
throw error
}
}
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> {
// 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
// Check that we're on the writer queue...
writer.execute { db in
// ... and that no transaction is opened.
@@ -531,32 +453,30 @@ extension DatabasePool : DatabaseReader {
var futureResult: Result<T>? = nil
do {
try readerPool.get { reader in
reader.async { db in
// Open a deferred transaction and access the database in
// order to establish snapshot isolation.
defer { _ = try? db.commit() }
do {
try db.beginTransaction(.deferred)
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
} catch {
// Snapshot isolation failure
futureResult = .failure(error)
isolationSemaphore.signal()
futureSemaphore.signal()
return
}
// Release the writer queue
isolationSemaphore.signal()
// Reset the schema cache before running user code in snapshot isolation
db.schemaCache = SimpleDatabaseSchemaCache()
// Fetch and release the future
futureResult = Result { try block(db) }
futureSemaphore.signal()
let (reader, releaseReader) = try readerPool.get()
reader.async { db in
defer {
try? db.commit() // Ignore commit error
releaseReader()
}
do {
try db.beginSnapshotIsolation()
} catch {
futureResult = .failure(error)
isolationSemaphore.signal()
futureSemaphore.signal()
return
}
// Release the writer queue
isolationSemaphore.signal()
// Reset the schema cache before running user code in snapshot isolation
db.schemaCache = SimpleDatabaseSchemaCache()
// Fetch and release the future
futureResult = Result { try block(db) }
futureSemaphore.signal()
}
} catch {
return Future { throw error }
@@ -568,13 +488,7 @@ extension DatabasePool : DatabaseReader {
return Future {
// Block the future until results are fetched
_ = futureSemaphore.wait(timeout: .distantFuture)
switch futureResult! {
case .failure(let error):
throw error
case .success(let result):
return result
}
return try futureResult!.unwrap()
}
}
@@ -722,19 +636,13 @@ extension DatabasePool : DatabaseReader {
/// }
public func add(function: DatabaseFunction) {
functions.update(with: function)
writer.sync { $0.add(function: function) }
readerPool.forEach { reader in
reader.sync { $0.add(function: function) }
}
forEachConnection { $0.add(function: function) }
}
/// Remove an SQL function.
public func remove(function: DatabaseFunction) {
functions.remove(function)
writer.sync { $0.remove(function: function) }
readerPool.forEach { reader in
reader.sync { $0.remove(function: function) }
}
forEachConnection { $0.remove(function: function) }
}
// MARK: - Collations
@@ -750,20 +658,30 @@ extension DatabasePool : DatabaseReader {
/// }
public func add(collation: DatabaseCollation) {
collations.update(with: collation)
writer.sync { $0.add(collation: collation) }
readerPool.forEach { reader in
reader.sync { $0.add(collation: collation) }
}
forEachConnection { $0.add(collation: collation) }
}
/// Remove a collation.
public func remove(collation: DatabaseCollation) {
collations.remove(collation)
writer.sync { $0.remove(collation: collation) }
readerPool.forEach { reader in
reader.sync { $0.remove(collation: collation) }
}
forEachConnection { $0.remove(collation: collation) }
}
// MARK: - Custom FTS5 Tokenizers
#if SQLITE_ENABLE_FTS5
/// Add a custom FTS5 tokenizer.
///
/// class MyTokenizer : FTS5CustomTokenizer { ... }
/// dbPool.add(tokenizer: MyTokenizer.self)
public func add<Tokenizer: FTS5CustomTokenizer>(tokenizer: Tokenizer.Type) {
func registerTokenizer(db: Database) {
db.add(tokenizer: Tokenizer.self)
}
tokenizerRegistrations.append(registerTokenizer)
forEachConnection(registerTokenizer)
}
#endif
}
extension DatabasePool {
@@ -839,7 +757,8 @@ extension DatabasePool {
let snapshot = try DatabaseSnapshot(
path: path,
configuration: writer.configuration,
labelSuffix: ".snapshot.\(snapshotCount.increment())")
defaultLabel: "GRDB.DatabasePool",
purpose: "snapshot.\(snapshotCount.increment())")
snapshot.read { setupDatabase($0) }
return snapshot
}
+5 -8
View File
@@ -40,7 +40,7 @@ public final class DatabaseQueue: DatabaseWriter {
path: path,
configuration: configuration,
schemaCache: SimpleDatabaseSchemaCache(),
label: configuration.label ?? "GRDB.DatabaseQueue")
defaultLabel: "GRDB.DatabaseQueue")
}
/// Opens an in-memory SQLite database.
@@ -56,7 +56,7 @@ public final class DatabaseQueue: DatabaseWriter {
path: ":memory:",
configuration: configuration,
schemaCache: SimpleDatabaseSchemaCache(),
label: configuration.label ?? "GRDB.DatabaseQueue")
defaultLabel: "GRDB.DatabaseQueue")
}
#if os(iOS)
@@ -225,7 +225,8 @@ extension DatabaseQueue {
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> {
// DatabaseQueue can't perform parallel reads.
let result = Result<T> {
// Perform a blocking read instead.
return Future(Result {
// Check that we're on the writer queue...
try writer.execute { db in
// ... and that no transaction is opened.
@@ -234,10 +235,7 @@ extension DatabaseQueue {
try block(db)
}
}
}
return Future {
try result.unwrap()
}
})
}
// MARK: - Writing in Database
@@ -387,4 +385,3 @@ extension DatabaseQueue {
writer.sync { $0.remove(collation: collation) }
}
}
+38
View File
@@ -149,6 +149,27 @@ public protocol DatabaseReader : class {
/// Remove a collation.
func remove(collation: DatabaseCollation)
// MARK: - Value Observation
/// Starts a value observation.
///
/// You should use the `ValueObservation.start(in:onError:onChange:)`
/// method instead.
///
/// - parameter observation: the stared observation
/// - parameter onError: a closure that is provided by eventual errors that happen
/// during observation
/// - parameter onChange: a closure that is provided fresh values
/// - returns: a TransactionObserver
func add<Reducer: ValueReducer>(
observation: ValueObservation<Reducer>,
onError: ((Error) -> Void)?,
onChange: @escaping (Reducer.Value) -> Void)
throws -> TransactionObserver
/// Remove a transaction observer.
func remove(transactionObserver: TransactionObserver)
}
extension DatabaseReader {
@@ -228,4 +249,21 @@ public final class AnyDatabaseReader : DatabaseReader {
public func remove(collation: DatabaseCollation) {
base.remove(collation: collation)
}
// MARK: - Value Observation
/// :nodoc:
public func add<Reducer: ValueReducer>(
observation: ValueObservation<Reducer>,
onError: ((Error) -> Void)?,
onChange: @escaping (Reducer.Value) -> Void)
throws -> TransactionObserver
{
return try base.add(observation: observation, onError: onError, onChange: onChange)
}
/// :nodoc:
public func remove(transactionObserver: TransactionObserver) {
base.remove(transactionObserver: transactionObserver)
}
}
+94 -28
View File
@@ -18,15 +18,15 @@
///
/// - `SelectStatement.databaseRegion`:
///
/// let statement = db.makeSelectStatement("SELECT name, score FROM player")
/// print(statement.databaseRegion)
/// // prints "player(name,score)"
/// let statement = db.makeSelectStatement("SELECT name, score FROM player")
/// print(statement.databaseRegion)
/// // prints "player(name,score)"
///
/// - `FetchRequest.databaseRegion(_:)`
///
/// let request = Player.filter(key: 1)
/// try print(request.databaseRegion(db))
/// // prints "player(*)[1]"
/// let request = Player.filter(key: 1)
/// try print(request.databaseRegion(db))
/// // prints "player(*)[1]"
///
/// Database regions returned by requests can be more precise than regions
/// returned by select statements. Especially, regions returned by statements
@@ -47,7 +47,10 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
/// Returns whether the region is empty.
public var isEmpty: Bool {
guard let tableRegions = tableRegions else { return false }
guard let tableRegions = tableRegions else {
// full database
return false
}
return tableRegions.isEmpty
}
@@ -122,7 +125,7 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
guard let otherTableRegions = other.tableRegions else { return .fullDatabase }
var tableRegionsUnion: [String: TableRegion] = [:]
let tableNames = Set(tableRegions.map { $0.key }).union(Set(otherTableRegions.map { $0.key }))
let tableNames = Set(tableRegions.keys).union(Set(otherTableRegions.keys))
for table in tableNames {
let tableRegion = tableRegions[table]
let otherTableRegion = otherTableRegions[table]
@@ -145,6 +148,13 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
public mutating func formUnion(_ other: DatabaseRegion) {
self = union(other)
}
func ignoring(_ tables: Set<String>) -> DatabaseRegion {
guard tables.isEmpty == false else { return self }
guard let tableRegions = tableRegions else { return .fullDatabase }
let filteredRegions = tableRegions.filter { tables.contains($0.key) == false }
return DatabaseRegion(tableRegions: filteredRegions)
}
}
extension DatabaseRegion {
@@ -154,7 +164,7 @@ extension DatabaseRegion {
/// Returns whether the content in the region would be impacted if the
/// database were modified by an event of this kind.
public func isModified(byEventsOfKind eventKind: DatabaseEventKind) -> Bool {
return !intersection(eventKind.modifiedRegion).isEmpty
return intersection(eventKind.modifiedRegion).isEmpty == false
}
/// Returns whether the content in the region is impacted by this event.
@@ -164,31 +174,27 @@ extension DatabaseRegion {
/// region.isModified(byEventsOfKind:)
public func isModified(by event: DatabaseEvent) -> Bool {
guard let tableRegions = tableRegions else {
// Full database: all changes are impactful
return true
}
switch tableRegions.count {
case 1:
// The precondition applies here:
if tableRegions.count == 1 {
// Fast path when the region contains a single table.
//
// The region contains a single table. Due to the
// filtering of events performed in observes(eventsOfKind:), the
// event argument is guaranteed to be about the fetched table.
// We thus only have to check for rowIds.
assert(event.tableName == tableRegions[tableRegions.startIndex].key) // sanity check
guard let rowIds = tableRegions[tableRegions.startIndex].value.rowIds else {
return true
}
return rowIds.contains(event.rowID)
default:
// We can apply the precondition: due to the filtering of events
// performed in observes(eventsOfKind:), the event argument is
// guaranteed to be about the fetched table. We thus only have to
// check for rowIds.
assert(event.tableName == tableRegions[tableRegions.startIndex].key) // sanity check in debug mode
let tableRegion = tableRegions[tableRegions.startIndex].value
return tableRegion.contains(rowID: event.rowID)
} else {
// Slow path when several tables are observed.
guard let tableRegion = tableRegions[event.tableName] else {
// Shouldn't happen if the precondition is met.
fatalError("precondition failure: event was not filtered out in observes(eventsOfKind:) by region.isModified(byEventsOfKind:)")
}
guard let rowIds = tableRegion.rowIds else {
return true
}
return rowIds.contains(event.rowID)
return tableRegion.contains(rowID: event.rowID)
}
}
}
@@ -201,8 +207,8 @@ extension DatabaseRegion {
case (nil, nil):
return true
case (let ltableRegions?, let rtableRegions?):
let ltableNames = Set(ltableRegions.map { $0.key })
let rtableNames = Set(rtableRegions.map { $0.key })
let ltableNames = Set(ltableRegions.keys)
let rtableNames = Set(rtableRegions.keys)
guard ltableNames == rtableNames else {
return false
}
@@ -295,4 +301,64 @@ private struct TableRegion: Equatable {
return TableRegion(columns: columnsUnion, rowIds: rowIdsUnion)
}
@inline(__always)
func contains(rowID: Int64) -> Bool {
guard let rowIds = rowIds else {
return true
}
return rowIds.contains(rowID)
}
}
// MARK: - DatabaseRegionConvertible
public protocol DatabaseRegionConvertible {
/// Returns a database region.
///
/// - parameter db: A database connection.
func databaseRegion(_ db: Database) throws -> DatabaseRegion
}
extension DatabaseRegion: DatabaseRegionConvertible {
/// :nodoc:
public func databaseRegion(_ db: Database) throws -> DatabaseRegion {
return self
}
}
/// A type-erased DatabaseRegionConvertible
public struct AnyDatabaseRegionConvertible: DatabaseRegionConvertible {
let _region: (Database) throws -> DatabaseRegion
public init(_ region: @escaping (Database) throws -> DatabaseRegion) {
_region = region
}
public init(_ region: DatabaseRegionConvertible) {
_region = { try region.databaseRegion($0) }
}
/// :nodoc:
public func databaseRegion(_ db: Database) throws -> DatabaseRegion {
return try _region(db)
}
}
// MARK: - Utils
extension DatabaseRegion {
static func union(_ regions: DatabaseRegion...) -> DatabaseRegion {
return regions.reduce(into: DatabaseRegion()) { union, region in
union.formUnion(region)
}
}
static func union(_ regions: [DatabaseRegionConvertible]) -> (Database) throws -> DatabaseRegion {
return { db in
try regions.reduce(into: DatabaseRegion()) { union, region in
try union.formUnion(region.databaseRegion(db))
}
}
}
}
+133
View File
@@ -0,0 +1,133 @@
/// DatabaseRegionObservation tracks changes in the results of database
/// requests, and notifies each database transaction whenever the
/// database changes.
///
/// For example:
///
/// let observation = DatabaseRegionObservation(tracking: Player.all)
/// let observer = try observation.start(in: dbQueue) { db: Database in
/// print("Players have changed.")
/// }
public struct DatabaseRegionObservation {
/// The extent of the database observation. The default is
/// `.observerLifetime`: the observation lasts until the
/// observer returned by the `start(in:onChange:)` method
/// is deallocated.
public var extent = Database.TransactionObservationExtent.observerLifetime
/// A closure that is evaluated when the observation starts, and returns
/// the observed database region.
var observedRegion: (Database) throws -> DatabaseRegion
// Not public because we foster DatabaseRegionConvertible.
init(tracking region: @escaping (Database) throws -> DatabaseRegion) {
self.observedRegion = { db in
// Remove views from the observed region.
//
// We can do it because we are only interested in modifications in
// actual tables. And we want to do it because we have a fast path
// for simple regions that span a single table.
let views = try db.schema().names(ofType: .view)
return try region(db).ignoring(views)
}
}
/// Creates a DatabaseRegionObservation which observes *regions*, and
/// notifies whenever one of the observed regions is modified by a
/// database transaction.
///
/// For example, this sample code counts the number of a times the player
/// table is modified:
///
/// let observation = DatabaseRegionObservation(tracking: Player.all())
///
/// var count = 0
/// let observer = observation.start(in: dbQueue) { _ in
/// count += 1
/// print("Players have been modified \(count) times.")
/// }
///
/// The observation lasts until the observer returned by `start` is
/// deallocated. See the `extent` property for more information.
///
/// - parameter regions: A list of observed regions.
public init(tracking regions: DatabaseRegionConvertible...) {
self.init(tracking: regions)
}
/// Creates a DatabaseRegionObservation which observes *regions*, and
/// notifies whenever one of the observed regions is modified by a
/// database transaction.
///
/// For example, this sample code counts the number of a times the player
/// table is modified:
///
/// let observation = DatabaseRegionObservation(tracking: [Player.all()])
///
/// var count = 0
/// let observer = observation.start(in: dbQueue) { _ in
/// count += 1
/// print("Players have been modified \(count) times.")
/// }
///
/// The observation lasts until the observer returned by `start` is
/// deallocated. See the `extent` property for more information.
///
/// - parameter regions: A list of observed regions.
public init(tracking regions: [DatabaseRegionConvertible]) {
self.init(tracking: DatabaseRegion.union(regions))
}
}
extension DatabaseRegionObservation {
/// Starts the observation in the provided database writer (such as
/// a database queue or database pool), and returns a transaction observer.
///
/// - parameter reader: A DatabaseWriter.
/// - parameter onChange: A closure that is provided a database connection
/// with write access each time the observed region has been modified.
/// - returns: a TransactionObserver
public func start(in dbWriter: DatabaseWriter, onChange: @escaping (Database) -> Void) throws -> TransactionObserver {
// Use unsafeReentrantWrite so that observation can start from any
// dispatch queue.
return try dbWriter.unsafeReentrantWrite { db -> TransactionObserver in
let region = try observedRegion(db)
let observer = DatabaseRegionObserver(region: region, onChange: onChange)
db.add(transactionObserver: observer, extent: extent)
return observer
}
}
}
private class DatabaseRegionObserver: TransactionObserver {
let region: DatabaseRegion
let onChange: (Database) -> Void
var isChanged = false
init(region: DatabaseRegion, onChange: @escaping (Database) -> Void) {
self.region = region
self.onChange = onChange
}
func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
return region.isModified(byEventsOfKind: eventKind)
}
func databaseDidChange(with event: DatabaseEvent) {
if region.isModified(by: event) {
isChanged = true
stopObservingDatabaseChangesUntilNextTransaction()
}
}
func databaseDidCommit(_ db: Database) {
guard isChanged else { return }
isChanged = false
onChange(db)
}
func databaseDidRollback(_ db: Database) {
isChanged = false
}
}
+8 -15
View File
@@ -2,9 +2,8 @@
protocol DatabaseSchemaCache {
mutating func clear()
func canonicalTableName(_ table: String) -> String?
mutating func set(canonicalTableName: String, forTable table: String)
var schemaInfo: SchemaInfo? { get set }
func primaryKey(_ table: String) -> PrimaryKeyInfo?
mutating func set(primaryKey: PrimaryKeyInfo, forTable table: String)
@@ -20,26 +19,18 @@ protocol DatabaseSchemaCache {
/// A thread-unsafe database schema cache
struct SimpleDatabaseSchemaCache: DatabaseSchemaCache {
private var canonicalTableNames: [String: String] = [:]
var schemaInfo: SchemaInfo?
private var primaryKeys: [String: PrimaryKeyInfo] = [:]
private var columns: [String: [ColumnInfo]] = [:]
private var indexes: [String: [IndexInfo]] = [:]
private var foreignKeys: [String: [ForeignKeyInfo]] = [:]
mutating func clear() {
canonicalTableNames = [:]
primaryKeys = [:]
columns = [:]
indexes = [:]
foreignKeys = [:]
}
func canonicalTableName(_ table: String) -> String? {
return canonicalTableNames[table]
}
mutating func set(canonicalTableName: String, forTable table: String) {
canonicalTableNames[table] = table
schemaInfo = nil
}
func primaryKey(_ table: String) -> PrimaryKeyInfo? {
@@ -79,8 +70,10 @@ struct SimpleDatabaseSchemaCache: DatabaseSchemaCache {
struct EmptyDatabaseSchemaCache: DatabaseSchemaCache {
func clear() { }
func canonicalTableName(_ table: String) -> String? { return nil }
func set(canonicalTableName: String, forTable table: String) { }
var schemaInfo: SchemaInfo? {
get { return nil }
set { }
}
func primaryKey(_ table: String) -> PrimaryKeyInfo? { return nil }
func set(primaryKey: PrimaryKeyInfo, forTable table: String) { }
+67 -32
View File
@@ -1,3 +1,5 @@
import Dispatch
/// A DatabaseSnapshot sees an unchanging database content, as it existed at the
/// moment it was created.
///
@@ -12,7 +14,7 @@ public class DatabaseSnapshot : DatabaseReader {
return serializedDatabase.configuration
}
init(path: String, configuration: Configuration = Configuration(), labelSuffix: String) throws {
init(path: String, configuration: Configuration = Configuration(), defaultLabel: String, purpose: String) throws {
var configuration = configuration
configuration.readonly = true
configuration.allowsUnsafeTransactions = true // Snaphost keeps a long-lived transaction
@@ -21,7 +23,8 @@ public class DatabaseSnapshot : DatabaseReader {
path: path,
configuration: configuration,
schemaCache: SimpleDatabaseSchemaCache(),
label: (configuration.label ?? "GRDB.DatabasePool") + labelSuffix)
defaultLabel: defaultLabel,
purpose: purpose)
try serializedDatabase.sync { db in
// Assert WAL mode
@@ -29,13 +32,7 @@ public class DatabaseSnapshot : DatabaseReader {
guard journalMode == "wal" else {
throw DatabaseError(message: "WAL mode is not activated at path: \(path)")
}
// Establish snapshot isolation (see deinit)
try db.beginTransaction(.deferred)
// Take snapshot
// See DatabasePool.concurrentRead for a complete discussion
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
try db.beginSnapshotIsolation()
}
}
@@ -81,45 +78,83 @@ extension DatabaseSnapshot {
// MARK: - Functions
/// Add or redefine an SQL function.
///
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
/// return nil
/// }
/// return int + 1
/// }
/// snapshot.add(function: fn)
/// try snapshot.read { db in
/// try Int.fetchOne(db, "SELECT succ(1)") // 2
/// }
public func add(function: DatabaseFunction) {
serializedDatabase.sync { $0.add(function: function) }
}
/// Remove an SQL function.
public func remove(function: DatabaseFunction) {
serializedDatabase.sync { $0.remove(function: function) }
}
// MARK: - Collations
/// Add or redefine a collation.
///
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
/// return (string1 as NSString).localizedStandardCompare(string2)
/// }
/// snapshot.add(collation: collation)
/// let files = try snapshot.read { db in
/// try File.fetchAll(db, "SELECT * FROM file ORDER BY name COLLATE localized_standard")
/// }
public func add(collation: DatabaseCollation) {
serializedDatabase.sync { $0.add(collation: collation) }
}
/// Remove a collation.
public func remove(collation: DatabaseCollation) {
serializedDatabase.sync { $0.remove(collation: collation) }
}
// MARK: - Value Observation
public func add<Reducer: ValueReducer>(
observation: ValueObservation<Reducer>,
onError: ((Error) -> Void)?,
onChange: @escaping (Reducer.Value) -> Void)
throws -> TransactionObserver
{
// Deal with initial value
switch observation.scheduling {
case .mainQueue:
if let value = try unsafeReentrantRead(observation.initialValue) {
if DispatchQueue.isMain {
onChange(value)
} else {
DispatchQueue.main.async {
onChange(value)
}
}
}
case let .onQueue(queue, startImmediately: startImmediately):
if startImmediately {
if let value = try unsafeReentrantRead(observation.initialValue) {
queue.async {
onChange(value)
}
}
}
case let .unsafe(startImmediately: startImmediately):
if startImmediately {
if let value = try unsafeReentrantRead(observation.initialValue) {
onChange(value)
}
}
}
// Return a dummy observer, because snapshots never change
return SnapshotValueObserver()
}
public func remove(transactionObserver: TransactionObserver) {
// Can't remove an observer which could not be added :-)
}
}
extension ValueObservation where Reducer: ValueReducer {
/// Helper method for DatabaseSnapshot.add(observation:onError:onChange:)
fileprivate func initialValue(_ db: Database) throws -> Reducer.Value? {
var reducer = try makeReducer(db)
let fetched = try reducer.fetch(db)
return reducer.value(fetched)
}
}
/// An observer that does nothing, support for
/// `DatabaseSnapshot.add(observation:onError:onChange:)`.
private class SnapshotValueObserver: TransactionObserver {
func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool { return false }
func databaseDidChange(with event: DatabaseEvent) { }
func databaseDidCommit(_ db: Database) { }
func databaseDidRollback(_ db: Database) { }
}
+12
View File
@@ -65,6 +65,12 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible> : Cursor
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Value? {
if done {
@@ -119,6 +125,12 @@ public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Value?? {
if done {
+112 -32
View File
@@ -129,6 +129,8 @@ extension DatabaseWriter {
/// Add a transaction observer, so that it gets notified of
/// database changes.
///
/// To remove the observer, use `DatabaseReader.remove(transactionObserver:)`.
///
/// - parameter transactionObserver: A transaction observer.
/// - parameter extent: The duration of the observation. The default is
/// the observer lifetime (observation lasts until observer
@@ -137,7 +139,8 @@ extension DatabaseWriter {
writeWithoutTransaction { $0.add(transactionObserver: transactionObserver, extent: extent) }
}
/// Remove a transaction observer.
/// Default implementation for the DatabaseReader requirement.
/// :nodoc:
public func remove(transactionObserver: TransactionObserver) {
writeWithoutTransaction { $0.remove(transactionObserver: transactionObserver) }
}
@@ -187,37 +190,6 @@ extension DatabaseWriter {
#endif
}
// MARK: - Reading from Database
/// Default implementation, based on the deprecated readFromCurrentState.
///
/// :nodoc:
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> {
let semaphore = DispatchSemaphore(value: 0)
var result: Result<T>? = nil
do {
try readFromCurrentState { db in
result = Result { try block(db) }
semaphore.signal()
}
} catch {
result = .failure(error)
semaphore.signal()
}
return Future {
_ = semaphore.wait(timeout: .distantFuture)
switch result! {
case .failure(let error):
throw error
case .success(let result):
return result
}
}
}
// MARK: - Claiming Disk Space
/// Rebuilds the database file, repacking it into a minimal amount of
@@ -227,6 +199,110 @@ extension DatabaseWriter {
public func vacuum() throws {
try writeWithoutTransaction { try $0.execute("VACUUM") }
}
// MARK: - Value Observation
/// Default implementation for the DatabaseReader requirement.
/// :nodoc:
public func add<Reducer: ValueReducer>(
observation: ValueObservation<Reducer>,
onError: ((Error) -> Void)?,
onChange: @escaping (Reducer.Value) -> Void)
throws -> TransactionObserver
{
let calledOnMainQueue = DispatchQueue.isMain
var startValue: Reducer.Value? = nil
defer {
if let startValue = startValue {
onChange(startValue)
}
}
// Use unsafeReentrantWrite so that observation can start from any
// dispatch queue.
return try unsafeReentrantWrite { db in
// Create the reducer
var reducer = try observation.makeReducer(db)
// Take care of initial value. Make sure it is dispatched before
// any future transaction can trigger a change.
switch observation.scheduling {
case .mainQueue:
if let value = try reducer.initialValue(db, requiresWriteAccess: observation.requiresWriteAccess) {
if calledOnMainQueue {
startValue = value
} else {
DispatchQueue.main.async { onChange(value) }
}
}
case let .onQueue(queue, startImmediately: startImmediately):
if startImmediately {
if let value = try reducer.initialValue(db, requiresWriteAccess: observation.requiresWriteAccess) {
queue.async { onChange(value) }
}
}
case let .unsafe(startImmediately: startImmediately):
if startImmediately {
startValue = try reducer.initialValue(db, requiresWriteAccess: observation.requiresWriteAccess)
}
}
// Start observing the database
let valueObserver = try ValueObserver(
region: observation.observedRegion(db),
reducer: reducer,
configuration: db.configuration,
fetch: observation.fetchAfterChange(in: self),
notificationQueue: observation.notificationQueue,
onError: onError,
onChange: onChange)
db.add(transactionObserver: valueObserver, extent: observation.extent)
return valueObserver
}
}
}
extension ValueReducer {
/// Helper method for DatabaseWriter.add(observation:onError:onChange:)
fileprivate mutating func initialValue(_ db: Database, requiresWriteAccess: Bool) throws -> Value? {
if requiresWriteAccess {
var fetchedValue: Fetched!
try db.inSavepoint {
fetchedValue = try fetch(db)
return .commit
}
return value(fetchedValue)
} else {
return try value(db.readOnly { try fetch(db) })
}
}
}
extension ValueObservation where Reducer: ValueReducer {
/// Helper method for DatabaseWriter.add(observation:onError:onChange:)
fileprivate func fetchAfterChange(in writer: DatabaseWriter) -> (Database, Reducer) -> Future<Reducer.Fetched> {
// The technique to return a future value after database has changed
// depends on the requiresWriteAccess flag:
if requiresWriteAccess {
// Synchronous fetch
return { (db, reducer) in
Future(Result {
var fetchedValue: Reducer.Fetched!
try db.inTransaction {
fetchedValue = try reducer.fetch(db)
return .commit
}
return fetchedValue
})
}
} else {
// Concurrent fetch
return { [unowned writer] (_, reducer) in
writer.concurrentRead(reducer.fetch)
}
}
}
}
/// A future value.
@@ -238,6 +314,10 @@ public class Future<Value> {
_wait = wait
}
init(_ result: Result<Value>) {
_wait = { try result.unwrap() }
}
/// Blocks the current thread until the value is available, and returns it.
///
/// It is a programmer error to call this method several times.
+1 -6
View File
@@ -8,7 +8,7 @@
/// try request.fetchCursor(db) // Cursor of Player
/// try request.fetchAll(db) // [Player]
/// try request.fetchOne(db) // Player?
public protocol FetchRequest {
public protocol FetchRequest: DatabaseRegionConvertible {
/// The type that tells how fetched database rows should be interpreted.
associatedtype RowDecoder
@@ -30,11 +30,6 @@ public protocol FetchRequest {
///
/// - parameter db: A database connection.
func fetchCount(_ db: Database) throws -> Int
/// Returns the database region that the request looks into.
///
/// - parameter db: A database connection.
func databaseRegion(_ db: Database) throws -> DatabaseRegion
}
extension FetchRequest {
+11 -2
View File
@@ -617,6 +617,12 @@ public final class RowCursor : Cursor {
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Row? {
if done {
@@ -702,8 +708,11 @@ extension Row {
/// - returns: An optional row.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Row? {
// The cursor reuses a single mutable row. Return an immutable copy.
return try fetchCursor(statement, arguments: arguments, adapter: adapter).next().map { $0.copy() }
let cursor = try fetchCursor(statement, arguments: arguments, adapter: adapter)
// Keep cursor alive until we can copy the fetched row
return try withExtendedLifetime(cursor) {
try cursor.next().map { $0.copy() }
}
}
}
+5 -6
View File
@@ -22,7 +22,7 @@ import Dispatch
/// - preconditionValidQueue() crashes whenever a database is used in an invalid
/// dispatch queue.
final class SchedulingWatchdog {
private static let specificKey = DispatchSpecificKey<SchedulingWatchdog>()
private static let watchDogKey = DispatchSpecificKey<SchedulingWatchdog>()
private(set) var allowedDatabases: [Database]
var databaseObservationBroker: DatabaseObservationBroker?
@@ -30,11 +30,10 @@ final class SchedulingWatchdog {
allowedDatabases = [database]
}
static func makeSerializedQueue(allowingDatabase database: Database, label: String) -> DispatchQueue {
let queue = DispatchQueue(label: label)
static func allowDatabase(_ database: Database, onQueue queue: DispatchQueue) {
precondition(queue.getSpecific(key: watchDogKey) == nil)
let watchdog = SchedulingWatchdog(allowedDatabase: database)
queue.setSpecific(key: specificKey, value: watchdog)
return queue
queue.setSpecific(key: watchDogKey, value: watchdog)
}
func inheritingAllowedDatabases<T>(from other: SchedulingWatchdog, execute body: () throws -> T) rethrows -> T {
@@ -49,7 +48,7 @@ final class SchedulingWatchdog {
}
static var current: SchedulingWatchdog? {
return DispatchQueue.getSpecific(key: specificKey)
return DispatchQueue.getSpecific(key: watchDogKey)
}
func allows(_ db: Database) -> Bool {
+4 -3
View File
@@ -16,7 +16,7 @@ final class SerializedDatabase {
/// The dispatch queue
private let queue: DispatchQueue
init(path: String, configuration: Configuration = Configuration(), schemaCache: DatabaseSchemaCache, label: String) throws {
init(path: String, configuration: Configuration = Configuration(), schemaCache: DatabaseSchemaCache, defaultLabel: String, purpose: String? = nil) throws {
// According to https://www.sqlite.org/threadsafe.html
//
// > SQLite support three different threading modes:
@@ -37,9 +37,10 @@ final class SerializedDatabase {
var config = configuration
config.threadingMode = .multiThread
db = try Database(path: path, configuration: config, schemaCache: schemaCache)
queue = SchedulingWatchdog.makeSerializedQueue(allowingDatabase: db, label: label)
self.path = path
self.db = try Database(path: path, configuration: config, schemaCache: schemaCache)
self.queue = configuration.makeDispatchQueue(defaultLabel: defaultLabel, purpose: purpose)
SchedulingWatchdog.allowDatabase(db, onQueue: queue)
try queue.sync {
try db.setup()
}
+13 -11
View File
@@ -83,14 +83,11 @@ public class Statement {
sqlite3_finalize(sqliteStatement)
}
final func reset() {
// It looks like sqlite3_reset() does not access the file system.
// This function call should thus succeed, unless a GRDB bug, or a
// programmer error (reusing a failed statement): there is no point
// throwing any error.
final func reset() throws {
SchedulingWatchdog.preconditionValidQueue(database)
let code = sqlite3_reset(sqliteStatement)
guard code == SQLITE_OK else {
fatalError(DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql).description)
throw DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql)
}
}
@@ -136,7 +133,7 @@ public class Statement {
_arguments = arguments
argumentsNeedValidation = false
reset()
try! reset()
clearBindings()
var valuesIterator = arguments.values.makeIterator()
@@ -159,7 +156,7 @@ public class Statement {
argumentsNeedValidation = false
// Apply
reset()
try reset()
clearBindings()
for (index, dbValue) in zip(Int32(1)..., bindings) {
bind(dbValue, at: index)
@@ -363,9 +360,8 @@ public final class SelectStatement : Statement {
/// Utility function for cursors
func reset(withArguments arguments: StatementArguments? = nil) {
SchedulingWatchdog.preconditionValidQueue(database)
prepare(withArguments: arguments)
reset()
try! reset()
}
}
@@ -392,6 +388,12 @@ public final class StatementCursor: Cursor {
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Void? {
if done {
@@ -480,7 +482,7 @@ public final class UpdateStatement : Statement {
public func execute(arguments: StatementArguments? = nil) throws {
SchedulingWatchdog.preconditionValidQueue(database)
prepare(withArguments: arguments)
reset()
try reset()
database.updateStatementWillExecute(self)
while true {
+8 -8
View File
@@ -49,18 +49,18 @@ final class StatementCompilationAuthorizer : StatementAuthorizer {
switch actionCode {
case SQLITE_DROP_TABLE, SQLITE_DROP_VTABLE, SQLITE_DROP_TEMP_TABLE,
SQLITE_DROP_INDEX, SQLITE_DROP_TEMP_INDEX:
SQLITE_DROP_INDEX, SQLITE_DROP_TEMP_INDEX,
SQLITE_DROP_VIEW, SQLITE_DROP_TEMP_VIEW,
SQLITE_DROP_TRIGGER, SQLITE_DROP_TEMP_TRIGGER:
isDropStatement = true
invalidatesDatabaseSchemaCache = true
return SQLITE_OK
case SQLITE_DROP_VIEW, SQLITE_DROP_TEMP_VIEW,
SQLITE_DROP_TRIGGER, SQLITE_CREATE_TEMP_TRIGGER:
isDropStatement = true
return SQLITE_OK
case SQLITE_DETACH, SQLITE_ALTER_TABLE,
SQLITE_CREATE_INDEX, SQLITE_CREATE_TEMP_INDEX:
case SQLITE_ALTER_TABLE, SQLITE_DETACH,
SQLITE_CREATE_INDEX, SQLITE_CREATE_TABLE,
SQLITE_CREATE_TEMP_INDEX, SQLITE_CREATE_TEMP_TABLE,
SQLITE_CREATE_TEMP_TRIGGER, SQLITE_CREATE_TEMP_VIEW,
SQLITE_CREATE_TRIGGER, SQLITE_CREATE_VIEW:
invalidatesDatabaseSchemaCache = true
return SQLITE_OK
@@ -77,6 +77,12 @@ public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & Sta
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Value? {
if done {
@@ -127,6 +133,12 @@ public final class FastNullableDatabaseValueCursor<Value: DatabaseValueConvertib
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Value?? {
if done {
-15
View File
@@ -150,19 +150,4 @@
}
}
}
extension DatabasePool {
// MARK: - Custom FTS5 Tokenizers
/// Add a custom FTS5 tokenizer.
///
/// class MyTokenizer : FTS5CustomTokenizer { ... }
/// dbPool.add(tokenizer: MyTokenizer.self)
public func add<Tokenizer: FTS5CustomTokenizer>(tokenizer: Tokenizer.Type) {
writeWithoutTransaction { db in
db.add(tokenizer: Tokenizer.self)
}
}
}
#endif
@@ -52,7 +52,7 @@ public protocol Association: DerivableRequest {
var request: AssociationRequest<RowDecoder> { get }
/// :nodoc:
func joinCondition(_ db: Database) throws -> JoinCondition
var joinCondition: JoinCondition { get }
/// :nodoc:
func mapRequest(_ transform: (AssociationRequest<RowDecoder>) -> AssociationRequest<RowDecoder>) -> Self
@@ -211,16 +211,30 @@ extension Association {
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
/// :nodoc:
public typealias JoinCondition = (_ leftAlias: TableAlias, _ rightAlias: TableAlias) -> SQLExpression?
/// Turns a ForeignKeyRequest into a JoinCondition
struct ForeignKeyJoinConditionRequest {
/// The condition that links two joined tables.
///
/// We only support one kind of join condition, today: foreign keys.
///
/// SELECT ...
/// FROM book
/// JOIN author ON author.id = book.authorId
/// <--the join condition--->
///
/// When we eventually add support for new ways to join tables, JoinCondition
/// is the type we'll need to update.
///
/// The Equatable conformance is used when we merge associations. Two
/// associations can be merged if and only if their join conditions
/// are equal:
///
/// let request = Book
/// .include(required: Book.author)
/// .include(required: Book.author)
public struct JoinCondition: Equatable {
var foreignKeyRequest: ForeignKeyRequest
var originIsLeft: Bool
func fetch(_ db: Database) throws -> JoinCondition {
func sqlExpression(_ db: Database, leftAlias: TableAlias, rightAlias: TableAlias) throws -> SQLExpression? {
let foreignKeyMapping = try foreignKeyRequest.fetch(db).mapping
let columnMapping: [(left: Column, right: Column)]
if originIsLeft {
@@ -228,11 +242,10 @@ struct ForeignKeyJoinConditionRequest {
} else {
columnMapping = foreignKeyMapping.map { (left: Column($0.destination), right: Column($0.origin)) }
}
return { (leftAlias, rightAlias) in
return columnMapping
.map { $0.right.qualifiedExpression(with: rightAlias) == $0.left.qualifiedExpression(with: leftAlias) }
.joined(operator: .and)
}
return columnMapping
.map { $0.right.qualifiedExpression(with: rightAlias) == $0.left.qualifiedExpression(with: leftAlias) }
.joined(operator: .and)
}
}
@@ -296,7 +309,7 @@ extension Association where OriginRowDecoder: MutablePersistableRecord {
.filter { db in
// Build a join condition: `association.recordId = record.id`
// We still need to replace `record.id` with the actual record id.
guard let joinCondition = try self.joinCondition(db)(recordAlias, associationAlias) else {
guard let joinExpression = try self.joinCondition.sqlExpression(db, leftAlias: recordAlias, rightAlias: associationAlias) else {
fatalError("Can't request from record without join condition")
}
@@ -306,7 +319,7 @@ extension Association where OriginRowDecoder: MutablePersistableRecord {
let container = PersistenceContainer(record)
// Replace `record.id` with 123
return joinCondition.resolvedExpression(inContext: [recordAlias: container])
return joinExpression.resolvedExpression(inContext: [recordAlias: container])
}
// We just added a condition qualified with associationAlias. Don't
@@ -0,0 +1,469 @@
import Foundation
/// An AssociationAggregate is able to compute aggregated values from a
/// population of associated records.
///
/// For example:
///
/// struct Author: TableRecord {
/// static let books = hasMany(Book.self)
/// }
///
/// let bookCount = Author.books.count // AssociationAggregate<Author>
///
/// Association aggregates can be used in the `annotated(with:)` and
/// `having(_:)` request methods:
///
/// let request = Author.annotated(with: bookCount)
/// let request = Author.having(bookCount >= 10)
public struct AssociationAggregate<RowDecoder> {
let prepare: (QueryInterfaceRequest<RowDecoder>) -> (request: QueryInterfaceRequest<RowDecoder>, expression: SQLExpression)
var alias: String?
init(_ prepare: @escaping (QueryInterfaceRequest<RowDecoder>) -> (request: QueryInterfaceRequest<RowDecoder>, expression: SQLExpression)) {
self.prepare = prepare
}
}
extension AssociationAggregate {
/// Returns an aggregate that is selected in a column with the given name.
///
/// For example:
///
/// let aggregate = Author.books.count.aliased("foo")
/// let request = Author.annotated(with: aggregate)
/// if let row = try Row.fetchOne(db, request) {
/// let bookCount: Int = row["foo"]
/// }
public func aliased(_ name: String) -> AssociationAggregate<RowDecoder> {
var aggregate = self
aggregate.alias = name
return aggregate
}
/// Returns an aggregate that is selected in a column named like the given
/// coding key.
///
/// For example:
///
/// struct AuthorInfo: Decodable, FetchableRecord {
/// var author: Author
/// var bookCount: Int
///
/// static func fetchAll(_ db: Database) throws -> [AuthorInfo] {
/// let aggregate = Author.books.count.aliased(CodingKeys.bookCount)
/// let request = Author.annotated(with: aggregate)
/// return try AuthorInfo.fetchAll(db, request)
/// }
/// }
public func aliased(_ key: CodingKey) -> AssociationAggregate<RowDecoder> {
return aliased(key.stringValue)
}
}
// MARK: - Logical Operators (AND, OR, NOT)
/// :nodoc:
public prefix func ! <RowDecoder>(aggregate: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = aggregate.prepare(request)
return (request: request, expression: !expression)
}
}
/// :nodoc:
public func && <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression && rExpression)
}
}
/// :nodoc:
public func && <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression && rhs)
}
}
/// :nodoc:
public func && <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs && expression)
}
}
/// :nodoc:
public func || <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression || rExpression)
}
}
/// :nodoc:
public func || <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression || rhs)
}
}
/// :nodoc:
public func || <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs || expression)
}
}
// MARK: - Egality and Identity Operators (=, <>, IS, IS NOT)
/// :nodoc:
public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression == rExpression)
}
}
/// :nodoc:
public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression == rhs)
}
}
/// :nodoc:
public func == <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs == expression)
}
}
/// :nodoc:
public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression == rhs)
}
}
/// :nodoc:
public func == <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs == expression)
}
}
/// :nodoc:
public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression != rExpression)
}
}
/// :nodoc:
public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression != rhs)
}
}
/// :nodoc:
public func != <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs != expression)
}
}
/// :nodoc:
public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression != rhs)
}
}
/// :nodoc:
public func != <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs != expression)
}
}
/// :nodoc:
public func === <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression === rExpression)
}
}
/// :nodoc:
public func === <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression === rhs)
}
}
/// :nodoc:
public func === <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs === expression)
}
}
/// :nodoc:
public func !== <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression !== rExpression)
}
}
/// :nodoc:
public func !== <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression !== rhs)
}
}
/// :nodoc:
public func !== <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs !== expression)
}
}
// MARK: - Comparison Operators (<, >, <=, >=)
/// :nodoc:
public func <= <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression <= rExpression)
}
}
/// :nodoc:
public func <= <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression <= rhs)
}
}
/// :nodoc:
public func <= <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs <= expression)
}
}
/// :nodoc:
public func < <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression < rExpression)
}
}
/// :nodoc:
public func < <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression < rhs)
}
}
/// :nodoc:
public func < <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs < expression)
}
}
/// :nodoc:
public func > <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression > rExpression)
}
}
/// :nodoc:
public func > <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression > rhs)
}
}
/// :nodoc:
public func > <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs > expression)
}
}
/// :nodoc:
public func >= <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression >= rExpression)
}
}
/// :nodoc:
public func >= <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression >= rhs)
}
}
/// :nodoc:
public func >= <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs >= expression)
}
}
// MARK: - Arithmetic Operators (+, -, *, /)
/// :nodoc:
public prefix func - <RowDecoder>(aggregate: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = aggregate.prepare(request)
return (request: request, expression:-expression)
}
}
/// :nodoc:
public func + <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression + rExpression)
}
}
/// :nodoc:
public func + <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression + rhs)
}
}
/// :nodoc:
public func + <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs + expression)
}
}
/// :nodoc:
public func - <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression - rExpression)
}
}
/// :nodoc:
public func - <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression - rhs)
}
}
/// :nodoc:
public func - <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs - expression)
}
}
/// :nodoc:
public func * <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression * rExpression)
}
}
/// :nodoc:
public func * <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression * rhs)
}
}
/// :nodoc:
public func * <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs * expression)
}
}
/// :nodoc:
public func / <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (lRequest, lExpression) = lhs.prepare(request)
let (request, rExpression) = rhs.prepare(lRequest)
return (request: request, expression: lExpression / rExpression)
}
}
/// :nodoc:
public func / <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = lhs.prepare(request)
return (request: request, expression: expression / rhs)
}
}
/// :nodoc:
public func / <RowDecoder>(lhs: SQLExpressible, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
return AssociationAggregate { request in
let (request, expression) = rhs.prepare(request)
return (request: request, expression: lhs / expression)
}
}
@@ -3,7 +3,7 @@ struct AssociationQuery {
var selection: [SQLSelectable]
var filterPromise: DatabasePromise<SQLExpression?>
var ordering: QueryOrdering
var joins: [AssociationJoin]
var joins: OrderedDictionary<String, AssociationJoin>
var alias: TableAlias? {
return source.alias
@@ -13,7 +13,7 @@ struct AssociationQuery {
extension AssociationQuery {
init(_ query: QueryInterfaceQuery) {
GRDBPrecondition(!query.isDistinct, "Not implemented: join distinct queries")
GRDBPrecondition(query.groupByExpressions.isEmpty, "Can't join aggregated queries")
GRDBPrecondition(query.groupPromise == nil, "Can't join aggregated queries")
GRDBPrecondition(query.havingExpression == nil, "Can't join aggregated queries")
GRDBPrecondition(query.limit == nil, "Can't join limited queries")
@@ -59,9 +59,17 @@ extension AssociationQuery {
return query
}
func joining(_ join: AssociationJoin) -> AssociationQuery {
func appendingJoin(_ join: AssociationJoin, forKey key: String) -> AssociationQuery {
var query = self
query.joins.append(join)
if let existingJoin = query.joins.removeValue(forKey: key) {
guard let mergedJoin = existingJoin.merged(with: join) else {
// can't merge
fatalError("The association key \"\(key)\" is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.")
}
query.joins.append(value: mergedJoin, forKey: key)
} else {
query.joins.append(value: join, forKey: key)
}
return query
}
@@ -82,7 +90,7 @@ extension AssociationQuery {
query.selection = selection.map { $0.qualifiedSelectable(with: alias) }
query.filterPromise = filterPromise.map { [alias] (_, expr) in expr?.qualifiedExpression(with: alias) }
query.ordering = ordering.qualified(with: alias)
query.joins = joins.map { $0.finalizedJoin }
query.joins = joins.mapValues { $0.finalizedJoin }
return query
}
@@ -94,21 +102,21 @@ extension AssociationQuery {
aliases.append(alias)
}
return joins.reduce(into: aliases) {
$0.append(contentsOf: $1.finalizedAliases)
$0.append(contentsOf: $1.value.finalizedAliases)
}
}
/// precondition: self is the result of finalizedQuery
var finalizedSelection: [SQLSelectable] {
return joins.reduce(into: selection) {
$0.append(contentsOf: $1.finalizedSelection)
$0.append(contentsOf: $1.value.finalizedSelection)
}
}
/// precondition: self is the result of finalizedQuery
var finalizedOrdering: QueryOrdering {
return joins.reduce(ordering) {
$0.appending($1.finalizedOrdering)
$0.appending($1.value.finalizedOrdering)
}
}
@@ -120,10 +128,9 @@ extension AssociationQuery {
var endIndex = startIndex + selectionWidth
var scopes: [String: RowAdapter] = [:]
for join in joins {
if let (joinAdapter, joinEndIndex) = try join.finalizedRowAdapter(db, fromIndex: endIndex, forKeyPath: keyPath + [join.key]) {
GRDBPrecondition(scopes[join.key] == nil, "The association key \"\((keyPath + [join.key]).joined(separator: "."))\" is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.")
scopes[join.key] = joinAdapter
for (key, join) in joins {
if let (joinAdapter, joinEndIndex) = try join.finalizedRowAdapter(db, fromIndex: endIndex, forKeyPath: keyPath + [key]) {
scopes[key] = joinAdapter
endIndex = joinEndIndex
}
}
@@ -136,3 +143,51 @@ extension AssociationQuery {
return (adapter: adapter.addingScopes(scopes), endIndex: endIndex)
}
}
extension AssociationQuery {
/// Returns nil if queries can't be merged (conflict in source, joins...)
func merged(with other: AssociationQuery) -> AssociationQuery? {
guard let mergedSource = source.merged(with: other.source) else {
// can't merge
return nil
}
let mergedFilterPromise = filterPromise.map { (db, expression) in
let otherExpression = try other.filterPromise.resolve(db)
let expressions = [expression, otherExpression].compactMap { $0 }
if expressions.isEmpty {
return nil
}
return expressions.joined(operator: .and)
}
var mergedJoins: OrderedDictionary<String, AssociationJoin> = [:]
for (key, join) in joins {
if let otherJoin = other.joins[key] {
guard let mergedJoin = join.merged(with: otherJoin) else {
// can't merge
return nil
}
mergedJoins.append(value: mergedJoin, forKey: key)
} else {
mergedJoins.append(value: join, forKey: key)
}
}
for (key, join) in other.joins where mergedJoins[key] == nil {
mergedJoins.append(value: join, forKey: key)
}
// replace selection unless empty
let mergedSelection = other.selection.isEmpty ? selection : other.selection
// replace ordering unless empty
let mergedOrdering = other.ordering.isEmpty ? ordering : other.ordering
return AssociationQuery(
source: mergedSource,
selection: mergedSelection,
filterPromise: mergedFilterPromise,
ordering: mergedOrdering,
joins: mergedJoins)
}
}
@@ -42,9 +42,8 @@ extension AssociationRequest {
{
let join = AssociationJoin(
joinOperator: joinOperator,
query: association.request.query,
key: association.key,
joinConditionPromise: DatabasePromise(association.joinCondition))
return AssociationRequest(query: query.joining(join))
joinCondition: association.joinCondition,
query: association.request.query)
return AssociationRequest(query: query.appendingJoin(join, forKey: association.key))
}
}
@@ -59,8 +59,6 @@
///
/// See ForeignKey for more information.
public struct BelongsToAssociation<Origin, Destination>: Association {
fileprivate let joinConditionRequest: ForeignKeyJoinConditionRequest
/// :nodoc:
public typealias OriginRowDecoder = Origin
@@ -69,6 +67,9 @@ public struct BelongsToAssociation<Origin, Destination>: Association {
public var key: String
/// :nodoc:
public let joinCondition: JoinCondition
/// :nodoc:
public var request: AssociationRequest<Destination>
@@ -78,11 +79,6 @@ public struct BelongsToAssociation<Origin, Destination>: Association {
return association
}
/// :nodoc:
public func joinCondition(_ db: Database) throws -> JoinCondition {
return try joinConditionRequest.fetch(db)
}
/// :nodoc:
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> BelongsToAssociation<Origin, Destination> {
var association = self
@@ -166,13 +162,13 @@ extension TableRecord {
destinationTable: Destination.databaseTableName,
foreignKey: foreignKey)
let joinConditionRequest = ForeignKeyJoinConditionRequest(
let joinCondition = JoinCondition(
foreignKeyRequest: foreignKeyRequest,
originIsLeft: true)
return BelongsToAssociation(
joinConditionRequest: joinConditionRequest,
key: key ?? Destination.databaseTableName,
joinCondition: joinCondition,
request: AssociationRequest(Destination.all()))
}
}
@@ -5,7 +5,7 @@
///
/// When the schema does not define any foreign key, we can still infer complete
/// mappings from partial information and primary keys.
struct ForeignKeyRequest {
struct ForeignKeyRequest: Equatable {
let originTable: String
let destinationTable: String
let originColumns: [String]?
@@ -59,8 +59,6 @@
///
/// See ForeignKey for more information.
public struct HasManyAssociation<Origin, Destination>: Association {
fileprivate let joinConditionRequest: ForeignKeyJoinConditionRequest
/// :nodoc:
public typealias OriginRowDecoder = Origin
@@ -69,6 +67,9 @@ public struct HasManyAssociation<Origin, Destination>: Association {
public var key: String
/// :nodoc:
public let joinCondition: JoinCondition
/// :nodoc:
public var request: AssociationRequest<Destination>
@@ -78,11 +79,6 @@ public struct HasManyAssociation<Origin, Destination>: Association {
return association
}
/// :nodoc:
public func joinCondition(_ db: Database) throws -> JoinCondition {
return try joinConditionRequest.fetch(db)
}
/// :nodoc:
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> HasManyAssociation<Origin, Destination> {
var association = self
@@ -97,6 +93,95 @@ extension HasManyAssociation: TableRequest where Destination: TableRecord {
public var databaseTableName: String { return Destination.databaseTableName }
}
extension HasManyAssociation where Origin: TableRecord, Destination: TableRecord {
private func makeAggregate(_ expression: SQLExpression) -> AssociationAggregate<Origin> {
return AssociationAggregate { request in
let tableAlias = TableAlias()
let request = request
.joining(optional: self.aliased(tableAlias))
.groupByPrimaryKey()
let expression = tableAlias[expression]
return (request: request, expression: expression)
}
}
/// The number of associated records.
///
/// For example:
///
/// Team.annotated(with: Team.players.count())
public var count: AssociationAggregate<Origin> {
return makeAggregate(SQLExpressionCountDistinct(Column.rowID)).aliased("\(key)Count")
}
/// An aggregate that is true if there exists no associated records.
///
/// For example:
///
/// Team.having(Team.players.isEmpty())
/// Team.having(!Team.players.isEmpty())
/// Team.having(Team.players.isEmpty() == false)
public var isEmpty: AssociationAggregate<Origin> {
return makeAggregate(SQLExpressionIsEmpty(SQLExpressionCountDistinct(Column.rowID)))
}
/// The average value of the given expression in associated records.
///
/// For example:
///
/// Team.annotated(with: Team.players.average(Column("score")))
public func average(_ expression: SQLExpressible) -> AssociationAggregate<Origin> {
let aggregate = makeAggregate(SQLExpressionFunction(.avg, arguments: expression))
if let column = expression as? ColumnExpression {
return aggregate.aliased("average\(key.uppercasingFirstCharacter)\(column.name.uppercasingFirstCharacter)")
} else {
return aggregate
}
}
/// The maximum value of the given expression in associated records.
///
/// For example:
///
/// Team.annotated(with: Team.players.max(Column("score")))
public func max(_ expression: SQLExpressible) -> AssociationAggregate<Origin> {
let aggregate = makeAggregate(SQLExpressionFunction(.max, arguments: expression))
if let column = expression as? ColumnExpression {
return aggregate.aliased("max\(key.uppercasingFirstCharacter)\(column.name.uppercasingFirstCharacter)")
} else {
return aggregate
}
}
/// The minimum value of the given expression in associated records.
///
/// For example:
///
/// Team.annotated(with: Team.players.min(Column("score")))
public func min(_ expression: SQLExpressible) -> AssociationAggregate<Origin> {
let aggregate = makeAggregate(SQLExpressionFunction(.min, arguments: expression))
if let column = expression as? ColumnExpression {
return aggregate.aliased("min\(key.uppercasingFirstCharacter)\(column.name.uppercasingFirstCharacter)")
} else {
return aggregate
}
}
/// The sum of the given expression in associated records.
///
/// For example:
///
/// Team.annotated(with: Team.players.min(Column("score")))
public func sum(_ expression: SQLExpressible) -> AssociationAggregate<Origin> {
let aggregate = makeAggregate(SQLExpressionFunction(.sum, arguments: expression))
if let column = expression as? ColumnExpression {
return aggregate.aliased("\(key)\(column.name.uppercasingFirstCharacter)Sum")
} else {
return aggregate
}
}
}
extension TableRecord {
/// Creates a "Has many" association between Self and the
/// destination type.
@@ -166,13 +251,13 @@ extension TableRecord {
destinationTable: databaseTableName,
foreignKey: foreignKey)
let joinConditionRequest = ForeignKeyJoinConditionRequest(
let joinCondition = JoinCondition(
foreignKeyRequest: foreignKeyRequest,
originIsLeft: false)
return HasManyAssociation(
joinConditionRequest: joinConditionRequest,
key: key ?? Destination.databaseTableName,
joinCondition: joinCondition,
request: AssociationRequest(Destination.all()))
}
}
@@ -61,8 +61,6 @@
///
/// See ForeignKey for more information.
public struct HasOneAssociation<Origin, Destination> : Association {
fileprivate let joinConditionRequest: ForeignKeyJoinConditionRequest
/// :nodoc:
public typealias OriginRowDecoder = Origin
@@ -71,6 +69,9 @@ public struct HasOneAssociation<Origin, Destination> : Association {
public var key: String
/// :nodoc:
public let joinCondition: JoinCondition
/// :nodoc:
public var request: AssociationRequest<Destination>
@@ -80,11 +81,6 @@ public struct HasOneAssociation<Origin, Destination> : Association {
return association
}
/// :nodoc:
public func joinCondition(_ db: Database) throws -> JoinCondition {
return try joinConditionRequest.fetch(db)
}
/// :nodoc:
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> HasOneAssociation<Origin, Destination> {
var association = self
@@ -168,13 +164,13 @@ extension TableRecord {
destinationTable: databaseTableName,
foreignKey: foreignKey)
let joinConditionRequest = ForeignKeyJoinConditionRequest(
let joinCondition = JoinCondition(
foreignKeyRequest: foreignKeyRequest,
originIsLeft: false)
return HasOneAssociation(
joinConditionRequest: joinConditionRequest,
key: key ?? Destination.databaseTableName,
joinCondition: joinCondition,
request: AssociationRequest(Destination.all()))
}
}
+92 -28
View File
@@ -21,28 +21,28 @@ struct QueryInterfaceQuery {
var selection: [SQLSelectable]
var isDistinct: Bool
var filterPromise: DatabasePromise<SQLExpression?>
var groupByExpressions: [SQLExpression]
var groupPromise: DatabasePromise<[SQLExpression]>?
var ordering: QueryOrdering
var havingExpression: SQLExpression?
var limit: SQLLimit?
var joins: [AssociationJoin]
var joins: OrderedDictionary<String, AssociationJoin>
init(
source: SQLSource,
selection: [SQLSelectable] = [],
isDistinct: Bool = false,
filterPromise: DatabasePromise<SQLExpression?> = DatabasePromise(value: nil),
groupByExpressions: [SQLExpression] = [],
groupPromise: DatabasePromise<[SQLExpression]>? = nil,
ordering: QueryOrdering = QueryOrdering(),
havingExpression: SQLExpression? = nil,
limit: SQLLimit? = nil,
joins: [AssociationJoin] = [])
joins: OrderedDictionary<String, AssociationJoin> = [:])
{
self.source = source
self.selection = selection
self.isDistinct = isDistinct
self.filterPromise = filterPromise
self.groupByExpressions = groupByExpressions
self.groupPromise = groupPromise
self.ordering = ordering
self.havingExpression = havingExpression
self.limit = limit
@@ -70,6 +70,12 @@ extension QueryInterfaceQuery {
return query
}
func annotated(with selection: [SQLSelectable]) -> QueryInterfaceQuery {
var query = self
query.selection.append(contentsOf: selection)
return query
}
func distinct() -> QueryInterfaceQuery {
var query = self
query.isDistinct = true
@@ -88,9 +94,9 @@ extension QueryInterfaceQuery {
return query
}
func group(_ expressions: [SQLExpressible]) -> QueryInterfaceQuery {
func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> QueryInterfaceQuery {
var query = self
query.groupByExpressions = expressions.map { $0.sqlExpression }
query.groupPromise = DatabasePromise { db in try expressions(db).map { $0.sqlExpression } }
return query
}
@@ -130,9 +136,17 @@ extension QueryInterfaceQuery {
return query
}
func joining(_ join: AssociationJoin) -> QueryInterfaceQuery {
func appendingJoin(_ join: AssociationJoin, forKey key: String) -> QueryInterfaceQuery {
var query = self
query.joins.append(join)
if let existingJoin = query.joins.removeValue(forKey: key) {
guard let mergedJoin = existingJoin.merged(with: join) else {
// can't merge
fatalError("The association key \"\(key)\" is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.")
}
query.joins.append(value: mergedJoin, forKey: key)
} else {
query.joins.append(value: join, forKey: key)
}
return query
}
@@ -152,11 +166,11 @@ extension QueryInterfaceQuery {
query.source = source.qualified(with: alias)
query.selection = query.selection.map { $0.qualifiedSelectable(with: alias) }
query.filterPromise = query.filterPromise.map { [alias] (_, expr) in expr?.qualifiedExpression(with: alias) }
query.groupByExpressions = query.groupByExpressions.map { $0.qualifiedExpression(with: alias) }
query.groupPromise = query.groupPromise?.map { [alias] (_, exprs) in exprs.map { $0.qualifiedExpression(with: alias) } }
query.ordering = query.ordering.qualified(with: alias)
query.havingExpression = query.havingExpression?.qualifiedExpression(with: alias)
query.joins = query.joins.map { $0.finalizedJoin }
query.joins = query.joins.mapValues { $0.finalizedJoin }
return query
}
@@ -168,21 +182,21 @@ extension QueryInterfaceQuery {
aliases.append(alias)
}
return joins.reduce(into: aliases) {
$0.append(contentsOf: $1.finalizedAliases)
$0.append(contentsOf: $1.value.finalizedAliases)
}
}
/// precondition: self is the result of finalizedQuery
var finalizedSelection: [SQLSelectable] {
return joins.reduce(into: selection) {
$0.append(contentsOf: $1.finalizedSelection)
$0.append(contentsOf: $1.value.finalizedSelection)
}
}
/// precondition: self is the result of finalizedQuery
var finalizedOrdering: QueryOrdering {
return joins.reduce(ordering) {
$0.appending($1.finalizedOrdering)
$0.appending($1.value.finalizedOrdering)
}
}
@@ -198,10 +212,9 @@ extension QueryInterfaceQuery {
var endIndex = selectionWidth
var scopes: [String: RowAdapter] = [:]
for join in joins {
if let (joinAdapter, joinEndIndex) = try join.finalizedRowAdapter(db, fromIndex: endIndex, forKeyPath: [join.key]) {
GRDBPrecondition(scopes[join.key] == nil, "The association key \"\(join.key)\" is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.")
scopes[join.key] = joinAdapter
for (key, join) in joins {
if let (joinAdapter, joinEndIndex) = try join.finalizedRowAdapter(db, fromIndex: endIndex, forKeyPath: [key]) {
scopes[key] = joinAdapter
endIndex = joinEndIndex
}
}
@@ -230,7 +243,7 @@ extension QueryInterfaceQuery {
sql += try " FROM " + source.sourceSQL(db, &context)
for join in joins {
for (_, join) in joins {
sql += try " " + join.joinSQL(db, &context, leftAlias: alias!, isRequiredAllowed: true)
}
@@ -238,9 +251,9 @@ extension QueryInterfaceQuery {
sql += " WHERE " + filter.expressionSQL(&context)
}
if !groupByExpressions.isEmpty {
if let groupExpressions = try groupPromise?.resolve(db), !groupExpressions.isEmpty {
sql += " GROUP BY "
sql += groupByExpressions.map { $0.expressionSQL(&context) }
sql += groupExpressions.map { $0.expressionSQL(&context) }
.joined(separator: ", ")
}
@@ -271,7 +284,7 @@ extension QueryInterfaceQuery {
/// precondition: self is the result of finalizedQuery
func makeDeleteStatement(_ db: Database) throws -> UpdateStatement {
guard groupByExpressions.isEmpty else {
if let groupExpressions = try groupPromise?.resolve(db), !groupExpressions.isEmpty {
// Programmer error
fatalError("Can't delete query with GROUP BY clause")
}
@@ -363,7 +376,7 @@ extension QueryInterfaceQuery {
}
private var countQuery: QueryInterfaceQuery {
guard groupByExpressions.isEmpty && limit == nil else {
guard groupPromise == nil && limit == nil else {
// SELECT ... GROUP BY ...
// SELECT ... LIMIT ...
return trivialCountQuery
@@ -458,10 +471,9 @@ enum AssociationJoinOperator {
struct AssociationJoin {
var joinOperator: AssociationJoinOperator
var joinCondition: JoinCondition
var query: AssociationQuery
var key: String
var joinConditionPromise: DatabasePromise<JoinCondition>
var finalizedJoin: AssociationJoin {
var join = self
join.query = query.finalizedQuery
@@ -504,19 +516,45 @@ struct AssociationJoin {
let rightAlias = query.alias!
let filters = try [
joinConditionPromise.resolve(db)(leftAlias, rightAlias),
joinCondition.sqlExpression(db, leftAlias: leftAlias, rightAlias: rightAlias),
query.filterPromise.resolve(db)
].compactMap { $0 }
if !filters.isEmpty {
sql += " ON " + filters.joined(operator: .and).expressionSQL(&context)
}
for join in query.joins {
for (_, join) in query.joins {
sql += try " " + join.joinSQL(db, &context, leftAlias: rightAlias, isRequiredAllowed: isRequiredAllowed)
}
return sql
}
/// Returns nil if joins can't be merged (conflict in condition, query...)
func merged(with other: AssociationJoin) -> AssociationJoin? {
guard joinCondition == other.joinCondition else {
// can't merge
return nil
}
guard let mergedQuery = query.merged(with: other.query) else {
// can't merge
return nil
}
let mergedJoinOperator: AssociationJoinOperator
switch (joinOperator, other.joinOperator) {
case (.required, _), (_, .required):
mergedJoinOperator = .required
default:
mergedJoinOperator = .optional
}
return AssociationJoin(
joinOperator: mergedJoinOperator,
joinCondition: joinCondition,
query: mergedQuery)
}
}
// MARK: - SQLSource
@@ -561,6 +599,32 @@ enum SQLSource {
return .query(query.qualified(with: alias))
}
}
/// Returns nil if sources can't be merged (conflict in tables, aliases...)
func merged(with other: SQLSource) -> SQLSource? {
switch (self, other) {
case let (.table(tableName: tableName, alias: alias), .table(tableName: otherTableName, alias: otherAlias)):
guard tableName == otherTableName else {
// can't merge
return nil
}
switch (alias, otherAlias) {
case (nil, nil):
return .table(tableName: tableName, alias: nil)
case let (alias?, nil), let (nil, alias?):
return .table(tableName: tableName, alias: alias)
case let (alias?, otherAlias?):
guard let mergedAlias = alias.merge(with: otherAlias) else {
// can't merge
return nil
}
return .table(tableName: tableName, alias: mergedAlias)
}
default:
// can't merge
return nil
}
}
}
struct SQLLimit {
@@ -5,10 +5,9 @@ extension QueryInterfaceRequest where RowDecoder: TableRecord {
{
let join = AssociationJoin(
joinOperator: joinOperator,
query: association.request.query,
key: association.key,
joinConditionPromise: DatabasePromise(association.joinCondition))
return QueryInterfaceRequest(query: query.joining(join))
joinCondition: association.joinCondition,
query: association.request.query)
return QueryInterfaceRequest(query: query.appendingJoin(join, forKey: association.key))
}
// MARK: - Associations
@@ -40,6 +39,52 @@ extension QueryInterfaceRequest where RowDecoder: TableRecord {
public func joining<A: Association>(required association: A) -> QueryInterfaceRequest<RowDecoder> where A.OriginRowDecoder == RowDecoder {
return joining(.required, association.select([]))
}
// MARK: - Association Aggregates
private func annotated(with aggregate: AssociationAggregate<RowDecoder>) -> QueryInterfaceRequest<RowDecoder> {
let (request, expression) = aggregate.prepare(self)
if let alias = aggregate.alias {
return request.annotated(with: [expression.aliased(alias)])
} else {
return request.annotated(with: [expression])
}
}
/// Creates a request which appends *aggregates* to the current selection.
///
/// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount
/// // FROM player LEFT JOIN book ...
/// var request = Player.all()
/// request = request.annotated(with: Player.books.count)
public func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> QueryInterfaceRequest<RowDecoder> {
return annotated(with: aggregates)
}
/// Creates a request which appends *aggregates* to the current selection.
///
/// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount
/// // FROM player LEFT JOIN book ...
/// var request = Player.all()
/// request = request.annotated(with: [Player.books.count])
public func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> QueryInterfaceRequest<RowDecoder> {
return aggregates.reduce(self) { request, aggregate in
request.annotated(with: aggregate)
}
}
/// Creates a request which appends the provided aggregate *predicate* to
/// the eventual set of already applied predicates.
///
/// // SELECT player.*
/// // FROM player LEFT JOIN book ...
/// // HAVING COUNT(DISTINCT book.rowid) = 0
/// var request = Player.all()
/// request = request.having(Player.books.isEmpty)
public func having(_ predicate: AssociationAggregate<RowDecoder>) -> QueryInterfaceRequest<RowDecoder> {
let (request, expression) = predicate.prepare(self)
return request.having(expression)
}
}
extension MutablePersistableRecord {
@@ -92,4 +137,39 @@ extension TableRecord {
public static func joining<A: Association>(required association: A) -> QueryInterfaceRequest<Self> where A.OriginRowDecoder == Self {
return all().joining(required: association)
}
// MARK: - Association Aggregates
/// Creates a request with *aggregates* appended to the selection.
///
/// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount
/// // FROM player LEFT JOIN book ...
/// var request = Player.annotated(with: Player.books.count)
public static func annotated(with aggregates: AssociationAggregate<Self>...) -> QueryInterfaceRequest<Self> {
return all().annotated(with: aggregates)
}
/// Creates a request with *aggregates* appended to the selection.
///
/// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount
/// // FROM player LEFT JOIN book ...
/// var request = Player.annotated(with: [Player.books.count])
public static func annotated(with aggregates: [AssociationAggregate<Self>]) -> QueryInterfaceRequest<Self> {
return all().annotated(with: aggregates)
}
/// Creates a request with the provided aggregate *predicate*.
///
/// // SELECT player.*
/// // FROM player LEFT JOIN book ...
/// // HAVING COUNT(DISTINCT book.rowid) = 0
/// var request = Player.all()
/// request = request.having(Player.books.isEmpty)
///
/// The selection defaults to all columns. This default can be changed for
/// all requests by the `TableRecord.databaseSelection` property, or
/// for individual requests with the `TableRecord.select` method.
public static func having(_ predicate: AssociationAggregate<Self>) -> QueryInterfaceRequest<Self> {
return all().having(predicate)
}
}
@@ -98,6 +98,17 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
public func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
return select(SQLSelectionLiteral(sql, arguments: arguments), as: type)
}
/// Creates a request which appends *selection*.
///
/// // SELECT id, email, name FROM player
/// var request = Player.all()
/// request = request
/// .select([Column("id"), Column("email")])
/// .annotated(with: [Column("name")])
public func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<T> {
return QueryInterfaceRequest(query: query.annotated(with: selection))
}
/// Creates a request which returns distinct rows.
///
@@ -122,8 +133,8 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
return QueryInterfaceRequest(query: query.filter(predicate))
}
/// Creates a request grouped according to *expressions*.
public func group(_ expressions: [SQLExpressible]) -> QueryInterfaceRequest<T> {
/// Creates a request grouped according to *expressions promise*.
public func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> QueryInterfaceRequest<T> {
return QueryInterfaceRequest(query: query.group(expressions))
}
+7 -3
View File
@@ -1,9 +1,6 @@
/// QueryOrdering provides the order clause to QueryInterfaceQuery
/// and AssociationQuery.
struct QueryOrdering {
private var elements: [Element] = []
var isReversed: Bool
private enum Element {
case orderingTerms((Database) throws -> [SQLOrderingTerm])
case queryOrdering(QueryOrdering)
@@ -36,6 +33,13 @@ struct QueryOrdering {
}
}
private var elements: [Element] = []
var isReversed: Bool
var isEmpty: Bool {
return elements.isEmpty
}
private init(elements: [Element], isReversed: Bool) {
self.elements = elements
self.isReversed = isReversed
+28 -2
View File
@@ -1,5 +1,7 @@
// MARK: - SelectionRequest
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The protocol for all requests that can refine their selection.
///
/// :nodoc:
@@ -56,6 +58,8 @@ extension SelectionRequest {
// MARK: - FilteredRequest
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The protocol for all requests that can be filtered.
///
/// :nodoc:
@@ -103,6 +107,8 @@ extension FilteredRequest {
// MARK: - TableRequest {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The protocol for all requests that feed from a database table
///
/// :nodoc:
@@ -222,14 +228,27 @@ extension TableRequest where Self: OrderedRequest {
}
}
/// :nodoc:
extension TableRequest where Self: AggregatingRequest {
/// Creates a request grouped by primary key.
public func groupByPrimaryKey() -> Self {
let tableName = self.databaseTableName
return group { db in
try db.primaryKey(tableName).columns.map { Column($0) }
}
}
}
// MARK: - AggregatingRequest
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The protocol for all requests that can aggregate.
///
/// :nodoc:
public protocol AggregatingRequest {
/// Creates a request grouped according to *expressions*.
func group(_ expressions: [SQLExpressible]) -> Self
/// Creates a request grouped according to *expressions promise*.
func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
/// Creates a request with the provided *predicate* added to the
/// eventual set of already applied predicates.
@@ -238,6 +257,11 @@ public protocol AggregatingRequest {
/// :nodoc:
extension AggregatingRequest {
/// Creates a request grouped according to *expressions*.
public func group(_ expressions: [SQLExpressible]) -> Self {
return group { _ in expressions }
}
/// Creates a request grouped according to *expressions*.
public func group(_ expressions: SQLExpressible...) -> Self {
return group(expressions)
@@ -267,6 +291,8 @@ extension AggregatingRequest {
// MARK: - OrderedRequest
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The protocol for all requests that be ordered.
///
/// :nodoc:
@@ -716,6 +716,42 @@ struct SQLExpressionCountDistinct : SQLExpression {
}
}
// MARK: - SQLExpressionIsEmpty
/// This one helps generating `COUNT(...) = 0` or `COUNT(...) > 0` while letting
/// the user using the not `!` logical operator, or comparisons with booleans
/// such as `== true` or `== false`.
struct SQLExpressionIsEmpty : SQLExpression {
var countExpression: SQLExpression
var isEmpty: Bool
// countExpression should be a counting expression
init(_ countExpression: SQLExpression, isEmpty: Bool = true) {
self.countExpression = countExpression
self.isEmpty = isEmpty
}
var negated: SQLExpression {
return SQLExpressionIsEmpty(countExpression, isEmpty: !isEmpty)
}
func expressionSQL(_ context: inout SQLGenerationContext) -> String {
if isEmpty {
return "(" + countExpression.expressionSQL(&context) + " = 0)"
} else {
return "(" + countExpression.expressionSQL(&context) + " > 0)"
}
}
func qualifiedExpression(with alias: TableAlias) -> SQLExpression {
return SQLExpressionIsEmpty(countExpression.qualifiedExpression(with: alias), isEmpty: isEmpty)
}
func resolvedExpression(inContext context: [TableAlias: PersistenceContainer]) -> SQLExpression {
return SQLExpressionIsEmpty(countExpression.resolvedExpression(inContext: context), isEmpty: isEmpty)
}
}
// MARK: - TableMatchExpression
struct TableMatchExpression: SQLExpression {
+33 -3
View File
@@ -180,15 +180,45 @@ public class TableAlias: Hashable {
func becomeProxy(of base: TableAlias) {
switch impl {
case .undefined(let userName):
case let .undefined(userName):
if let userName = userName {
// rename
assert(base.userName == nil || base.userName == userName)
base.setUserName(userName)
}
self.impl = .proxy(base)
case let .table(tableName: tableName, userName: userName):
assert(tableName == base.tableName)
if let userName = userName {
// rename
assert(base.userName == nil || base.userName == userName)
base.setUserName(userName)
}
self.impl = .proxy(base)
case let .proxy(selfBase):
selfBase.becomeProxy(of: base)
}
}
/// Returns nil if aliases can't be merged (conflict in tables, aliases...)
func merge(with other: TableAlias) -> TableAlias? {
let root = self.root
let otherRoot = other.root
switch (root.impl, otherRoot.impl) {
case let (.table(tableName: tableName, userName: userName), .table(tableName: otherTableName, userName: otherUserName)):
guard tableName == otherTableName else {
// can't merge
return nil
}
if let userName = userName, let otherUserName = otherUserName, userName != otherUserName {
// can't merge
return nil
}
root.becomeProxy(of: otherRoot)
return otherRoot
default:
// Likely a GRDB bug
fatalError("Not implemented")
// can't merge
return nil
}
}
@@ -30,6 +30,13 @@ extension SQLSpecificExpressible {
public func aliased(_ name: String) -> SQLSelectable {
return SQLAliasedExpression(sqlExpression, name: name)
}
/// Returns a value that can be used as an argument to QueryInterfaceRequest.select()
///
/// See https://github.com/groue/GRDB.swift/#the-query-interface
public func aliased(_ key: CodingKey) -> SQLSelectable {
return aliased(key.stringValue)
}
}
+24
View File
@@ -216,6 +216,30 @@ extension Database {
public func drop(index name: String) throws {
try execute("DROP INDEX \(name.quotedDatabaseIdentifier)")
}
/// Delete and recreate from scratch all indices that use this collation.
///
/// This method is useful when the definition of a collation sequence
/// has changed.
///
/// See https://www.sqlite.org/lang_reindex.html
///
/// - throws: A DatabaseError whenever an SQLite error occurs.
public func reindex(collation: Database.CollationName) throws {
try execute("REINDEX \(collation.rawValue)")
}
/// Delete and recreate from scratch all indices that use this collation.
///
/// This method is useful when the definition of a collation sequence
/// has changed.
///
/// See https://www.sqlite.org/lang_reindex.html
///
/// - throws: A DatabaseError whenever an SQLite error occurs.
public func reindex(collation: DatabaseCollation) throws {
try reindex(collation: Database.CollationName(collation.name))
}
}
/// The TableDefinition class lets you define table columns and constraints.
+6
View File
@@ -381,6 +381,12 @@ public final class RecordCursor<Record: FetchableRecord> : Cursor {
statement.reset(withArguments: arguments)
}
deinit {
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? statement.reset()
}
/// :nodoc:
public func next() throws -> Record? {
if done {
@@ -140,6 +140,10 @@ private class RecordEncoder<Record: MutablePersistableRecord>: Encoder {
// error happens, we'll switch to JSON encoding.
let encoder = ColumnEncoder(recordEncoder: self, key: key)
try value.encode(to: encoder)
if encoder.requiresJSON {
// Here we handle empty arrays and dictionaries.
throw JSONRequiredError()
}
} catch is JSONRequiredError {
// Encode to JSON
let jsonData = try Record.databaseJSONEncoder(for: key.stringValue).encode(value)
@@ -159,11 +163,12 @@ private class RecordEncoder<Record: MutablePersistableRecord>: Encoder {
// MARK: - ColumnEncoder
/// The encoder that encodes into a database column
private struct ColumnEncoder<Record: MutablePersistableRecord>: Encoder {
private class ColumnEncoder<Record: MutablePersistableRecord>: Encoder {
var recordEncoder: RecordEncoder<Record>
var key: CodingKey
var codingPath: [CodingKey] { return [key] }
var userInfo: [CodingUserInfoKey: Any] { return Record.databaseEncodingUserInfo }
var requiresJSON = false
init(recordEncoder: RecordEncoder<Record>, key: CodingKey) {
self.recordEncoder = recordEncoder
@@ -174,6 +179,7 @@ private struct ColumnEncoder<Record: MutablePersistableRecord>: Encoder {
// Keyed values require JSON encoding: we need to throw
// JSONRequiredError. Since we can't throw right from here, let's
// delegate the job to a dedicated container.
requiresJSON = true
let container = JSONRequiredEncoder<Record>.KeyedContainer<Key>(codingPath: codingPath)
return KeyedEncodingContainer(container)
}
@@ -182,6 +188,7 @@ private struct ColumnEncoder<Record: MutablePersistableRecord>: Encoder {
// Keyed values require JSON encoding: we need to throw
// JSONRequiredError. Since we can't throw right from here, let's
// delegate the job to a dedicated container.
requiresJSON = true
return JSONRequiredEncoder<Record>(codingPath: codingPath)
}
+97 -19
View File
@@ -521,28 +521,62 @@ extension MutablePersistableRecord {
try update(db, columns: Set(columns.map { $0.name }))
}
/// If the record has differences from the other record, executes an UPDATE
/// statement so that those changes and only those changes are saved in
/// the database.
/// If the record has any difference from the other record, executes an
/// UPDATE statement so that those differences and only those difference are
/// saved in the database.
///
/// This method is guaranteed to have saved the eventual changes in the
/// This method is guaranteed to have saved the eventual differences in the
/// database if it returns without error.
///
/// For example:
///
/// if let oldPlayer = try Player.fetchOne(db, key: 42) {
/// var newPlayer = oldPlayer
/// newPlayer.score += 10
/// newPlayer.hasAward = true
/// try newPlayer.updateChanges(db, from: oldRecord)
/// }
///
/// - parameter db: A database connection.
/// - parameter columns: The columns to update.
/// - parameter record: The comparison record.
/// - returns: Whether the record had changes.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
/// PersistenceError.recordNotFound is thrown if the primary key does not
/// match any row in the database and record could not be updated.
/// - SeeAlso: updateChanges(_:with:)
@discardableResult
public func updateChanges(_ db: Database, from record: MutablePersistableRecord) throws -> Bool {
return try updateChanges(db, from: PersistenceContainer(record))
}
/// Mutates the record according to the provided closure, and then, if the
/// record has any difference from its previous version, executes an
/// UPDATE statement so that those differences and only those difference are
/// saved in the database.
///
/// This method is guaranteed to have saved the eventual differences in the
/// database if it returns without error.
///
/// For example:
///
/// if var player = try Player.fetchOne(db, key: 42) {
/// try player.updateChanges(db) {
/// $0.score += 10
/// $0.hasAward = true
/// }
/// }
///
/// - parameter db: A database connection.
/// - parameter change: A closure that modifies the record.
/// - returns: Whether the record had changes.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
/// PersistenceError.recordNotFound is thrown if the primary key does not
/// match any row in the database and record could not be updated.
@discardableResult
public func updateChanges(_ db: Database, from record: MutablePersistableRecord) throws -> Bool {
let changedColumns = Set(databaseChanges(from: record).keys)
if changedColumns.isEmpty {
return false
} else {
try update(db, columns: changedColumns)
return true
}
public mutating func updateChanges(_ db: Database, with change: (inout Self) throws -> Void) throws -> Bool {
let container = PersistenceContainer(self)
try change(&self)
return try updateChanges(db, from: container)
}
/// Executes an INSERT or an UPDATE statement so that `self` is saved in
@@ -574,7 +608,7 @@ extension MutablePersistableRecord {
/// Returns a boolean indicating whether this record and the other record
/// have the same database representation.
public func databaseEquals(_ record: Self) -> Bool {
return databaseChangesIterator(from: record).next() == nil
return databaseChangesIterator(from: PersistenceContainer(record)).next() == nil
}
/// A dictionary of values changed from the other record.
@@ -586,16 +620,15 @@ extension MutablePersistableRecord {
/// same set of columns in their `encode(to:)` method, only the columns
/// defined by the receiver record are considered.
public func databaseChanges(from record: MutablePersistableRecord) -> [String: DatabaseValue] {
return Dictionary(uniqueKeysWithValues: databaseChangesIterator(from: record))
return Dictionary(uniqueKeysWithValues: databaseChangesIterator(from: PersistenceContainer(record)))
}
fileprivate func databaseChangesIterator(from record: MutablePersistableRecord) -> AnyIterator<(String, DatabaseValue)> {
let oldContainer = PersistenceContainer(record)
private func databaseChangesIterator(from container: PersistenceContainer) -> AnyIterator<(String, DatabaseValue)> {
var newValueIterator = PersistenceContainer(self).makeIterator()
return AnyIterator {
// Loop until we find a change, or exhaust columns:
while let (column, newValue) = newValueIterator.next() {
let oldValue = oldContainer[caseInsensitive: column]
let oldValue = container[caseInsensitive: column]
let oldDbValue = oldValue?.databaseValue ?? .null
let newDbValue = newValue?.databaseValue ?? .null
if newDbValue != oldDbValue {
@@ -606,6 +639,17 @@ extension MutablePersistableRecord {
}
}
@discardableResult
fileprivate func updateChanges(_ db: Database, from container: PersistenceContainer) throws -> Bool {
let changes = databaseChangesIterator(from: container)
let changedColumns: Set<String> = changes.reduce(into: []) { $0.insert($1.0) }
if changedColumns.isEmpty {
return false
}
try update(db, columns: changedColumns)
return true
}
// MARK: - CRUD Internals
/// Return true if record has a non-null primary key
@@ -721,7 +765,42 @@ extension MutablePersistableRecord {
}
return try Row.fetchOne(statement) != nil
}
}
extension MutablePersistableRecord where Self: AnyObject {
// MARK: - Record Comparison
/// Mutates the record according to the provided closure, and then, if the
/// record has any difference from its previous version, executes an
/// UPDATE statement so that those differences and only those difference are
/// saved in the database.
///
/// This method is guaranteed to have saved the eventual differences in the
/// database if it returns without error.
///
/// For example:
///
/// if let player = try Player.fetchOne(db, key: 42) {
/// try player.updateChanges(db) {
/// $0.score += 10
/// $0.hasAward = true
/// }
/// }
///
/// - parameter db: A database connection.
/// - parameter change: A closure that modifies the record.
/// - returns: Whether the record had changes.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
/// PersistenceError.recordNotFound is thrown if the primary key does not
/// match any row in the database and record could not be updated.
@discardableResult
public func updateChanges(_ db: Database, with change: (Self) throws -> Void) throws -> Bool {
let container = PersistenceContainer(self)
try change(self)
return try updateChanges(db, from: container)
}
}
extension MutablePersistableRecord {
@@ -929,7 +1008,6 @@ extension PersistableRecord {
try performSave(db)
}
// MARK: - Immutable CRUD Internals
/// Don't invoke this method directly: it is an internal method for types
+10
View File
@@ -0,0 +1,10 @@
import Foundation
extension String {
var uppercasingFirstCharacter: String {
guard let first = first else {
return self
}
return String(first).uppercased() + dropFirst()
}
}
+67
View File
@@ -0,0 +1,67 @@
struct OrderedDictionary<Key: Hashable, Value> {
private var keys: [Key]
private var values: [Key: Value]
init() {
self.keys = []
self.values = [:]
}
subscript(_ key: Key) -> Value? {
return values[key]
}
mutating func append(value: Value, forKey key: Key) {
guard values.updateValue(value, forKey: key) == nil else {
fatalError("key is already defined")
}
keys.append(key)
}
@discardableResult
mutating func removeValue(forKey key: Key) -> Value? {
guard let value = values.removeValue(forKey: key) else {
return nil
}
let index = keys.index { $0 == key }!
keys.remove(at: index)
return value
}
func mapValues<T>(_ transform: (Value) throws -> T) rethrows -> OrderedDictionary<Key, T> {
var result = OrderedDictionary<Key, T>()
for key in keys {
let value = values[key]!
try result.append(value: transform(value), forKey: key)
}
return result
}
}
extension OrderedDictionary: Collection {
typealias Index = Int
var startIndex: Int {
return 0
}
var endIndex: Int {
return keys.count
}
func index(after i: Int) -> Int {
return i + 1
}
subscript(position: Int) -> (key: Key, value: Value) {
let key = keys[position]
return (key: key, value: values[key]!)
}
}
extension OrderedDictionary: ExpressibleByDictionaryLiteral {
init(dictionaryLiteral elements: (Key, Value)...) {
self.keys = elements.map { $0.0 }
self.values = Dictionary(uniqueKeysWithValues: elements)
}
}
+12
View File
@@ -69,3 +69,15 @@ extension Array {
}
}
}
extension DispatchQueue {
private static var mainKey: DispatchSpecificKey<()> = {
let key = DispatchSpecificKey<()>()
DispatchQueue.main.setSpecific(key: key, value: ())
return key
}()
static var isMain: Bool {
return DispatchQueue.getSpecific(key: mainKey) != nil
}
}
@@ -0,0 +1,273 @@
extension ValueObservation where Reducer == Void {
public static func combine<R1: ValueReducer, R2: ValueReducer>(
_ o1: ValueObservation<R1>,
_ o2: ValueObservation<R2>)
-> ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched),
(R1.Value, R2.Value)>>
{
return ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched),
(R1.Value, R2.Value)>>(
tracking: { try DatabaseRegion.union(
o1.observedRegion($0),
o2.observedRegion($0)) },
reducer: { try _combine(
o1.makeReducer($0),
o2.makeReducer($0)) })
}
public static func combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer>(
_ o1: ValueObservation<R1>,
_ o2: ValueObservation<R2>,
_ o3: ValueObservation<R3>)
-> ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched),
(R1.Value, R2.Value, R3.Value)>>
{
return ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched),
(R1.Value, R2.Value, R3.Value)>>(
tracking: { try DatabaseRegion.union(
o1.observedRegion($0),
o2.observedRegion($0),
o3.observedRegion($0)) },
reducer: { try _combine(
o1.makeReducer($0),
o2.makeReducer($0),
o3.makeReducer($0)) })
}
public static func combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer, R4: ValueReducer>(
_ o1: ValueObservation<R1>,
_ o2: ValueObservation<R2>,
_ o3: ValueObservation<R3>,
_ o4: ValueObservation<R4>)
-> ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value)>>
{
return ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value)>>(
tracking: { try DatabaseRegion.union(
o1.observedRegion($0),
o2.observedRegion($0),
o3.observedRegion($0),
o4.observedRegion($0)) },
reducer: { try _combine(
o1.makeReducer($0),
o2.makeReducer($0),
o3.makeReducer($0),
o4.makeReducer($0)) })
}
public static func combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer, R4: ValueReducer, R5: ValueReducer>(
_ o1: ValueObservation<R1>,
_ o2: ValueObservation<R2>,
_ o3: ValueObservation<R3>,
_ o4: ValueObservation<R4>,
_ o5: ValueObservation<R5>)
-> ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched, R5.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value, R5.Value)>>
{
return ValueObservation<AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched, R5.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value, R5.Value)>>(
tracking: { try DatabaseRegion.union(
o1.observedRegion($0),
o2.observedRegion($0),
o3.observedRegion($0),
o4.observedRegion($0),
o5.observedRegion($0)) },
reducer: { try _combine(
o1.makeReducer($0),
o2.makeReducer($0),
o3.makeReducer($0),
o4.makeReducer($0),
o5.makeReducer($0)) })
}
}
private func _combine<R1: ValueReducer, R2: ValueReducer>(
_ r1: R1,
_ r2: R2)
-> AnyValueReducer<
(R1.Fetched, R2.Fetched),
(R1.Value, R2.Value)>
{
var r1 = r1
var r2 = r2
var prev1: R1.Value?
var prev2: R2.Value?
func fetch(db: Database) throws -> (R1.Fetched, R2.Fetched) {
return try (
r1.fetch(db),
r2.fetch(db))
}
func value(tuple: (R1.Fetched, R2.Fetched)) -> (R1.Value, R2.Value)? {
let v1 = r1.value(tuple.0)
let v2 = r2.value(tuple.1)
defer {
if let v1 = v1 { prev1 = v1 }
if let v2 = v2 { prev2 = v2 }
}
if v1 != nil || v2 != nil,
let c1 = v1 ?? prev1,
let c2 = v2 ?? prev2
{
return (c1, c2)
} else {
return nil
}
}
return AnyValueReducer(fetch: fetch, value: value)
}
private func _combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer>(
_ r1: R1,
_ r2: R2,
_ r3: R3)
-> AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched),
(R1.Value, R2.Value, R3.Value)>
{
var r1 = r1
var r2 = r2
var r3 = r3
var prev1: R1.Value?
var prev2: R2.Value?
var prev3: R3.Value?
func fetch(db: Database) throws -> (R1.Fetched, R2.Fetched, R3.Fetched) {
return try (
r1.fetch(db),
r2.fetch(db),
r3.fetch(db))
}
func value(tuple: (R1.Fetched, R2.Fetched, R3.Fetched)) -> (R1.Value, R2.Value, R3.Value)? {
let v1 = r1.value(tuple.0)
let v2 = r2.value(tuple.1)
let v3 = r3.value(tuple.2)
defer {
if let v1 = v1 { prev1 = v1 }
if let v2 = v2 { prev2 = v2 }
if let v3 = v3 { prev3 = v3 }
}
if v1 != nil || v2 != nil || v3 != nil,
let c1 = v1 ?? prev1,
let c2 = v2 ?? prev2,
let c3 = v3 ?? prev3
{
return (c1, c2, c3)
} else {
return nil
}
}
return AnyValueReducer(fetch: fetch, value: value)
}
private func _combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer, R4: ValueReducer>(
_ r1: R1,
_ r2: R2,
_ r3: R3,
_ r4: R4)
-> AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value)>
{
var r1 = r1
var r2 = r2
var r3 = r3
var r4 = r4
var prev1: R1.Value?
var prev2: R2.Value?
var prev3: R3.Value?
var prev4: R4.Value?
func fetch(db: Database) throws -> (R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched) {
return try (
r1.fetch(db),
r2.fetch(db),
r3.fetch(db),
r4.fetch(db))
}
func value(tuple: (R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched)) -> (R1.Value, R2.Value, R3.Value, R4.Value)? {
let v1 = r1.value(tuple.0)
let v2 = r2.value(tuple.1)
let v3 = r3.value(tuple.2)
let v4 = r4.value(tuple.3)
defer {
if let v1 = v1 { prev1 = v1 }
if let v2 = v2 { prev2 = v2 }
if let v3 = v3 { prev3 = v3 }
if let v4 = v4 { prev4 = v4 }
}
if v1 != nil || v2 != nil || v3 != nil || v4 != nil,
let c1 = v1 ?? prev1,
let c2 = v2 ?? prev2,
let c3 = v3 ?? prev3,
let c4 = v4 ?? prev4
{
return (c1, c2, c3, c4)
} else {
return nil
}
}
return AnyValueReducer(fetch: fetch, value: value)
}
private func _combine<R1: ValueReducer, R2: ValueReducer, R3: ValueReducer, R4: ValueReducer, R5: ValueReducer>(
_ r1: R1,
_ r2: R2,
_ r3: R3,
_ r4: R4,
_ r5: R5)
-> AnyValueReducer<
(R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched, R5.Fetched),
(R1.Value, R2.Value, R3.Value, R4.Value, R5.Value)>
{
var r1 = r1
var r2 = r2
var r3 = r3
var r4 = r4
var r5 = r5
var prev1: R1.Value?
var prev2: R2.Value?
var prev3: R3.Value?
var prev4: R4.Value?
var prev5: R5.Value?
func fetch(db: Database) throws -> (R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched, R5.Fetched) {
return try (
r1.fetch(db),
r2.fetch(db),
r3.fetch(db),
r4.fetch(db),
r5.fetch(db))
}
func value(tuple: (R1.Fetched, R2.Fetched, R3.Fetched, R4.Fetched, R5.Fetched)) -> (R1.Value, R2.Value, R3.Value, R4.Value, R5.Value)? {
let v1 = r1.value(tuple.0)
let v2 = r2.value(tuple.1)
let v3 = r3.value(tuple.2)
let v4 = r4.value(tuple.3)
let v5 = r5.value(tuple.4)
defer {
if let v1 = v1 { prev1 = v1 }
if let v2 = v2 { prev2 = v2 }
if let v3 = v3 { prev3 = v3 }
if let v4 = v4 { prev4 = v4 }
if let v5 = v5 { prev5 = v5 }
}
if v1 != nil || v2 != nil || v3 != nil || v4 != nil || v5 != nil,
let c1 = v1 ?? prev1,
let c2 = v2 ?? prev2,
let c3 = v3 ?? prev3,
let c4 = v4 ?? prev4,
let c5 = v5 ?? prev5
{
return (c1, c2, c3, c4, c5)
} else {
return nil
}
}
return AnyValueReducer(fetch: fetch, value: value)
}
@@ -0,0 +1,44 @@
extension ValueObservation where Reducer: ValueReducer {
/// Returns a ValueObservation which notifies the non-nil results of calling
/// the given transformation which each element notified by this
/// value observation.
public func compactMap<T>(_ transform: @escaping (Reducer.Value) -> T?)
-> ValueObservation<CompactMapValueReducer<Reducer, T>>
{
return mapReducer { $1.compactMap(transform) }
}
}
extension ValueReducer {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns a reducer which outputs the non-nil results of calling the given
/// transformation which each element emitted by this reducer.
public func compactMap<T>(_ transform: @escaping (Value) -> T?) -> CompactMapValueReducer<Self, T> {
return CompactMapValueReducer(self, transform)
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// See ValueReducer.compactMap(_:)
///
/// :nodoc:
public struct CompactMapValueReducer<Base: ValueReducer, T>: ValueReducer {
private var base: Base
private let transform: (Base.Value) -> T?
init(_ base: Base, _ transform: @escaping (Base.Value) -> T?) {
self.base = base
self.transform = transform
}
public func fetch(_ db: Database) throws -> Base.Fetched {
return try base.fetch(db)
}
public mutating func value(_ fetched: Base.Fetched) -> T? {
guard let value = base.value(fetched) else { return nil }
return transform(value)
}
}
@@ -0,0 +1,34 @@
extension ValueObservation where Reducer == Void {
// MARK: - Count Observation
/// Creates a ValueObservation which observes *request*, and notifies its
/// count whenever it is modified by a database transaction.
///
/// For example:
///
/// let request = Player.all()
/// let observation = ValueObservation.trackingCount(request)
///
/// let observer = try observation.start(in: dbQueue) { count: Int in
/// print("Number of players has changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingCount<Request: FetchRequest>(_ request: Request)
-> ValueObservation<DistinctUntilChangedValueReducer<RawValueReducer<Int>>>
{
// TODO: Remove distinctUntilChanged in GRDB 4
return ValueObservation.tracking(request, fetch: request.fetchCount).distinctUntilChanged()
}
}
@@ -0,0 +1,214 @@
extension ValueObservation where Reducer == Void {
// MARK: - DatabaseValueConvertible Observation
/// Creates a ValueObservation which observes *request*, and notifies
/// fresh values whenever the request is modified by a
/// database transaction.
///
/// For example:
///
/// let request = Player.select(Column("name"), as: String.self)
/// let observation = ValueObservation.trackingAll(request)
///
/// let observer = try observation.start(in: dbQueue) { names: [String] in
/// print("Player names have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingAll<Request: FetchRequest>(_ request: Request)
-> ValueObservation<DatabaseValuesReducer<Request>>
where Request.RowDecoder: DatabaseValueConvertible
{
return ValueObservation<DatabaseValuesReducer<Request>>.tracking(request, reducer: { _ in
DatabaseValuesReducer(request: request) }
)
}
/// Creates a ValueObservation which observes *request*, and notifies a
/// fresh value whenever the request is modified by a database transaction.
///
/// For example:
///
/// let request = Player.select(max(Column("score")), as: Int.self)
/// let observation = ValueObservation.trackingOne(request)
///
/// let observer = try observation.start(in: dbQueue) { maxScore: Int? in
/// print("Maximum score has changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingOne<Request: FetchRequest>(_ request: Request)
-> ValueObservation<DatabaseValueReducer<Request>>
where Request.RowDecoder: DatabaseValueConvertible
{
return ValueObservation<DatabaseValueReducer<Request>>.tracking(request, reducer: { _ in DatabaseValueReducer(request: request)
})
}
/// Creates a ValueObservation which observes *request*, and notifies
/// fresh values whenever the request is modified by a
/// database transaction.
///
/// For example:
///
/// let request = Player.select(Column("name"), as: Optional<String>.self)
/// let observation = ValueObservation.trackingAll(request)
///
/// let observer = try observation.start(in: dbQueue) { names: [String?] in
/// print("Player names have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingAll<Request: FetchRequest>(_ request: Request)
-> ValueObservation<OptionalDatabaseValuesReducer<Request>>
where Request.RowDecoder: _OptionalProtocol,
Request.RowDecoder._Wrapped: DatabaseValueConvertible
{
return ValueObservation<OptionalDatabaseValuesReducer<Request>>.tracking(request, reducer: { _ in
OptionalDatabaseValuesReducer(request: request)
})
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs arrays of values, filtering out consecutive
/// identical database values.
///
/// :nodoc:
public struct DatabaseValuesReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder: DatabaseValueConvertible
{
public let request: Request
private var previousDbValues: [DatabaseValue]?
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> [DatabaseValue] {
return try DatabaseValue.fetchAll(db, request)
}
public mutating func value(_ dbValues: [DatabaseValue]) -> [Request.RowDecoder]? {
if let previousDbValues = previousDbValues, previousDbValues == dbValues {
// Don't notify consecutive identical dbValue arrays
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousDbValues = dbValues
return dbValues.map {
Request.RowDecoder.decode(from: $0, conversionContext: nil)
}
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs optional values, filtering out consecutive
/// identical database values.
///
/// :nodoc:
public struct DatabaseValueReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder: DatabaseValueConvertible
{
public let request: Request
private var previousDbValue: DatabaseValue??
private var previousValueWasNil = false
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> DatabaseValue? {
return try DatabaseValue.fetchOne(db, request)
}
public mutating func value(_ dbValue: DatabaseValue?) -> Request.RowDecoder?? {
if let previousDbValue = previousDbValue, previousDbValue == dbValue {
// Don't notify consecutive identical dbValue
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousDbValue = dbValue
if let dbValue = dbValue,
let value = Request.RowDecoder.decodeIfPresent(from: dbValue, conversionContext: nil)
{
previousValueWasNil = false
return .some(value)
} else if previousValueWasNil {
// Don't notify consecutive nil values
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
} else {
previousValueWasNil = true
return .some(nil)
}
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs arrays of optional values, filtering out consecutive
/// identical database values.
///
/// :nodoc:
public struct OptionalDatabaseValuesReducer<Request: FetchRequest>: ValueReducer
where
Request.RowDecoder: _OptionalProtocol,
Request.RowDecoder._Wrapped: DatabaseValueConvertible
{
public let request: Request
private var previousDbValues: [DatabaseValue]?
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> [DatabaseValue] {
return try DatabaseValue.fetchAll(db, request)
}
public mutating func value(_ dbValues: [DatabaseValue]) -> [Request.RowDecoder._Wrapped?]? {
if let previousDbValues = previousDbValues, previousDbValues == dbValues {
// Don't notify consecutive identical dbValue arrays
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousDbValues = dbValues
return dbValues.map {
Request.RowDecoder._Wrapped.decodeIfPresent(from: $0, conversionContext: nil)
}
}
}
@@ -0,0 +1,47 @@
extension ValueObservation where Reducer: ValueReducer, Reducer.Value: Equatable {
/// Returns a ValueObservation which filters out consecutive equal values.
public func distinctUntilChanged()
-> ValueObservation<DistinctUntilChangedValueReducer<Reducer>>
{
return mapReducer { $1.distinctUntilChanged() }
}
}
extension ValueReducer where Value: Equatable {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns a ValueReducer which filters out consecutive equal values.
public func distinctUntilChanged() -> DistinctUntilChangedValueReducer<Self> {
return DistinctUntilChangedValueReducer(self)
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// See ValueReducer.distinctUntilChanged()
///
/// :nodoc:
public struct DistinctUntilChangedValueReducer<Base: ValueReducer>: ValueReducer where Base.Value: Equatable {
private var base: Base
private var previousValue: Base.Value?
init(_ base: Base) {
self.base = base
}
public func fetch(_ db: Database) throws -> Base.Fetched {
return try base.fetch(db)
}
public mutating func value(_ fetched: Base.Fetched) -> Base.Value? {
guard let value = base.value(fetched) else {
return nil
}
if let previousValue = previousValue, previousValue == value {
// Don't notify consecutive identical values
return nil
}
self.previousValue = value
return value
}
}
@@ -0,0 +1,131 @@
extension ValueObservation where Reducer == Void {
// MARK: - FetchableRecord Observation
/// Creates a ValueObservation which observes *request*, and notifies
/// fresh records whenever the request is modified by a
/// database transaction.
///
/// For example:
///
/// let request = Player.all()
/// let observation = ValueObservation.trackingAll(request)
///
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingAll<Request: FetchRequest>(_ request: Request)
-> ValueObservation<FetchableRecordsReducer<Request>>
where Request.RowDecoder: FetchableRecord
{
return ValueObservation<FetchableRecordsReducer<Request>>.tracking(request, reducer: { _ in
FetchableRecordsReducer(request: request)
})
}
/// Creates a ValueObservation which observes *request*, and notifies a
/// fresh record whenever the request is modified by a database transaction.
///
/// For example:
///
/// let request = Player.filter(key: 1)
/// let observation = ValueObservation.trackingOne(request)
///
/// let observer = try observation.start(in: dbQueue) { player: Player? in
/// print("Player has changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingOne<Request: FetchRequest>(_ request: Request) ->
ValueObservation<FetchableRecordReducer<Request>>
where Request.RowDecoder: FetchableRecord
{
return ValueObservation<FetchableRecordReducer<Request>>.tracking(request, reducer: { _ in
FetchableRecordReducer(request: request)
})
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs arrays of records, filtering out consecutive
/// identical database rows.
///
/// :nodoc:
public struct FetchableRecordsReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder: FetchableRecord
{
public let request: Request
private var previousRows: [Row]?
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> [Row] {
return try Row.fetchAll(db, request)
}
public mutating func value(_ rows: [Row]) -> [Request.RowDecoder]? {
if let previousRows = previousRows, previousRows == rows {
// Don't notify consecutive identical row arrays
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousRows = rows
return rows.map(Request.RowDecoder.init(row:))
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs optional records, filtering out consecutive
/// identical database rows.
///
/// :nodoc:
public struct FetchableRecordReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder: FetchableRecord
{
public let request: Request
private var previousRow: Row??
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> Row? {
return try Row.fetchOne(db, request)
}
public mutating func value(_ row: Row?) -> Request.RowDecoder?? {
if let previousRow = previousRow, previousRow == row {
// Don't notify consecutive identical rows
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousRow = row
return .some(row.map(Request.RowDecoder.init(row:)))
}
}
@@ -0,0 +1,47 @@
extension ValueObservation where Reducer: ValueReducer {
/// Returns a ValueObservation which notifies the results of calling the
/// given transformation which each element notified by this
/// value observation.
public func map<T>(_ transform: @escaping (Reducer.Value) -> T)
-> ValueObservation<MapValueReducer<Reducer, T>>
{
return mapReducer { $1.map(transform) }
}
}
extension ValueReducer {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns a reducer which outputs the results of calling the given
/// transformation which each element emitted by this reducer.
public func map<T>(_ transform: @escaping (Value) -> T) -> MapValueReducer<Self, T> {
return MapValueReducer(self, transform)
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A ValueReducer whose values consist of those in a Base ValueReducer passed
/// through a transform function.
///
/// See ValueReducer.map(_:)
///
/// :nodoc:
public struct MapValueReducer<Base: ValueReducer, T>: ValueReducer {
private var base: Base
private let transform: (Base.Value) -> T
init(_ base: Base, _ transform: @escaping (Base.Value) -> T) {
self.base = base
self.transform = transform
}
public func fetch(_ db: Database) throws -> Base.Fetched {
return try base.fetch(db)
}
public mutating func value(_ fetched: Base.Fetched) -> T? {
guard let value = base.value(fetched) else { return nil }
return transform(value)
}
}
@@ -0,0 +1,15 @@
extension ValueObservation {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns a ValueObservation with a transformed reducer.
public func mapReducer<R>(_ transform: @escaping (Database, Reducer) throws -> R) -> ValueObservation<R> {
let makeReducer = self.makeReducer
var observation = ValueObservation<R>(
tracking: observedRegion,
reducer: { db in try transform(db, makeReducer(db)) })
observation.extent = extent
observation.scheduling = scheduling
observation.requiresWriteAccess = requiresWriteAccess
return observation
}
}
@@ -0,0 +1,129 @@
extension ValueObservation where Reducer == Void {
// MARK: - Row Observation
/// Creates a ValueObservation which observes *request*, and notifies
/// fresh rows whenever the request is modified by a database transaction.
///
/// For example:
///
/// let request = SQLRequest<Row>("SELECT * FROM player")
/// let observation = ValueObservation.trackingAll(request)
///
/// let observer = try observation.start(in: dbQueue) { rows: [Row] in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingAll<Request: FetchRequest>(_ request: Request)
-> ValueObservation<RowsReducer<Request>>
where Request.RowDecoder == Row
{
return ValueObservation<RowsReducer<Request>>.tracking(request, reducer: { _ in
RowsReducer(request: request)
})
}
/// Creates a ValueObservation which observes *request*, and notifies a
/// fresh row whenever the request is modified by a database transaction.
///
/// For example:
///
/// let request = SQLRequest<Row>("SELECT * FROM player WHERE id = ?", arguments: [1])
/// let observation = ValueObservation.trackingOne(request)
///
/// let observer = try observation.start(in: dbQueue) { row: Row? in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter request: the observed request.
/// - returns: a ValueObservation.
public static func trackingOne<Request: FetchRequest>(_ request: Request)
-> ValueObservation<RowReducer<Request>>
where Request.RowDecoder == Row
{
return ValueObservation<RowReducer<Request>>.tracking(request, reducer: { _ in
RowReducer(request: request)
})
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs arrays of database rows, filtering out
/// consecutive identical arrays.
///
/// :nodoc:
public struct RowsReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder == Row
{
public let request: Request
private var previousRows: [Row]?
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> [Row] {
return try request.fetchAll(db)
}
public mutating func value(_ rows: [Row]) -> [Row]? {
if let previousRows = previousRows, previousRows == rows {
// Don't notify consecutive identical row arrays
return nil
}
self.previousRows = rows
return rows
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs optional records, filtering out consecutive
/// identical database rows.
///
/// :nodoc:
public struct RowReducer<Request: FetchRequest>: ValueReducer
where Request.RowDecoder == Row
{
public let request: Request
private var previousRow: Row??
init(request: Request) {
self.request = request
}
public func fetch(_ db: Database) throws -> Row? {
return try request.fetchOne(db)
}
public mutating func value(_ row: Row?) -> Row?? {
if let previousRow = previousRow, previousRow == row {
// Don't notify consecutive identical rows
// TODO: Remove this implicit `distinctUntilDatabaseChanged` in GRDB 4
return nil
}
self.previousRow = row
return row
}
}
@@ -0,0 +1,445 @@
import Dispatch
// MARK: - ValueScheduling
/// ValueScheduling controls how ValueObservation schedules the notifications
/// of fresh values to your application.
public enum ValueScheduling {
/// All values are notified on the main queue.
///
/// If the observation starts on the main queue, an initial value is
/// notified right upon subscription, synchronously:
///
/// // On main queue
/// let observation = ValueObservation.trackingAll(Player.all())
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
/// // <- here "fresh players" is already printed.
///
/// If the observation does not start on the main queue, an initial value
/// is also notified on the main queue, but asynchronously:
///
/// // Not on the main queue: "fresh players" is eventually printed
/// // on the main queue.
/// let observation = ValueObservation.trackingAll(Player.all())
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
///
/// When the database changes, fresh values are asynchronously notified on
/// the main queue:
///
/// // Eventually prints "fresh players" on the main queue
/// try dbQueue.write { db in
/// try Player(...).insert(db)
/// }
case mainQueue
/// All values are asychronously notified on the specified queue.
///
/// An initial value is fetched and notified if `startImmediately`
/// is true.
case onQueue(DispatchQueue, startImmediately: Bool)
/// Values are not all notified on the same dispatch queue.
///
/// If `startImmediately` is true, an initial value is notified right upon
/// subscription, synchronously, on the dispatch queue which starts
/// the observation.
///
/// // On any queue
/// var observation = ValueObservation.trackingAll(Player.all())
/// observation.scheduling = .unsafe(startImmediately: true)
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
/// // <- here "fresh players" is already printed.
///
/// When the database changes, other values are notified on
/// unspecified queues.
case unsafe(startImmediately: Bool)
}
// MARK: - ValueObservation
/// ValueObservation tracks changes in the results of database requests, and
/// notifies fresh values whenever the database changes.
///
/// For example:
///
/// let observation = ValueObservation.trackingAll(Player.all)
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("Players have changed.")
/// }
public struct ValueObservation<Reducer> {
/// A closure that is evaluated when the observation starts, and returns
/// the observed database region.
var observedRegion: (Database) throws -> DatabaseRegion
/// The reducer is created when observation starts, and is triggered upon
/// each database change in *observedRegion*.
var makeReducer: (Database) throws -> Reducer
/// Default is false. Set this property to true when the observation
/// requires write access in order to fetch fresh values. Fetches are then
/// wrapped inside a savepoint.
///
/// Don't set this flag to true unless you really need it. A read/write
/// observation is less efficient than a read-only observation.
public var requiresWriteAccess: Bool = false
/// The extent of the database observation. The default is
/// `.observerLifetime`: the observation lasts until the
/// observer returned by the `start(in:onError:onChange:)` method
/// is deallocated.
public var extent = Database.TransactionObservationExtent.observerLifetime
/// `scheduling` controls how fresh values are notified. Default
/// is `.mainQueue`.
///
/// - `.mainQueue`: all values are notified on the main queue.
///
/// If the observation starts on the main queue, an initial value is
/// notified right upon subscription, synchronously::
///
/// // On main queue
/// let observation = ValueObservation.trackingAll(Player.all())
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
/// // <- here "fresh players" is already printed.
///
/// If the observation does not start on the main queue, an initial
/// value is also notified on the main queue, but asynchronously:
///
/// // Not on the main queue: "fresh players" is eventually printed
/// // on the main queue.
/// let observation = ValueObservation.trackingAll(Player.all())
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
///
/// When the database changes, fresh values are asynchronously notified:
///
/// // Eventually prints "fresh players" on the main queue
/// try dbQueue.write { db in
/// try Player(...).insert(db)
/// }
///
/// - `.onQueue(_:startImmediately:)`: all values are asychronously notified
/// on the specified queue.
///
/// An initial value is fetched and notified if `startImmediately`
/// is true.
///
/// - `unsafe(startImmediately:)`: values are not all notified on the same
/// dispatch queue.
///
/// If `startImmediately` is true, an initial value is notified right
/// upon subscription, synchronously, on the dispatch queue which starts
/// the observation.
///
/// // On any queue
/// var observation = ValueObservation.trackingAll(Player.all())
/// observation.scheduling = .unsafe(startImmediately: true)
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("fresh players: \(players)")
/// }
/// // <- here "fresh players" is already printed.
///
/// When the database changes, other values are notified on
/// unspecified queues.
public var scheduling: ValueScheduling = .mainQueue
/// The dispatch queue where change callbacks are called.
var notificationQueue: DispatchQueue? {
switch scheduling {
case .mainQueue:
return DispatchQueue.main
case .onQueue(let queue, startImmediately: _):
return queue
case .unsafe:
return nil
}
}
// Not public because we foster DatabaseRegionConvertible.
// See ValueObservation.tracking(_:reducer:)
init(
tracking region: @escaping (Database) throws -> DatabaseRegion,
reducer: @escaping (Database) throws -> Reducer)
{
self.observedRegion = { db in
// Remove views from the observed region.
//
// We can do it because we are only interested in modifications in
// actual tables. And we want to do it because we have a fast path
// for simple regions that span a single table.
let views = try db.schema().names(ofType: .view)
return try region(db).ignoring(views)
}
self.makeReducer = reducer
}
}
extension ValueObservation where Reducer: ValueReducer {
// MARK: - Starting Observation
/// Starts the value observation in the provided database reader (such as
/// a database queue or database pool), and returns a transaction observer.
///
/// - parameter reader: A DatabaseReader.
/// - parameter onError: A closure that is provided eventual errors that
/// happen during observation
/// - parameter onChange: A closure that is provided fresh values
/// - returns: a TransactionObserver
public func start(
in reader: DatabaseReader,
onError: ((Error) -> Void)? = nil,
onChange: @escaping (Reducer.Value) -> Void) throws -> TransactionObserver
{
return try reader.add(observation: self, onError: onError, onChange: onChange)
}
}
extension ValueObservation {
// MARK: - Creating ValueObservation from ValueReducer
/// Returns a ValueObservation which observes *regions*, and notifies the
/// values returned by the *reducer* whenever one of the observed
/// regions is modified by a database transaction.
///
/// This method is the most fundamental way to create a ValueObservation.
///
/// For example, this observation counts the number of a times the player
/// table is modified:
///
/// var count = 0
/// let reducer = AnyValueReducer(
/// fetch: { _ in },
/// value: { _ -> Int? in
/// count += 1
/// return count })
/// let observation = ValueObservation.tracking(Player.all(), reducer: reducer)
/// let observer = observation.start(in: dbQueue) { count: Int in
/// print("Players have been modified \(count) times.")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter reducer: A reducer that turns database changes in the
/// modified regions into fresh values. Currently only reducers that adopt
/// the ValueReducer protocol are supported.
@available(*, deprecated, message: "Provide the reducer in a (Database) -> Reducer closure")
public static func tracking(
_ regions: DatabaseRegionConvertible...,
reducer: Reducer)
-> ValueObservation
{
return ValueObservation.tracking(regions, reducer: { _ in reducer })
}
/// Returns a ValueObservation which observes *regions*, and notifies the
/// values returned by the *reducer* whenever one of the observed
/// regions is modified by a database transaction.
///
/// This method is the most fundamental way to create a ValueObservation.
///
/// For example, this observation counts the number of a times the player
/// table is modified:
///
/// var count = 0
/// let reducer = AnyValueReducer(
/// fetch: { _ in /* don't fetch anything */ },
/// value: { _ -> Int? in
/// defer { count += 1 }
/// return count })
/// let observation = ValueObservation.tracking(Player.all(), reducer: { db in reducer })
/// let observer = observation.start(in: dbQueue) { count: Int in
/// print("Players have been modified \(count) times.")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter reducer: A reducer that turns database changes in the
/// modified regions into fresh values. Currently only reducers that adopt
/// the ValueReducer protocol are supported.
public static func tracking(
_ regions: DatabaseRegionConvertible...,
reducer: @escaping (Database) throws -> Reducer)
-> ValueObservation
{
return ValueObservation.tracking(regions, reducer: reducer)
}
/// Returns a ValueObservation which observes *regions*, and notifies the
/// values returned by the *reducer* whenever one of the observed
/// regions is modified by a database transaction.
///
/// This method is the most fundamental way to create a ValueObservation.
///
/// For example, this observation counts the number of a times the player
/// table is modified:
///
/// var count = 0
/// let reducer = AnyValueReducer(
/// fetch: { _ in /* don't fetch anything */ },
/// value: { _ -> Int? in
/// defer { count += 1 }
/// return count })
/// let observation = ValueObservation.tracking([Player.all()], reducer: { db in reducer })
/// let observer = observation.start(in: dbQueue) { count: Int in
/// print("Players have been modified \(count) times.")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter reducer: A reducer that turns database changes in the
/// modified regions into fresh values. Currently only reducers that adopt
/// the ValueReducer protocol are supported.
public static func tracking(
_ regions: [DatabaseRegionConvertible],
reducer: @escaping (Database) throws -> Reducer)
-> ValueObservation
{
return ValueObservation(
tracking: DatabaseRegion.union(regions),
reducer: reducer)
}
}
extension ValueObservation where Reducer == Void {
// MARK: - Creating ValueObservation from Fetch Closures
/// Creates a ValueObservation which observes *regions*, and notifies the
/// values returned by the *fetch* closure whenever one of the observed
/// regions is modified by a database transaction.
///
/// For example:
///
/// let observation = ValueObservation.tracking(
/// Player.all(),
/// fetch: { db in return try Player.fetchAll(db) })
///
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter fetch: A closure that fetches a value.
public static func tracking<Value>(
_ regions: DatabaseRegionConvertible...,
fetch: @escaping (Database) throws -> Value)
-> ValueObservation<RawValueReducer<Value>>
{
return ValueObservation.tracking(regions, fetch: fetch)
}
/// Creates a ValueObservation which observes *regions*, and notifies the
/// values returned by the *fetch* closure whenever one of the observed
/// regions is modified by a database transaction.
///
/// For example:
///
/// let observation = ValueObservation.tracking(
/// [Player.all()],
/// fetch: { db in return try Player.fetchAll(db) })
///
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter fetch: A closure that fetches a value.
public static func tracking<Value>(
_ regions: [DatabaseRegionConvertible],
fetch: @escaping (Database) throws -> Value)
-> ValueObservation<RawValueReducer<Value>>
{
return ValueObservation<RawValueReducer<Value>>(
tracking: DatabaseRegion.union(regions),
reducer: { _ in RawValueReducer(fetch) })
}
/// Creates a ValueObservation which observes *regions*, and notifies the
/// values returned by the *fetch* closure whenever one of the observed
/// regions is modified by a database transaction. Consecutive equal values
/// are filtered out.
///
/// For example:
///
/// let observation = ValueObservation.tracking(
/// Player.all(),
/// fetchDistinct: { db in return try Player.fetchAll(db) })
///
/// let observer = try observation.start(in: dbQueue) { players: [Player] in
/// print("Players have changed")
/// }
///
/// The returned observation has the default configuration:
///
/// - When started with the `start(in:onError:onChange:)` method, a fresh
/// value is immediately notified on the main queue.
/// - Upon subsequent database changes, fresh values are notified on the
/// main queue.
/// - The observation lasts until the observer returned by
/// `start` is deallocated.
///
/// - parameter regions: A list of observed regions.
/// - parameter fetch: A closure that fetches a value.
@available(*, deprecated, message: "Use distinctUntilChanged() instead")
public static func tracking<Value>(
_ regions: DatabaseRegionConvertible...,
fetchDistinct fetch: @escaping (Database) throws -> Value)
-> ValueObservation<DistinctUntilChangedValueReducer<RawValueReducer<Value>>>
where Value: Equatable
{
return ValueObservation.tracking(regions, fetch: fetch).distinctUntilChanged()
}
}
+87
View File
@@ -0,0 +1,87 @@
import Foundation
/// Support for ValueObservation.
/// See DatabaseWriter.add(observation:onError:onChange:)
class ValueObserver<Reducer: ValueReducer>: TransactionObserver {
/* private */ let region: DatabaseRegion // Internal for testability
private var reducer: Reducer
private let fetch: (Database, Reducer) -> Future<Reducer.Fetched>
private let notificationQueue: DispatchQueue?
private let onError: ((Error) -> Void)?
private let onChange: (Reducer.Value) -> Void
private let reduceQueue: DispatchQueue
private var isChanged = false
init(
region: DatabaseRegion,
reducer: Reducer,
configuration: Configuration,
fetch: @escaping (Database, Reducer) -> Future<Reducer.Fetched>,
notificationQueue: DispatchQueue?,
onError: ((Error) -> Void)?,
onChange: @escaping (Reducer.Value) -> Void)
{
self.region = region
self.reducer = reducer
self.fetch = fetch
self.notificationQueue = notificationQueue
self.onChange = onChange
self.onError = onError
self.reduceQueue = configuration.makeDispatchQueue(defaultLabel: "GRDB", purpose: "ValueObservation.reducer")
}
func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
return region.isModified(byEventsOfKind: eventKind)
}
func databaseDidChange(with event: DatabaseEvent) {
if region.isModified(by: event) {
isChanged = true
stopObservingDatabaseChangesUntilNextTransaction()
}
}
func databaseDidCommit(_ db: Database) {
guard isChanged else { return }
isChanged = false
// Grab future fetched values from the database writer queue
let future = fetch(db, reducer)
// Wait for future fetched values in reduceQueue. This guarantees:
// - that notifications have the same ordering as transactions.
// - that expensive reduce operations are computed without blocking
// any database dispatch queue.
reduceQueue.async { [weak self] in
// Never ever retain self so that notifications stop when self
// is deallocated by the user.
do {
if let value = try self?.reducer.value(future.wait()) {
if let queue = self?.notificationQueue {
queue.async {
self?.onChange(value)
}
} else {
self?.onChange(value)
}
}
} catch {
guard self?.onError != nil else {
// TODO: how can we let the user know about the error?
return
}
if let queue = self?.notificationQueue {
queue.async {
self?.onError?(error)
}
} else {
self?.onError?(error)
}
}
}
}
func databaseDidRollback(_ db: Database) {
isChanged = false
}
}
+92
View File
@@ -0,0 +1,92 @@
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The ValueReducer protocol supports ValueObservation.
public protocol ValueReducer {
/// The type of fetched database values
associatedtype Fetched
/// The type of observed values
associatedtype Value
/// Feches database values upon changes in an observed database region.
func fetch(_ db: Database) throws -> Fetched
/// Transforms a fetched value into an eventual observed value. Returns nil
/// when observer should not be notified.
///
/// This method runs inside a private dispatch queue.
mutating func value(_ fetched: Fetched) -> Value?
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A type-erased ValueReducer.
///
/// An AnyValueReducer forwards its operations to an underlying reducer,
/// hiding its specifics.
public struct AnyValueReducer<Fetched, Value>: ValueReducer {
private var _fetch: (Database) throws -> Fetched
private var _value: (Fetched) -> Value?
/// Creates a reducer whose `fetch(_:)` and `value(_:)` methods wrap and
/// forward operations the argument closures.
///
/// For example, this reducer counts the number of a times the player table
/// is modified:
///
/// var count = 0
/// let reducer = AnyValueReducer(
/// fetch: { _ in },
/// value: { _ -> Int? in
/// count += 1
/// return count
/// })
/// let observer = ValueObservation
/// .tracking(Player.all(), reducer: reducer)
/// .start(in: dbQueue) { count: Int in
/// print("Players have been modified \(count) times.")
/// }
public init(fetch: @escaping (Database) throws -> Fetched, value: @escaping (Fetched) -> Value?) {
self._fetch = fetch
self._value = value
}
/// Creates a reducer that wraps and forwards operations to `reducer`.
public init<Base: ValueReducer>(_ reducer: Base) where Base.Fetched == Fetched, Base.Value == Value {
var reducer = reducer
self._fetch = { try reducer.fetch($0) }
self._value = { reducer.value($0) }
}
/// :nodoc:
public func fetch(_ db: Database) throws -> Fetched {
return try _fetch(db)
}
/// :nodoc:
public func value(_ fetched: Fetched) -> Value? {
return _value(fetched)
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A reducer which outputs raw values.
///
/// :nodoc:
public struct RawValueReducer<Value>: ValueReducer {
private let _fetch: (Database) throws -> Value
public init(_ fetch: @escaping (Database) throws -> Value) {
self._fetch = fetch
}
public func fetch(_ db: Database) throws -> Value {
return try _fetch(db)
}
public func value(_ fetched: Value) -> Value? {
return fetched
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDBCipher'
s.version = '3.3.0'
s.version = '3.6.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
+264 -2
View File
@@ -89,6 +89,26 @@
560FC5A71CB00B880014AA8E /* GRDBTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */; };
560FC5B21CB031E30014AA8E /* StatementColumnConvertibleFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E8CE0F1BB4FE5B00828BEC /* StatementColumnConvertibleFetchTests.swift */; };
560FC5B31CB031EA0014AA8E /* DataMemoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56EB0AB11BCD787300A3DC55 /* DataMemoryTests.swift */; };
5613ED7B21A95E8400DC7A68 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7321A95E8400DC7A68 /* ValueObservation.swift */; };
5613ED7C21A95E8400DC7A68 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7321A95E8400DC7A68 /* ValueObservation.swift */; };
5613ED7D21A95E8400DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7421A95E8400DC7A68 /* ValueObservation+Combine.swift */; };
5613ED7E21A95E8400DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7421A95E8400DC7A68 /* ValueObservation+Combine.swift */; };
5613ED7F21A95E8400DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7521A95E8400DC7A68 /* ValueObservation+Map.swift */; };
5613ED8021A95E8400DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7521A95E8400DC7A68 /* ValueObservation+Map.swift */; };
5613ED8121A95E8400DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7621A95E8400DC7A68 /* ValueObservation+Row.swift */; };
5613ED8221A95E8400DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7621A95E8400DC7A68 /* ValueObservation+Row.swift */; };
5613ED8321A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7721A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED8421A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7721A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED8521A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7821A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED8621A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7821A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED8721A95E8400DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7921A95E8400DC7A68 /* ValueReducer.swift */; };
5613ED8821A95E8400DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7921A95E8400DC7A68 /* ValueReducer.swift */; };
5613ED8921A95E8400DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7A21A95E8400DC7A68 /* ValueObservation+Count.swift */; };
5613ED8A21A95E8400DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED7A21A95E8400DC7A68 /* ValueObservation+Count.swift */; };
5613ED9E21A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */; };
5613ED9F21A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */; };
5613EDA021A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */; };
5613EDA121A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */; };
561667021D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
561667031D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
561667061D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
@@ -180,6 +200,56 @@
5634B10C1CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */; };
5636E9BD1D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
5636E9C01D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
563B06E12185E07200B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */; };
563B06E22185E07200B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */; };
563B06E32185E07300B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */; };
563B06E42185E07300B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */; };
563B06E52185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06E62185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06E72185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06E82185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06E92185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */; };
563B06EA2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */; };
563B06EB2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */; };
563B06EC2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */; };
563B06ED2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */; };
563B06EE2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */; };
563B06EF2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */; };
563B06F02185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */; };
563B06F12185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06F22185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06F32185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06F42185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06FA21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */; };
563B06FB21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */; };
563B06FC21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */; };
563B06FD21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */; };
563B07082186280600B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B07072186280500B38F35 /* ValueObservationRowTests.swift */; };
563B07092186280600B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B07072186280500B38F35 /* ValueObservationRowTests.swift */; };
563B070A2186280600B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B07072186280500B38F35 /* ValueObservationRowTests.swift */; };
563B070B2186280600B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B07072186280500B38F35 /* ValueObservationRowTests.swift */; };
563B070D21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */; };
563B070E21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */; };
563B070F21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */; };
563B071021862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */; };
563B071E21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563B071F21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563B072021862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563B072121862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563EF424215F8A88007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF422215F8A88007DAACD /* OrderedDictionary.swift */; };
563EF425215F8A88007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF422215F8A88007DAACD /* OrderedDictionary.swift */; };
563EF43C2161183E007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF43A2161183E007DAACD /* AssociationAggregate.swift */; };
563EF43D2161183E007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF43A2161183E007DAACD /* AssociationAggregate.swift */; };
563EF44521613213007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44421613212007DAACD /* AssociationAggregateTests.swift */; };
563EF44621613213007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44421613212007DAACD /* AssociationAggregateTests.swift */; };
563EF44721613213007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44421613212007DAACD /* AssociationAggregateTests.swift */; };
563EF44821613213007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44421613212007DAACD /* AssociationAggregateTests.swift */; };
563EF4502161F1A8007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44F2161F1A7007DAACD /* Inflections.swift */; };
563EF4512161F1A8007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44F2161F1A7007DAACD /* Inflections.swift */; };
563EF45921631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45A21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45B21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45C21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */; };
564448841EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */; };
564448851EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */; };
564448881EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */; };
@@ -190,6 +260,28 @@
5644DE8320F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE8120F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift */; };
5644DE8420F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE8120F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift */; };
5644DE8520F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE8120F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift */; };
564CE44021AA957000652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43F21AA957000652B19 /* ValueObserver.swift */; };
564CE44121AA957000652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43F21AA957000652B19 /* ValueObserver.swift */; };
564CE4DD21B2DEF700652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4DC21B2DEF700652B19 /* ValueObservation+CompactMap.swift */; };
564CE4DE21B2DEF700652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4DC21B2DEF700652B19 /* ValueObservation+CompactMap.swift */; };
564CE4EC21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4ED21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4EE21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4EF21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4F121B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */; };
564CE4F221B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */; };
564CE4F321B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */; };
564CE4F421B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */; };
564CE52621B312B500652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE51A21B3128400652B19 /* ValueObservation+MapReducer.swift */; };
564CE52721B312B700652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE51A21B3128400652B19 /* ValueObservation+MapReducer.swift */; };
564CE5A621B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5A421B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE5A721B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5A421B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE5BB21B8FBFD00652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5B921B8FBFD00652B19 /* DatabaseRegionObservation.swift */; };
564CE5BC21B8FBFD00652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5B921B8FBFD00652B19 /* DatabaseRegionObservation.swift */; };
564CE5C121B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */; };
564CE5C221B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */; };
564CE5C321B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */; };
564CE5C421B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */; };
564E73EF203DA2A2000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73EB203DA29B000C443C /* JoinSupportTests.swift */; };
564E73F0203DA2A3000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73EB203DA29B000C443C /* JoinSupportTests.swift */; };
564E73F1203DA2A3000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73EB203DA29B000C443C /* JoinSupportTests.swift */; };
@@ -946,6 +1038,15 @@
560FC54D1CB003810014AA8E /* GRDBCipher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDBCipher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
560FC5501CB004AD0014AA8E /* sqlcipher.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = sqlcipher.xcodeproj; path = SQLCipher/src/sqlcipher.xcodeproj; sourceTree = "<group>"; };
560FC5B01CB00B880014AA8E /* GRDBCipherOSXTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCipherOSXTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5613ED7321A95E8400DC7A68 /* ValueObservation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservation.swift; sourceTree = "<group>"; };
5613ED7421A95E8400DC7A68 /* ValueObservation+Combine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Combine.swift"; sourceTree = "<group>"; };
5613ED7521A95E8400DC7A68 /* ValueObservation+Map.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Map.swift"; sourceTree = "<group>"; };
5613ED7621A95E8400DC7A68 /* ValueObservation+Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Row.swift"; sourceTree = "<group>"; };
5613ED7721A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+FetchableRecord.swift"; sourceTree = "<group>"; };
5613ED7821A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DatabaseValueConvertible.swift"; sourceTree = "<group>"; };
5613ED7921A95E8400DC7A68 /* ValueReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueReducer.swift; sourceTree = "<group>"; };
5613ED7A21A95E8400DC7A68 /* ValueObservation+Count.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Count.swift"; sourceTree = "<group>"; };
5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCombineTests.swift; sourceTree = "<group>"; };
561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDecimalNumberTests.swift; sourceTree = "<group>"; };
5616AAF8207CD5A900AC3664 /* RequestProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestProtocols.swift; sourceTree = "<group>"; };
562393171DECC02000A6B01F /* RowFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFetchTests.swift; sourceTree = "<group>"; };
@@ -974,10 +1075,32 @@
563363D41C94484E000BE133 /* DatabaseQueueReleaseMemoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueueReleaseMemoryTests.swift; sourceTree = "<group>"; };
5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverSavepointsTests.swift; sourceTree = "<group>"; };
5636E9BB1D22574100B9B05F /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationExtentTests.swift; sourceTree = "<group>"; };
563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationReadonlyTests.swift; sourceTree = "<group>"; };
563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationFetchTests.swift; sourceTree = "<group>"; };
563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationReducerTests.swift; sourceTree = "<group>"; };
563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationSchedulingTests.swift; sourceTree = "<group>"; };
563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCountTests.swift; sourceTree = "<group>"; };
563B07072186280500B38F35 /* ValueObservationRowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRowTests.swift; sourceTree = "<group>"; };
563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRecordTests.swift; sourceTree = "<group>"; };
563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationDatabaseValueConvertibleTests.swift; sourceTree = "<group>"; };
563EF422215F8A88007DAACD /* OrderedDictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedDictionary.swift; sourceTree = "<group>"; };
563EF43A2161183E007DAACD /* AssociationAggregate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregate.swift; sourceTree = "<group>"; };
563EF44421613212007DAACD /* AssociationAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregateTests.swift; sourceTree = "<group>"; };
563EF44F2161F1A7007DAACD /* Inflections.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Inflections.swift; sourceTree = "<group>"; };
563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfacePromiseTests.swift; sourceTree = "<group>"; };
564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAfterNextTransactionCommitTests.swift; sourceTree = "<group>"; };
5644DE7A20F8C903001FFDDE /* DatabaseValueConversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConversion.swift; sourceTree = "<group>"; };
5644DE8120F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConversionErrorTests.swift; sourceTree = "<group>"; };
564A50C61BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCollationTests.swift; sourceTree = "<group>"; };
564CE43F21AA957000652B19 /* ValueObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObserver.swift; sourceTree = "<group>"; };
564CE4DC21B2DEF700652B19 /* ValueObservation+CompactMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+CompactMap.swift"; sourceTree = "<group>"; };
564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCompactMapTests.swift; sourceTree = "<group>"; };
564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationMapTests.swift; sourceTree = "<group>"; };
564CE51A21B3128400652B19 /* ValueObservation+MapReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+MapReducer.swift"; sourceTree = "<group>"; };
564CE5A421B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DistinctUntilChanged.swift"; sourceTree = "<group>"; };
564CE5B921B8FBFD00652B19 /* DatabaseRegionObservation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservation.swift; sourceTree = "<group>"; };
564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservationTests.swift; sourceTree = "<group>"; };
564E73EB203DA29B000C443C /* JoinSupportTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinSupportTests.swift; sourceTree = "<group>"; };
564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAggregateTests.swift; sourceTree = "<group>"; };
564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = "<group>"; };
@@ -1367,6 +1490,25 @@
name = Products;
sourceTree = "<group>";
};
5613ED7221A95E8400DC7A68 /* ValueObservation */ = {
isa = PBXGroup;
children = (
5613ED7321A95E8400DC7A68 /* ValueObservation.swift */,
5613ED7421A95E8400DC7A68 /* ValueObservation+Combine.swift */,
564CE4DC21B2DEF700652B19 /* ValueObservation+CompactMap.swift */,
5613ED7A21A95E8400DC7A68 /* ValueObservation+Count.swift */,
5613ED7821A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */,
564CE5A421B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift */,
5613ED7721A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift */,
5613ED7521A95E8400DC7A68 /* ValueObservation+Map.swift */,
564CE51A21B3128400652B19 /* ValueObservation+MapReducer.swift */,
5613ED7621A95E8400DC7A68 /* ValueObservation+Row.swift */,
564CE43F21AA957000652B19 /* ValueObserver.swift */,
5613ED7921A95E8400DC7A68 /* ValueReducer.swift */,
);
path = ValueObservation;
sourceTree = "<group>";
};
56176C581EACC2D8000F3F2B /* GRDBTests */ = {
isa = PBXGroup;
children = (
@@ -1380,6 +1522,7 @@
56300B5C1C53C38F005A543B /* QueryInterface */,
56A238251B9C74A90082EB20 /* Record */,
56176C9F1EACEE15000F3F2B /* Support */,
563B06F52185E07C00B38F35 /* ValueObservation */,
);
path = GRDBTests;
sourceTree = "<group>";
@@ -1448,6 +1591,7 @@
56300B601C53C42C005A543B /* FetchableRecord+QueryInterfaceRequestTests.swift */,
56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */,
5698AC021D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift */,
563EF45821631E51007DAACD /* QueryInterfacePromiseTests.swift */,
56300B5D1C53C38F005A543B /* QueryInterfaceRequestTests.swift */,
56300B841C54DC95005A543B /* Record+QueryInterfaceRequestTests.swift */,
566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */,
@@ -1499,10 +1643,30 @@
name = DatabaseQueue;
sourceTree = "<group>";
};
563B06F52185E07C00B38F35 /* ValueObservation */ = {
isa = PBXGroup;
children = (
5613ED9D21A96A6F00DC7A68 /* ValueObservationCombineTests.swift */,
564CE4EB21B2E08200652B19 /* ValueObservationCompactMapTests.swift */,
563B06F921861D8B00B38F35 /* ValueObservationCountTests.swift */,
563B071D21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */,
563B06DC2185E07100B38F35 /* ValueObservationExtentTests.swift */,
563B06DE2185E07200B38F35 /* ValueObservationFetchTests.swift */,
564CE4F021B2E08A00652B19 /* ValueObservationMapTests.swift */,
563B06DD2185E07200B38F35 /* ValueObservationReadonlyTests.swift */,
563B070C21862C3500B38F35 /* ValueObservationRecordTests.swift */,
563B06DF2185E07200B38F35 /* ValueObservationReducerTests.swift */,
563B07072186280500B38F35 /* ValueObservationRowTests.swift */,
563B06E02185E07200B38F35 /* ValueObservationSchedulingTests.swift */,
);
name = ValueObservation;
sourceTree = "<group>";
};
5653EB8420961FBF00F46237 /* Association */ = {
isa = PBXGroup;
children = (
5653EB8C20961FBF00F46237 /* Association.swift */,
563EF43A2161183E007DAACD /* AssociationAggregate.swift */,
5653EB8720961FBF00F46237 /* AssociationQuery.swift */,
5653EB8B20961FBF00F46237 /* AssociationRequest.swift */,
5653EB8520961FBF00F46237 /* BelongsToAssociation.swift */,
@@ -1517,6 +1681,7 @@
5653EBA420961FD300F46237 /* Association */ = {
isa = PBXGroup;
children = (
563EF44421613212007DAACD /* AssociationAggregateTests.swift */,
5653EBB220961FE800F46237 /* AssociationBelongsToDecodableRecordTests.swift */,
5653EBA720961FE600F46237 /* AssociationBelongsToFetchableRecordTests.swift */,
5653EBB320961FE800F46237 /* AssociationBelongsToRowScopeTests.swift */,
@@ -1538,10 +1703,12 @@
5659F4861EA8D94E004A4992 /* Utils */ = {
isa = PBXGroup;
children = (
5659F4871EA8D94E004A4992 /* Utils.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
563EF44F2161F1A7007DAACD /* Inflections.swift */,
563EF422215F8A88007DAACD /* OrderedDictionary.swift */,
5659F4971EA8D989004A4992 /* Pool.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
5659F49F1EA8D997004A4992 /* Result.swift */,
5659F4871EA8D94E004A4992 /* Utils.swift */,
);
path = Utils;
sourceTree = "<group>";
@@ -1631,6 +1798,7 @@
560A37A91C90084600949E71 /* DatabasePool */,
563363BB1C93FD32000BE133 /* DatabaseQueue */,
56EA86931C91DFE7002BB4DF /* DatabaseReaderTests.swift */,
564CE5C021B8FFD800652B19 /* DatabaseRegionObservationTests.swift */,
56C3F7521CF9F12400F6A361 /* DatabaseSavepointTests.swift */,
566A842F20413DCF00E50BFD /* DatabaseSnapshotTests.swift */,
56A238131B9C74A90082EB20 /* DatabaseTests.swift */,
@@ -1728,6 +1896,7 @@
56A238741B9C75030082EB20 /* DatabaseQueue.swift */,
563363BF1C942C04000BE133 /* DatabaseReader.swift */,
569EF0E8200D387000A9FA45 /* DatabaseRegion.swift */,
564CE5B921B8FBFD00652B19 /* DatabaseRegionObservation.swift */,
5695311E1C907A8C00CF1A2B /* DatabaseSchemaCache.swift */,
566A842720413D6E00E50BFD /* DatabaseSnapshot.swift */,
56A238751B9C75030082EB20 /* DatabaseValue.swift */,
@@ -1881,6 +2050,7 @@
56A2389F1B9C753B0082EB20 /* Record */,
DC37743319C8CFCE004FCF85 /* Supporting Files */,
5659F4861EA8D94E004A4992 /* Utils */,
5613ED7221A95E8400DC7A68 /* ValueObservation */,
);
path = GRDB;
sourceTree = "<group>";
@@ -2150,10 +2320,12 @@
buildActionMask = 2147483647;
files = (
56873BED1F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
563EF43C2161183E007DAACD /* AssociationAggregate.swift in Sources */,
56BF6D3E1DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5616AAF9207CD5A900AC3664 /* RequestProtocols.swift in Sources */,
5636E9BD1D22574100B9B05F /* FetchRequest.swift in Sources */,
56BB6EAA1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
563EF4502161F1A8007DAACD /* Inflections.swift in Sources */,
566B910A1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
566B91241FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
5653EB9B20961FC000F46237 /* AssociationRequest.swift in Sources */,
@@ -2164,20 +2336,25 @@
560FC51C1CB003810014AA8E /* QueryInterfaceRequest.swift in Sources */,
560FC51D1CB003810014AA8E /* SQLCollatedExpression.swift in Sources */,
5653EB9920961FC000F46237 /* ForeignKeyRequest.swift in Sources */,
5613ED8121A95E8400DC7A68 /* ValueObservation+Row.swift in Sources */,
566B91341FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
56D1215B1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
5613ED8921A95E8400DC7A68 /* ValueObservation+Count.swift in Sources */,
566475D41D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
5653EB9120961FC000F46237 /* HasOneAssociation.swift in Sources */,
56CEB5621EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56CEB4FB1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
5698AD361DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
564CE5A621B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
566B91141FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
560FC51F1CB003810014AA8E /* CGFloat.swift in Sources */,
5674A7091F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
5653EC17209873A400F46237 /* SQLExpression+QueryInterface.swift in Sources */,
564CE52621B312B500652B19 /* ValueObservation+MapReducer.swift in Sources */,
5659F4A11EA8D997004A4992 /* Result.swift in Sources */,
560FC5201CB003810014AA8E /* Date.swift in Sources */,
560FC5221CB003810014AA8E /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
563EF424215F8A88007DAACD /* OrderedDictionary.swift in Sources */,
560FC5231CB003810014AA8E /* Configuration.swift in Sources */,
566475CD1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */,
569EF0E9200D387000A9FA45 /* DatabaseRegion.swift in Sources */,
@@ -2197,6 +2374,7 @@
56B964B21DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */,
560FC5261CB003810014AA8E /* SerializedDatabase.swift in Sources */,
560FC5271CB003810014AA8E /* NSString.swift in Sources */,
564CE4DD21B2DEF700652B19 /* ValueObservation+CompactMap.swift in Sources */,
560FC5291CB003810014AA8E /* DatabaseValueConvertible.swift in Sources */,
56A8C2311D1914540096E9D4 /* UUID.swift in Sources */,
56CEB5021EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
@@ -2206,6 +2384,7 @@
5656BF5E20C7248700F98521 /* QueryOrdering.swift in Sources */,
56D51D011EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
566475BB1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
5613ED8721A95E8400DC7A68 /* ValueReducer.swift in Sources */,
560FC52B1CB003810014AA8E /* DatabaseValue.swift in Sources */,
5671FC211DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
560FC52E1CB003810014AA8E /* Record.swift in Sources */,
@@ -2214,6 +2393,7 @@
560FC5311CB003810014AA8E /* TableRecord.swift in Sources */,
56DAA2DC1DE9C827006E10C8 /* Cursor.swift in Sources */,
5674A6F11F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
5613ED8321A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
5644DE7C20F8C903001FFDDE /* DatabaseValueConversion.swift in Sources */,
560FC5321CB003810014AA8E /* DatabasePool.swift in Sources */,
560FC5331CB003810014AA8E /* Migration.swift in Sources */,
@@ -2232,19 +2412,25 @@
560FC5391CB003810014AA8E /* DatabaseReader.swift in Sources */,
560FC53A1CB003810014AA8E /* NSNull.swift in Sources */,
56CEB51A1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
564CE44021AA957000652B19 /* ValueObserver.swift in Sources */,
5674A7011F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */,
5698AC791DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
560FC53B1CB003810014AA8E /* Database.swift in Sources */,
566AD8B31D5318F4002EC1A8 /* TableDefinition.swift in Sources */,
5613ED7F21A95E8400DC7A68 /* ValueObservation+Map.swift in Sources */,
5698AD221DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
564CE5BB21B8FBFD00652B19 /* DatabaseRegionObservation.swift in Sources */,
560FC53C1CB003810014AA8E /* DatabaseQueue.swift in Sources */,
5653EB9720961FC000F46237 /* ForeignKey.swift in Sources */,
569A98FC2039B72D008D7DBF /* Fixits-3.0.swift in Sources */,
5613ED8521A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5653EB9520961FC000F46237 /* HasManyAssociation.swift in Sources */,
560FC53D1CB003810014AA8E /* NSNumber.swift in Sources */,
5613ED7B21A95E8400DC7A68 /* ValueObservation.swift in Sources */,
567071F8208A00D4006AD95A /* SQLiteDateParser.swift in Sources */,
560FC53F1CB003810014AA8E /* Row.swift in Sources */,
560FC5401CB003810014AA8E /* StandardLibrary.swift in Sources */,
5613ED7D21A95E8400DC7A68 /* ValueObservation+Combine.swift in Sources */,
5653EC1A209873E600F46237 /* SQLGenerationContext.swift in Sources */,
560FC5411CB003810014AA8E /* PersistableRecord.swift in Sources */,
566475A31D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
@@ -2269,6 +2455,7 @@
56A8C2411D1918EE0096E9D4 /* FoundationNSUUIDTests.swift in Sources */,
562EA8301F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EBC020961FE800F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45921631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
562206031E420EA3005860AC /* DatabasePoolBackupTests.swift in Sources */,
5657AB571D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
564448841EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
@@ -2288,12 +2475,14 @@
560FC56B1CB00B880014AA8E /* DatabaseCollationTests.swift in Sources */,
560FC56C1CB00B880014AA8E /* UpdateStatementTests.swift in Sources */,
5653EBE020961FE800F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B06FA21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */,
560FC56D1CB00B880014AA8E /* DatabaseMigratorTests.swift in Sources */,
56EA63CC209C7F31009715B8 /* DerivableRequestTests.swift in Sources */,
560FC5701CB00B880014AA8E /* DatabasePoolCollationTests.swift in Sources */,
560FC5711CB00B880014AA8E /* RecordPrimaryKeySingleTests.swift in Sources */,
5674A7191F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
56B021CA1D8C0D3900B239BB /* MutablePersistableRecordPersistenceConflictPolicyTests.swift in Sources */,
563B07082186280600B38F35 /* ValueObservationRowTests.swift in Sources */,
562205F61E420E48005860AC /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
560FC5741CB00B880014AA8E /* DatabasePoolFunctionTests.swift in Sources */,
5653EBDC20961FE800F46237 /* AssociationParallelRowScopesTests.swift in Sources */,
@@ -2319,12 +2508,15 @@
56D5075F1F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
56176C631EACCCC7000F3F2B /* FTS5TokenizerTests.swift in Sources */,
5623934F1DEDFEFB00A6B01F /* EnumeratedCursorTests.swift in Sources */,
563B06ED2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */,
560FC57C1CB00B880014AA8E /* StatementArgumentsTests.swift in Sources */,
563B06E52185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
567F45A91F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
5634B1081CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */,
560FC57D1CB00B880014AA8E /* RecordInitializersTests.swift in Sources */,
56176C5F1EACCCC7000F3F2B /* FTS5CustomTokenizerTests.swift in Sources */,
565F03C31CE5D3AA00DE108F /* RowAdapterTests.swift in Sources */,
563B070D21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF64208CB762002F0ACB /* ColumnExpressionTests.swift in Sources */,
5657AB3F1D108BA9006283EF /* FoundationNSDataTests.swift in Sources */,
560FC57E1CB00B880014AA8E /* MutablePersistableRecordTests.swift in Sources */,
@@ -2335,6 +2527,7 @@
5653EBE820961FE800F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
56176C601EACCCC7000F3F2B /* FTS5PatternTests.swift in Sources */,
564E73EF203DA2A2000C443C /* JoinSupportTests.swift in Sources */,
563B071E21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5674A7111F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
5657AB471D108BA9006283EF /* FoundationNSNullTests.swift in Sources */,
5665F86C203EF47D0084C6C0 /* ColumnInfoTests.swift in Sources */,
@@ -2346,6 +2539,7 @@
5653EBB820961FE800F46237 /* AssociationParallelSQLTests.swift in Sources */,
560FC5841CB00B880014AA8E /* PersistableRecordTests.swift in Sources */,
560FC5871CB00B880014AA8E /* RecordSubClassTests.swift in Sources */,
5613ED9E21A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EBBC20961FE800F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
560FC5891CB00B880014AA8E /* TransactionObserverTests.swift in Sources */,
5674A72C1F30A9090095F066 /* FetchableRecordDecodableTests.swift in Sources */,
@@ -2363,8 +2557,10 @@
560FC58E1CB00B880014AA8E /* RecordPrimaryKeyRowIDTests.swift in Sources */,
560FC58F1CB00B880014AA8E /* DatabaseReaderTests.swift in Sources */,
5653EBD020961FE800F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06E12185E07200B38F35 /* ValueObservationExtentTests.swift in Sources */,
560FC5901CB00B880014AA8E /* RecordEditedTests.swift in Sources */,
5665FA412129EEEF004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06F12185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE8220F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
560FC5911CB00B880014AA8E /* RecordPrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
56CC924C201E059100CB597E /* DropFirstCursorTests.swift in Sources */,
@@ -2372,13 +2568,16 @@
560FC5921CB00B880014AA8E /* FetchableRecordTests.swift in Sources */,
56A5EF101EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
5657AB371D108BA9006283EF /* FoundationDataTests.swift in Sources */,
563EF44521613213007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EBD820961FE800F46237 /* AssociationChainRowScopesTests.swift in Sources */,
560FC5941CB00B880014AA8E /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
5653EBC820961FE800F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
565EFAEF1D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */,
560FC5961CB00B880014AA8E /* DatabaseValueConvertibleFetchTests.swift in Sources */,
5653EBC420961FE800F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C121B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */,
560FC5971CB00B880014AA8E /* DatabaseErrorTests.swift in Sources */,
564CE4EC21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */,
560FC5991CB00B880014AA8E /* RecordMinimalPrimaryKeySingleTests.swift in Sources */,
564F9C1F1F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
562393731DEE104400A6B01F /* MapCursorTests.swift in Sources */,
@@ -2388,6 +2587,7 @@
560FC59B1CB00B880014AA8E /* DatabaseTimestampTests.swift in Sources */,
5698AC411DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
5623936A1DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
563B06E92185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */,
560FC59C1CB00B880014AA8E /* StatementArguments+FoundationTests.swift in Sources */,
5657AB671D108BA9006283EF /* FoundationURLTests.swift in Sources */,
560FC59D1CB00B880014AA8E /* TableRecord+QueryInterfaceRequestTests.swift in Sources */,
@@ -2403,6 +2603,7 @@
560FC5A21CB00B880014AA8E /* DatabaseFunctionTests.swift in Sources */,
560FC5A41CB00B880014AA8E /* RecordWithColumnNameManglingTests.swift in Sources */,
5674A7221F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4F121B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */,
5690C3271D23E6D800E59934 /* FoundationDateComponentsTests.swift in Sources */,
560FC5A51CB00B880014AA8E /* CGFloatTests.swift in Sources */,
56FF45571D2CDA5200F21EF9 /* RecordUniqueIndexTests.swift in Sources */,
@@ -2434,6 +2635,7 @@
567156221CB16729007DC145 /* StatementColumnConvertibleFetchTests.swift in Sources */,
562EA8311F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EBC120961FE800F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45A21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
562206001E420EA3005860AC /* DatabasePoolBackupTests.swift in Sources */,
567156231CB16729007DC145 /* RecordPrimaryKeyNoneTests.swift in Sources */,
564448851EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
@@ -2453,12 +2655,14 @@
5671562E1CB16729007DC145 /* DatabasePoolCollationTests.swift in Sources */,
5671562F1CB16729007DC145 /* RecordPrimaryKeySingleTests.swift in Sources */,
5653EBE120961FE800F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B06FB21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */,
56EA63CD209C7F31009715B8 /* DerivableRequestTests.swift in Sources */,
56C3F7551CF9F12400F6A361 /* DatabaseSavepointTests.swift in Sources */,
5672DE5B1CDB72520022BA81 /* DatabaseQueueBackupTests.swift in Sources */,
56B021CB1D8C0D3900B239BB /* MutablePersistableRecordPersistenceConflictPolicyTests.swift in Sources */,
5674A71B1F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
56B14E811D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */,
563B07092186280600B38F35 /* ValueObservationRowTests.swift in Sources */,
562205F91E420E49005860AC /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
566AD8C81D531BEB002EC1A8 /* TableDefinitionTests.swift in Sources */,
5653EBDD20961FE800F46237 /* AssociationParallelRowScopesTests.swift in Sources */,
@@ -2484,12 +2688,15 @@
56D507601F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
56176C691EACCCC8000F3F2B /* FTS5TokenizerTests.swift in Sources */,
562393501DEDFEFB00A6B01F /* EnumeratedCursorTests.swift in Sources */,
563B06EE2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */,
5671563A1CB16729007DC145 /* StatementArgumentsTests.swift in Sources */,
563B06E62185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
567F45AA1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
5657AB601D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
5671563B1CB16729007DC145 /* RecordInitializersTests.swift in Sources */,
56176C651EACCCC8000F3F2B /* FTS5CustomTokenizerTests.swift in Sources */,
5657AB681D108BA9006283EF /* FoundationURLTests.swift in Sources */,
563B070E21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF65208CB762002F0ACB /* ColumnExpressionTests.swift in Sources */,
5671563C1CB16729007DC145 /* MutablePersistableRecordTests.swift in Sources */,
5671563D1CB16729007DC145 /* FetchableRecord+QueryInterfaceRequestTests.swift in Sources */,
@@ -2500,6 +2707,7 @@
5653EBE920961FE800F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
56176C661EACCCC8000F3F2B /* FTS5PatternTests.swift in Sources */,
564E73F0203DA2A3000C443C /* JoinSupportTests.swift in Sources */,
563B071F21862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5674A7131F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
567156411CB16729007DC145 /* PersistableRecordTests.swift in Sources */,
5665F86D203EF47D0084C6C0 /* ColumnInfoTests.swift in Sources */,
@@ -2511,6 +2719,7 @@
5653EBB920961FE800F46237 /* AssociationParallelSQLTests.swift in Sources */,
567156461CB16729007DC145 /* TransactionObserverTests.swift in Sources */,
567A80551D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
5613ED9F21A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EBBD20961FE800F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
567156481CB16729007DC145 /* DatabaseValueTests.swift in Sources */,
5674A72E1F30A9090095F066 /* FetchableRecordDecodableTests.swift in Sources */,
@@ -2528,8 +2737,10 @@
5671564F1CB16729007DC145 /* RecordEditedTests.swift in Sources */,
567156501CB16729007DC145 /* RecordPrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
5653EBD120961FE800F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06E22185E07200B38F35 /* ValueObservationExtentTests.swift in Sources */,
567156511CB16729007DC145 /* FetchableRecordTests.swift in Sources */,
5665FA422129EEEF004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06F22185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE8320F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
56A8C2441D1918EE0096E9D4 /* FoundationUUIDTests.swift in Sources */,
56CC924D201E059100CB597E /* DropFirstCursorTests.swift in Sources */,
@@ -2537,13 +2748,16 @@
567156531CB16729007DC145 /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
56A5EF111EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
5690C3281D23E6D800E59934 /* FoundationDateComponentsTests.swift in Sources */,
563EF44621613213007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EBD920961FE800F46237 /* AssociationChainRowScopesTests.swift in Sources */,
5657AB381D108BA9006283EF /* FoundationDataTests.swift in Sources */,
5653EBC920961FE800F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
561667031D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
565EFAF01D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */,
5653EBC520961FE800F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C221B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */,
567156551CB16729007DC145 /* DatabaseValueConvertibleFetchTests.swift in Sources */,
564CE4ED21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */,
567156561CB16729007DC145 /* DatabaseErrorTests.swift in Sources */,
564F9C201F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
562393741DEE104400A6B01F /* MapCursorTests.swift in Sources */,
@@ -2553,6 +2767,7 @@
567156571CB16729007DC145 /* RecordMinimalPrimaryKeySingleTests.swift in Sources */,
5698AC421DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
5623936B1DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
563B06EA2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */,
567156591CB16729007DC145 /* DatabaseTimestampTests.swift in Sources */,
5671565A1CB16729007DC145 /* StatementArguments+FoundationTests.swift in Sources */,
5657AB581D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
@@ -2568,6 +2783,7 @@
5698ACD01DA8C2620056AF8C /* RecordPrimaryKeyHiddenRowIDTests.swift in Sources */,
569178481CED9B6000E179EA /* DatabaseQueueTests.swift in Sources */,
5674A7241F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4F221B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */,
5634B1091CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */,
567156601CB16729007DC145 /* DatabaseFunctionTests.swift in Sources */,
567156611CB16729007DC145 /* RecordWithColumnNameManglingTests.swift in Sources */,
@@ -2592,10 +2808,12 @@
buildActionMask = 2147483647;
files = (
56873BF01F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
563EF43D2161183E007DAACD /* AssociationAggregate.swift in Sources */,
56BF6D411DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5616AAFA207CD5A900AC3664 /* RequestProtocols.swift in Sources */,
5636E9C01D22574100B9B05F /* FetchRequest.swift in Sources */,
56BB6EAD1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
563EF4512161F1A8007DAACD /* Inflections.swift in Sources */,
566B910D1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
566B91271FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
5653EB9C20961FC000F46237 /* AssociationRequest.swift in Sources */,
@@ -2606,20 +2824,25 @@
56AFC9F11CB1A8BB00F48B96 /* QueryInterfaceRequest.swift in Sources */,
56AFC9F21CB1A8BB00F48B96 /* SQLCollatedExpression.swift in Sources */,
5653EB9A20961FC000F46237 /* ForeignKeyRequest.swift in Sources */,
5613ED8221A95E8400DC7A68 /* ValueObservation+Row.swift in Sources */,
566B91371FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
56D1215E1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
5613ED8A21A95E8400DC7A68 /* ValueObservation+Count.swift in Sources */,
566475D71D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
5653EB9220961FC000F46237 /* HasOneAssociation.swift in Sources */,
56CEB5651EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56CEB4FE1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
5698AD391DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
564CE5A721B7A9D600652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
566B91171FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
56AFC9F31CB1A8BB00F48B96 /* Database.swift in Sources */,
5674A7061F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
5653EC18209873A400F46237 /* SQLExpression+QueryInterface.swift in Sources */,
564CE52721B312B700652B19 /* ValueObservation+MapReducer.swift in Sources */,
5659F4A41EA8D997004A4992 /* Result.swift in Sources */,
56AFC9F41CB1A8BB00F48B96 /* CGFloat.swift in Sources */,
56AFC9F51CB1A8BB00F48B96 /* Date.swift in Sources */,
563EF425215F8A88007DAACD /* OrderedDictionary.swift in Sources */,
56AFC9F71CB1A8BB00F48B96 /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
566475D01D981D5E00FF74B8 /* SQLFunctions.swift in Sources */,
569EF0EA200D387000A9FA45 /* DatabaseRegion.swift in Sources */,
@@ -2639,6 +2862,7 @@
56B964B51DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */,
56AFC9FB1CB1A8BB00F48B96 /* SerializedDatabase.swift in Sources */,
56AFC9FC1CB1A8BB00F48B96 /* DatabaseMigrator.swift in Sources */,
564CE4DE21B2DEF700652B19 /* ValueObservation+CompactMap.swift in Sources */,
56AFC9FD1CB1A8BB00F48B96 /* NSString.swift in Sources */,
56A8C2341D1914540096E9D4 /* UUID.swift in Sources */,
56CEB5051EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
@@ -2648,6 +2872,7 @@
5656BF5F20C7248700F98521 /* QueryOrdering.swift in Sources */,
56D51D041EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
566475BE1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
5613ED8821A95E8400DC7A68 /* ValueReducer.swift in Sources */,
56AFCA001CB1A8BB00F48B96 /* Record.swift in Sources */,
5671FC241DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
56AFCA031CB1A8BB00F48B96 /* TableRecord.swift in Sources */,
@@ -2656,6 +2881,7 @@
56AFCA061CB1A8BB00F48B96 /* Configuration.swift in Sources */,
56DAA2DF1DE9C827006E10C8 /* Cursor.swift in Sources */,
5674A6EE1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
5613ED8421A95E8400DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
5644DE7D20F8C903001FFDDE /* DatabaseValueConversion.swift in Sources */,
56AFCA071CB1A8BB00F48B96 /* DatabasePool.swift in Sources */,
56AFCA081CB1A8BB00F48B96 /* Statement.swift in Sources */,
@@ -2674,19 +2900,25 @@
56AFCA0F1CB1A8BB00F48B96 /* NSNull.swift in Sources */,
56AFCA101CB1A8BB00F48B96 /* DatabaseQueue.swift in Sources */,
56CEB51D1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
564CE44121AA957000652B19 /* ValueObserver.swift in Sources */,
5674A6FE1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */,
5698AC7C1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
56AFCA111CB1A8BB00F48B96 /* DatabaseError.swift in Sources */,
566AD8B61D5318F4002EC1A8 /* TableDefinition.swift in Sources */,
5613ED8021A95E8400DC7A68 /* ValueObservation+Map.swift in Sources */,
5698AD251DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
564CE5BC21B8FBFD00652B19 /* DatabaseRegionObservation.swift in Sources */,
56AFCA121CB1A8BB00F48B96 /* NSNumber.swift in Sources */,
5653EB9820961FC000F46237 /* ForeignKey.swift in Sources */,
569A98FD2039B72D008D7DBF /* Fixits-3.0.swift in Sources */,
5613ED8621A95E8400DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5653EB9620961FC000F46237 /* HasManyAssociation.swift in Sources */,
56AFCA141CB1A8BB00F48B96 /* StandardLibrary.swift in Sources */,
5613ED7C21A95E8400DC7A68 /* ValueObservation.swift in Sources */,
56AFCA151CB1A8BB00F48B96 /* PersistableRecord.swift in Sources */,
567071F9208A00D4006AD95A /* SQLiteDateParser.swift in Sources */,
56AFCA161CB1A8BB00F48B96 /* StatementColumnConvertible.swift in Sources */,
5613ED7E21A95E8400DC7A68 /* ValueObservation+Combine.swift in Sources */,
5653EC1B209873E600F46237 /* SQLGenerationContext.swift in Sources */,
566475A61D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
5657AABD1D107001006283EF /* NSData.swift in Sources */,
@@ -2711,6 +2943,7 @@
56AFCA321CB1AA9900F48B96 /* DatabaseQueueConcurrencyTests.swift in Sources */,
562EA8341F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EBC220961FE800F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45B21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
5698ACD31DA8C2620056AF8C /* RecordPrimaryKeyHiddenRowIDTests.swift in Sources */,
56AFCA331CB1AA9900F48B96 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
564448881EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
@@ -2730,12 +2963,14 @@
5657AB4B1D108BA9006283EF /* FoundationNSNullTests.swift in Sources */,
56AFCA3E1CB1AA9900F48B96 /* DatabasePoolCollationTests.swift in Sources */,
5653EBE220961FE800F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B06FC21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */,
56FF455B1D2CDA5200F21EF9 /* RecordUniqueIndexTests.swift in Sources */,
56EA63CE209C7F31009715B8 /* DerivableRequestTests.swift in Sources */,
56AFCA3F1CB1AA9900F48B96 /* RecordPrimaryKeySingleTests.swift in Sources */,
56AFCA421CB1AA9900F48B96 /* DatabasePoolFunctionTests.swift in Sources */,
5674A7181F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
56AFCA441CB1AA9900F48B96 /* RowCopiedFromStatementTests.swift in Sources */,
563B070A2186280600B38F35 /* ValueObservationRowTests.swift in Sources */,
56C3F7571CF9F12400F6A361 /* DatabaseSavepointTests.swift in Sources */,
562393351DEDFC5700A6B01F /* AnyCursorTests.swift in Sources */,
5653EBDE20961FE800F46237 /* AssociationParallelRowScopesTests.swift in Sources */,
@@ -2761,12 +2996,15 @@
56CC9238201E009900CB597E /* DropWhileCursorTests.swift in Sources */,
56D507631F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
56176C751EACCCCA000F3F2B /* FTS5TokenizerTests.swift in Sources */,
563B06EF2185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */,
56AFCA4D1CB1AA9900F48B96 /* DatabasePoolReadOnlyTests.swift in Sources */,
563B06E72185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
5657AB631D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
567F45AD1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
5657AB6B1D108BA9006283EF /* FoundationURLTests.swift in Sources */,
56AFCA4F1CB1AA9900F48B96 /* DataMemoryTests.swift in Sources */,
56176C711EACCCCA000F3F2B /* FTS5CustomTokenizerTests.swift in Sources */,
563B070F21862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF66208CB762002F0ACB /* ColumnExpressionTests.swift in Sources */,
5672DE5D1CDB72520022BA81 /* DatabaseQueueBackupTests.swift in Sources */,
56AFCA501CB1AA9900F48B96 /* RecordCopyTests.swift in Sources */,
@@ -2777,6 +3015,7 @@
5653EBEA20961FE800F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
5698AC9B1DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
56176C721EACCCCA000F3F2B /* FTS5PatternTests.swift in Sources */,
563B072021862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
564E73F1203DA2A3000C443C /* JoinSupportTests.swift in Sources */,
5674A7101F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
56AFCA551CB1AA9900F48B96 /* RawRepresentable+DatabaseValueConvertibleTests.swift in Sources */,
@@ -2788,6 +3027,7 @@
5653EBBA20961FE800F46237 /* AssociationParallelSQLTests.swift in Sources */,
56176C761EACCCCA000F3F2B /* FTS5WrapperTokenizerTests.swift in Sources */,
5623935C1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
5613EDA021A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EBBE20961FE800F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
5698AC851DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */,
5698AC451DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
@@ -2805,8 +3045,10 @@
56AFCA5D1CB1AA9900F48B96 /* DatabaseReaderTests.swift in Sources */,
56A8C2491D1918F10096E9D4 /* FoundationNSUUIDTests.swift in Sources */,
5653EBD220961FE800F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06E32185E07300B38F35 /* ValueObservationExtentTests.swift in Sources */,
56AFCA5E1CB1AA9900F48B96 /* FetchableRecordTests.swift in Sources */,
5665FA432129EEEF004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06F32185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE8420F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
56AFCA5F1CB1AA9900F48B96 /* DatabaseValueConvertibleFetchTests.swift in Sources */,
56AFCA601CB1AA9900F48B96 /* RecordPrimaryKeyRowIDTests.swift in Sources */,
@@ -2814,13 +3056,16 @@
56AFCA611CB1AA9900F48B96 /* RecordEditedTests.swift in Sources */,
56AFCA621CB1AA9900F48B96 /* DatabasePoolSchemaCacheTests.swift in Sources */,
56A5EF141EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
563EF44721613213007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EBDA20961FE800F46237 /* AssociationChainRowScopesTests.swift in Sources */,
5623931D1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
5653EBCA20961FE800F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
56AFCA631CB1AA9900F48B96 /* RecordPrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
5698AC8E1DA389380056AF8C /* FTS3TableBuilderTests.swift in Sources */,
5653EBC620961FE800F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C321B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */,
56AFCA641CB1AA9900F48B96 /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
564CE4EE21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */,
56A8C24A1D1918F10096E9D4 /* FoundationUUIDTests.swift in Sources */,
56AFCA651CB1AA9900F48B96 /* DatabaseErrorTests.swift in Sources */,
564F9C231F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
@@ -2830,6 +3075,7 @@
5657AB3B1D108BA9006283EF /* FoundationDataTests.swift in Sources */,
5698AC081D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */,
56AFCA661CB1AA9900F48B96 /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
563B06EB2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */,
561667061D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
565EFAF31D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */,
56AFCA671CB1AA9900F48B96 /* DatabasePoolReleaseMemoryTests.swift in Sources */,
@@ -2845,6 +3091,7 @@
56AFCA6D1CB1AA9900F48B96 /* TableRecord+QueryInterfaceRequestTests.swift in Sources */,
56AFCA6E1CB1AA9900F48B96 /* FoundationNSDateTests.swift in Sources */,
5674A7211F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4F321B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */,
56AFCA6F1CB1AA9900F48B96 /* DatabaseTests.swift in Sources */,
56AFCA701CB1AA9900F48B96 /* QueryInterfaceRequestTests.swift in Sources */,
5634B10B1CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */,
@@ -2876,6 +3123,7 @@
56AFCA8B1CB1ABC800F48B96 /* DatabaseQueueConcurrencyTests.swift in Sources */,
562EA8351F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EBC320961FE800F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45C21631E51007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
5698ACD41DA8C2620056AF8C /* RecordPrimaryKeyHiddenRowIDTests.swift in Sources */,
56AFCA8C1CB1ABC800F48B96 /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
564448891EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
@@ -2895,12 +3143,14 @@
56AFCA921CB1ABC800F48B96 /* SelectStatementTests.swift in Sources */,
56AFCA931CB1ABC800F48B96 /* UpdateStatementTests.swift in Sources */,
5653EBE320961FE800F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B06FD21861D8B00B38F35 /* ValueObservationCountTests.swift in Sources */,
56AFCA941CB1ABC800F48B96 /* DatabaseMigratorTests.swift in Sources */,
56EA63CF209C7F31009715B8 /* DerivableRequestTests.swift in Sources */,
5657AB641D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
56FF455C1D2CDA5200F21EF9 /* RecordUniqueIndexTests.swift in Sources */,
56AFCA971CB1ABC800F48B96 /* DatabasePoolCollationTests.swift in Sources */,
5674A7151F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
563B070B2186280600B38F35 /* ValueObservationRowTests.swift in Sources */,
5657AB5C1D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
56AFCA981CB1ABC800F48B96 /* RecordPrimaryKeySingleTests.swift in Sources */,
562393361DEDFC5700A6B01F /* AnyCursorTests.swift in Sources */,
@@ -2926,12 +3176,15 @@
56CC9239201E009A00CB597E /* DropWhileCursorTests.swift in Sources */,
56D507641F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
56176C7B1EACCCCB000F3F2B /* FTS5TokenizerTests.swift in Sources */,
563B06F02185E07300B38F35 /* ValueObservationReducerTests.swift in Sources */,
566AD8CC1D531BEE002EC1A8 /* TableDefinitionTests.swift in Sources */,
563B06E82185E07300B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
56AFCAA41CB1ABC800F48B96 /* MutablePersistableRecordTests.swift in Sources */,
567F45AE1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
56AFCAA51CB1ABC800F48B96 /* FetchableRecord+QueryInterfaceRequestTests.swift in Sources */,
56AFCAA61CB1ABC800F48B96 /* DatabasePoolReadOnlyTests.swift in Sources */,
56176C771EACCCCB000F3F2B /* FTS5CustomTokenizerTests.swift in Sources */,
563B071021862C3600B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF67208CB762002F0ACB /* ColumnExpressionTests.swift in Sources */,
5657AB6C1D108BA9006283EF /* FoundationURLTests.swift in Sources */,
56AFCAA81CB1ABC800F48B96 /* DataMemoryTests.swift in Sources */,
@@ -2942,6 +3195,7 @@
5653EBEB20961FE800F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
5698AC9C1DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
56176C781EACCCCB000F3F2B /* FTS5PatternTests.swift in Sources */,
563B072121862F5D00B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
564E73F2203DA2A4000C443C /* JoinSupportTests.swift in Sources */,
5674A70D1F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
56AFCAAC1CB1ABC800F48B96 /* DatabaseValueConversionTests.swift in Sources */,
@@ -2953,6 +3207,7 @@
5653EBBB20961FE800F46237 /* AssociationParallelSQLTests.swift in Sources */,
56176C7C1EACCCCB000F3F2B /* FTS5WrapperTokenizerTests.swift in Sources */,
5698AC861DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */,
5613EDA121A96A6F00DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EBBF20961FE800F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
5698AC461DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
56AF74711D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift in Sources */,
@@ -2970,8 +3225,10 @@
56AFCAB41CB1ABC800F48B96 /* DatabaseValueTests.swift in Sources */,
5657AB3C1D108BA9006283EF /* FoundationDataTests.swift in Sources */,
5653EBD320961FE800F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06E42185E07300B38F35 /* ValueObservationExtentTests.swift in Sources */,
5634B10C1CF9B970005360B9 /* TransactionObserverSavepointsTests.swift in Sources */,
5665FA442129EEEF004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06F42185E07300B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE8520F8D1E4001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
56AFCAB51CB1ABC800F48B96 /* DatabaseQueueReadOnlyTests.swift in Sources */,
56AFCAB61CB1ABC800F48B96 /* DatabaseReaderTests.swift in Sources */,
@@ -2979,13 +3236,16 @@
56AFCAB71CB1ABC800F48B96 /* FetchableRecordTests.swift in Sources */,
56B15D0D1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */,
56A5EF151EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
563EF44821613213007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EBDB20961FE800F46237 /* AssociationChainRowScopesTests.swift in Sources */,
5623931E1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
5653EBCB20961FE800F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
56AFCAB81CB1ABC800F48B96 /* DatabaseValueConvertibleFetchTests.swift in Sources */,
5698AC8F1DA389380056AF8C /* FTS3TableBuilderTests.swift in Sources */,
5653EBC720961FE800F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C421B8FFD800652B19 /* DatabaseRegionObservationTests.swift in Sources */,
56AFCAB91CB1ABC800F48B96 /* RecordPrimaryKeyRowIDTests.swift in Sources */,
564CE4EF21B2E08300652B19 /* ValueObservationCompactMapTests.swift in Sources */,
56AFCABA1CB1ABC800F48B96 /* RecordEditedTests.swift in Sources */,
56AFCABB1CB1ABC800F48B96 /* DatabasePoolSchemaCacheTests.swift in Sources */,
564F9C241F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
@@ -2995,6 +3255,7 @@
561667071D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
5698AC091D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */,
56AFCABD1CB1ABC800F48B96 /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
563B06EC2185E07300B38F35 /* ValueObservationFetchTests.swift in Sources */,
56AFCABE1CB1ABC800F48B96 /* DatabaseErrorTests.swift in Sources */,
56AFCABF1CB1ABC800F48B96 /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
56AFCAC01CB1ABC800F48B96 /* DatabasePoolReleaseMemoryTests.swift in Sources */,
@@ -3010,6 +3271,7 @@
56AFCAC71CB1ABC800F48B96 /* FoundationNSDateTests.swift in Sources */,
56AFCAC81CB1ABC800F48B96 /* DatabaseTests.swift in Sources */,
5674A71E1F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4F421B2E08A00652B19 /* ValueObservationMapTests.swift in Sources */,
56AFCAC91CB1ABC800F48B96 /* QueryInterfaceRequestTests.swift in Sources */,
5691784B1CED9B6000E179EA /* DatabaseQueueTests.swift in Sources */,
56AFCACB1CB1ABC800F48B96 /* DatabaseFunctionTests.swift in Sources */,
+205 -3
View File
@@ -8,6 +8,24 @@
/* Begin PBXBuildFile section */
56071A501DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
5613ED6121A95E6100DC7A68 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5921A95E6100DC7A68 /* ValueObservation.swift */; };
5613ED6221A95E6100DC7A68 /* ValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5921A95E6100DC7A68 /* ValueObservation.swift */; };
5613ED6321A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5A21A95E6100DC7A68 /* ValueObservation+Combine.swift */; };
5613ED6421A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5A21A95E6100DC7A68 /* ValueObservation+Combine.swift */; };
5613ED6521A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5B21A95E6100DC7A68 /* ValueObservation+Map.swift */; };
5613ED6621A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5B21A95E6100DC7A68 /* ValueObservation+Map.swift */; };
5613ED6721A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5C21A95E6100DC7A68 /* ValueObservation+Row.swift */; };
5613ED6821A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5C21A95E6100DC7A68 /* ValueObservation+Row.swift */; };
5613ED6921A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5D21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED6A21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5D21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift */; };
5613ED6B21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5E21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED6C21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5E21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */; };
5613ED6D21A95E6100DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5F21A95E6100DC7A68 /* ValueReducer.swift */; };
5613ED6E21A95E6100DC7A68 /* ValueReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED5F21A95E6100DC7A68 /* ValueReducer.swift */; };
5613ED6F21A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED6021A95E6100DC7A68 /* ValueObservation+Count.swift */; };
5613ED7021A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613ED6021A95E6100DC7A68 /* ValueObservation+Count.swift */; };
5613EDA321A96A8100DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613EDA221A96A8000DC7A68 /* ValueObservationCombineTests.swift */; };
5613EDA421A96A8100DC7A68 /* ValueObservationCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5613EDA221A96A8000DC7A68 /* ValueObservationCombineTests.swift */; };
561667041D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
561667081D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; };
5616AAF6207CD59400AC3664 /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5616AAF4207CD59300AC3664 /* RequestProtocols.swift */; };
@@ -43,12 +61,56 @@
562EA8361F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562EA82E1F17B9EB00FA528C /* CompilationSubClassTests.swift */; };
5636E9BE1D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
5636E9C11D22574100B9B05F /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; };
563B06D12185E04600B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CC2185E04500B38F35 /* ValueObservationExtentTests.swift */; };
563B06D22185E04600B38F35 /* ValueObservationExtentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CC2185E04500B38F35 /* ValueObservationExtentTests.swift */; };
563B06D32185E04600B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CD2185E04600B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06D42185E04600B38F35 /* ValueObservationReadonlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CD2185E04600B38F35 /* ValueObservationReadonlyTests.swift */; };
563B06D52185E04600B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CE2185E04600B38F35 /* ValueObservationFetchTests.swift */; };
563B06D62185E04600B38F35 /* ValueObservationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CE2185E04600B38F35 /* ValueObservationFetchTests.swift */; };
563B06D72185E04600B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CF2185E04600B38F35 /* ValueObservationReducerTests.swift */; };
563B06D82185E04600B38F35 /* ValueObservationReducerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06CF2185E04600B38F35 /* ValueObservationReducerTests.swift */; };
563B06D92185E04600B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06D02185E04600B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06DA2185E04600B38F35 /* ValueObservationSchedulingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06D02185E04600B38F35 /* ValueObservationSchedulingTests.swift */; };
563B06FF21861D9D00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06FE21861D9D00B38F35 /* ValueObservationCountTests.swift */; };
563B070021861D9D00B38F35 /* ValueObservationCountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B06FE21861D9D00B38F35 /* ValueObservationCountTests.swift */; };
563B0702218627DF00B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B0701218627DE00B38F35 /* ValueObservationRowTests.swift */; };
563B0703218627DF00B38F35 /* ValueObservationRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B0701218627DE00B38F35 /* ValueObservationRowTests.swift */; };
563B071221862C3E00B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071121862C3E00B38F35 /* ValueObservationRecordTests.swift */; };
563B071321862C3E00B38F35 /* ValueObservationRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071121862C3E00B38F35 /* ValueObservationRecordTests.swift */; };
563B071B21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563B071C21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; };
563EF420215F8A76007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF41E215F8A76007DAACD /* OrderedDictionary.swift */; };
563EF421215F8A76007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF41E215F8A76007DAACD /* OrderedDictionary.swift */; };
563EF4382161182C007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4362161182C007DAACD /* AssociationAggregate.swift */; };
563EF4392161182C007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4362161182C007DAACD /* AssociationAggregate.swift */; };
563EF442216131F5007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF441216131F5007DAACD /* AssociationAggregateTests.swift */; };
563EF443216131F5007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF441216131F5007DAACD /* AssociationAggregateTests.swift */; };
563EF44D2161F196007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44C2161F196007DAACD /* Inflections.swift */; };
563EF44E2161F196007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44C2161F196007DAACD /* Inflections.swift */; };
563EF45621631E3F007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45521631E3E007DAACD /* QueryInterfacePromiseTests.swift */; };
563EF45721631E3F007DAACD /* QueryInterfacePromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF45521631E3E007DAACD /* QueryInterfacePromiseTests.swift */; };
564448861EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */; };
5644488A1EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */; };
5644DE7820F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE7620F8C8E9001FFDDE /* DatabaseValueConversion.swift */; };
5644DE7920F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE7620F8C8E9001FFDDE /* DatabaseValueConversion.swift */; };
5644DE7F20F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE7E20F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift */; };
5644DE8020F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644DE7E20F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift */; };
564CE43C21AA955B00652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43B21AA955B00652B19 /* ValueObserver.swift */; };
564CE43D21AA955B00652B19 /* ValueObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE43B21AA955B00652B19 /* ValueObserver.swift */; };
564CE4DA21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4D921B2DEEB00652B19 /* ValueObservation+CompactMap.swift */; };
564CE4DB21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4D921B2DEEB00652B19 /* ValueObservation+CompactMap.swift */; };
564CE4E021B2E04500652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4DF21B2E04500652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4E121B2E04500652B19 /* ValueObservationCompactMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4DF21B2E04500652B19 /* ValueObservationCompactMapTests.swift */; };
564CE4E321B2E05400652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E221B2E05400652B19 /* ValueObservationMapTests.swift */; };
564CE4E421B2E05400652B19 /* ValueObservationMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE4E221B2E05400652B19 /* ValueObservationMapTests.swift */; };
564CE52421B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE52321B312AC00652B19 /* ValueObservation+MapReducer.swift */; };
564CE52521B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE52321B312AC00652B19 /* ValueObservation+MapReducer.swift */; };
564CE5A221B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5A021B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE5A321B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5A021B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift */; };
564CE5B721B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5B521B8FBEA00652B19 /* DatabaseRegionObservation.swift */; };
564CE5B821B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5B521B8FBEA00652B19 /* DatabaseRegionObservation.swift */; };
564CE5C621B8FFE600652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C521B8FFE500652B19 /* DatabaseRegionObservationTests.swift */; };
564CE5C721B8FFE600652B19 /* DatabaseRegionObservationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564CE5C521B8FFE500652B19 /* DatabaseRegionObservationTests.swift */; };
564E73F3203DA2AC000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73E7203DA278000C443C /* JoinSupportTests.swift */; };
564E73F4203DA2AD000C443C /* JoinSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564E73E7203DA278000C443C /* JoinSupportTests.swift */; };
564F9C211F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */; };
@@ -611,6 +673,15 @@
560D923F1C672C3E00F4F92B /* StatementColumnConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementColumnConvertible.swift; sourceTree = "<group>"; };
560D92441C672C4B00F4F92B /* PersistableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistableRecord.swift; sourceTree = "<group>"; };
560D92461C672C4B00F4F92B /* TableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRecord.swift; sourceTree = "<group>"; };
5613ED5921A95E6100DC7A68 /* ValueObservation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservation.swift; sourceTree = "<group>"; };
5613ED5A21A95E6100DC7A68 /* ValueObservation+Combine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Combine.swift"; sourceTree = "<group>"; };
5613ED5B21A95E6100DC7A68 /* ValueObservation+Map.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Map.swift"; sourceTree = "<group>"; };
5613ED5C21A95E6100DC7A68 /* ValueObservation+Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Row.swift"; sourceTree = "<group>"; };
5613ED5D21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+FetchableRecord.swift"; sourceTree = "<group>"; };
5613ED5E21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DatabaseValueConvertible.swift"; sourceTree = "<group>"; };
5613ED5F21A95E6100DC7A68 /* ValueReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueReducer.swift; sourceTree = "<group>"; };
5613ED6021A95E6100DC7A68 /* ValueObservation+Count.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+Count.swift"; sourceTree = "<group>"; };
5613EDA221A96A8000DC7A68 /* ValueObservationCombineTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCombineTests.swift; sourceTree = "<group>"; };
561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDecimalNumberTests.swift; sourceTree = "<group>"; };
5616AAF4207CD59300AC3664 /* RequestProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestProtocols.swift; sourceTree = "<group>"; };
562393171DECC02000A6B01F /* RowFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFetchTests.swift; sourceTree = "<group>"; };
@@ -639,10 +710,32 @@
563363D41C94484E000BE133 /* DatabaseQueueReleaseMemoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueueReleaseMemoryTests.swift; sourceTree = "<group>"; };
5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverSavepointsTests.swift; sourceTree = "<group>"; };
5636E9BB1D22574100B9B05F /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
563B06CC2185E04500B38F35 /* ValueObservationExtentTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationExtentTests.swift; sourceTree = "<group>"; };
563B06CD2185E04600B38F35 /* ValueObservationReadonlyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationReadonlyTests.swift; sourceTree = "<group>"; };
563B06CE2185E04600B38F35 /* ValueObservationFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationFetchTests.swift; sourceTree = "<group>"; };
563B06CF2185E04600B38F35 /* ValueObservationReducerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationReducerTests.swift; sourceTree = "<group>"; };
563B06D02185E04600B38F35 /* ValueObservationSchedulingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationSchedulingTests.swift; sourceTree = "<group>"; };
563B06FE21861D9D00B38F35 /* ValueObservationCountTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCountTests.swift; sourceTree = "<group>"; };
563B0701218627DE00B38F35 /* ValueObservationRowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRowTests.swift; sourceTree = "<group>"; };
563B071121862C3E00B38F35 /* ValueObservationRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRecordTests.swift; sourceTree = "<group>"; };
563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationDatabaseValueConvertibleTests.swift; sourceTree = "<group>"; };
563EF41E215F8A76007DAACD /* OrderedDictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedDictionary.swift; sourceTree = "<group>"; };
563EF4362161182C007DAACD /* AssociationAggregate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregate.swift; sourceTree = "<group>"; };
563EF441216131F5007DAACD /* AssociationAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregateTests.swift; sourceTree = "<group>"; };
563EF44C2161F196007DAACD /* Inflections.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Inflections.swift; sourceTree = "<group>"; };
563EF45521631E3E007DAACD /* QueryInterfacePromiseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfacePromiseTests.swift; sourceTree = "<group>"; };
564448821EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAfterNextTransactionCommitTests.swift; sourceTree = "<group>"; };
5644DE7620F8C8E9001FFDDE /* DatabaseValueConversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConversion.swift; sourceTree = "<group>"; };
5644DE7E20F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConversionErrorTests.swift; sourceTree = "<group>"; };
564A50C61BFF4B7F00B3A3A2 /* DatabaseCollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCollationTests.swift; sourceTree = "<group>"; };
564CE43B21AA955B00652B19 /* ValueObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObserver.swift; sourceTree = "<group>"; };
564CE4D921B2DEEB00652B19 /* ValueObservation+CompactMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+CompactMap.swift"; sourceTree = "<group>"; };
564CE4DF21B2E04500652B19 /* ValueObservationCompactMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationCompactMapTests.swift; sourceTree = "<group>"; };
564CE4E221B2E05400652B19 /* ValueObservationMapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationMapTests.swift; sourceTree = "<group>"; };
564CE52321B312AC00652B19 /* ValueObservation+MapReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+MapReducer.swift"; sourceTree = "<group>"; };
564CE5A021B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ValueObservation+DistinctUntilChanged.swift"; sourceTree = "<group>"; };
564CE5B521B8FBEA00652B19 /* DatabaseRegionObservation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservation.swift; sourceTree = "<group>"; };
564CE5C521B8FFE500652B19 /* DatabaseRegionObservationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionObservationTests.swift; sourceTree = "<group>"; };
564E73E7203DA278000C443C /* JoinSupportTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinSupportTests.swift; sourceTree = "<group>"; };
564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAggregateTests.swift; sourceTree = "<group>"; };
564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = "<group>"; };
@@ -998,6 +1091,25 @@
name = PersistableRecord;
sourceTree = "<group>";
};
5613ED5821A95E6100DC7A68 /* ValueObservation */ = {
isa = PBXGroup;
children = (
5613ED5921A95E6100DC7A68 /* ValueObservation.swift */,
5613ED5A21A95E6100DC7A68 /* ValueObservation+Combine.swift */,
564CE4D921B2DEEB00652B19 /* ValueObservation+CompactMap.swift */,
5613ED6021A95E6100DC7A68 /* ValueObservation+Count.swift */,
5613ED5E21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift */,
564CE5A021B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift */,
5613ED5D21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift */,
5613ED5B21A95E6100DC7A68 /* ValueObservation+Map.swift */,
564CE52321B312AC00652B19 /* ValueObservation+MapReducer.swift */,
5613ED5C21A95E6100DC7A68 /* ValueObservation+Row.swift */,
564CE43B21AA955B00652B19 /* ValueObserver.swift */,
5613ED5F21A95E6100DC7A68 /* ValueReducer.swift */,
);
path = ValueObservation;
sourceTree = "<group>";
};
5614DEEE1BA9D6F9003163B3 /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -1018,6 +1130,7 @@
56300B5C1C53C38F005A543B /* QueryInterface */,
56A238251B9C74A90082EB20 /* Record */,
56176C9F1EACEE15000F3F2B /* Support */,
563B06DB2185E04E00B38F35 /* ValueObservation */,
);
path = GRDBTests;
sourceTree = "<group>";
@@ -1086,6 +1199,7 @@
56300B601C53C42C005A543B /* FetchableRecord+QueryInterfaceRequestTests.swift */,
56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */,
5698AC021D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift */,
563EF45521631E3E007DAACD /* QueryInterfacePromiseTests.swift */,
56300B5D1C53C38F005A543B /* QueryInterfaceRequestTests.swift */,
56300B841C54DC95005A543B /* Record+QueryInterfaceRequestTests.swift */,
566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */,
@@ -1137,10 +1251,30 @@
name = DatabaseQueue;
sourceTree = "<group>";
};
563B06DB2185E04E00B38F35 /* ValueObservation */ = {
isa = PBXGroup;
children = (
5613EDA221A96A8000DC7A68 /* ValueObservationCombineTests.swift */,
564CE4DF21B2E04500652B19 /* ValueObservationCompactMapTests.swift */,
563B06FE21861D9D00B38F35 /* ValueObservationCountTests.swift */,
563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */,
563B06CC2185E04500B38F35 /* ValueObservationExtentTests.swift */,
563B06CE2185E04600B38F35 /* ValueObservationFetchTests.swift */,
564CE4E221B2E05400652B19 /* ValueObservationMapTests.swift */,
563B06CD2185E04600B38F35 /* ValueObservationReadonlyTests.swift */,
563B071121862C3E00B38F35 /* ValueObservationRecordTests.swift */,
563B06CF2185E04600B38F35 /* ValueObservationReducerTests.swift */,
563B0701218627DE00B38F35 /* ValueObservationRowTests.swift */,
563B06D02185E04600B38F35 /* ValueObservationSchedulingTests.swift */,
);
name = ValueObservation;
sourceTree = "<group>";
};
5653EB3620961F6000F46237 /* Association */ = {
isa = PBXGroup;
children = (
5653EB3E20961F6100F46237 /* Association.swift */,
563EF4362161182C007DAACD /* AssociationAggregate.swift */,
5653EB3920961F6000F46237 /* AssociationQuery.swift */,
5653EB3D20961F6100F46237 /* AssociationRequest.swift */,
5653EB3720961F6000F46237 /* BelongsToAssociation.swift */,
@@ -1155,6 +1289,7 @@
5653EB5620961F8900F46237 /* Association */ = {
isa = PBXGroup;
children = (
563EF441216131F5007DAACD /* AssociationAggregateTests.swift */,
5653EB6420961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift */,
5653EB5920961FB100F46237 /* AssociationBelongsToFetchableRecordTests.swift */,
5653EB6520961FB200F46237 /* AssociationBelongsToRowScopeTests.swift */,
@@ -1176,10 +1311,12 @@
5659F4861EA8D94E004A4992 /* Utils */ = {
isa = PBXGroup;
children = (
5659F4871EA8D94E004A4992 /* Utils.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
563EF44C2161F196007DAACD /* Inflections.swift */,
563EF41E215F8A76007DAACD /* OrderedDictionary.swift */,
5659F4971EA8D989004A4992 /* Pool.swift */,
5659F48F1EA8D964004A4992 /* ReadWriteBox.swift */,
5659F49F1EA8D997004A4992 /* Result.swift */,
5659F4871EA8D94E004A4992 /* Utils.swift */,
);
path = Utils;
sourceTree = "<group>";
@@ -1269,6 +1406,7 @@
560A37A91C90084600949E71 /* DatabasePool */,
563363BB1C93FD32000BE133 /* DatabaseQueue */,
56EA86931C91DFE7002BB4DF /* DatabaseReaderTests.swift */,
564CE5C521B8FFE500652B19 /* DatabaseRegionObservationTests.swift */,
56C3F7521CF9F12400F6A361 /* DatabaseSavepointTests.swift */,
566A843420413DE400E50BFD /* DatabaseSnapshotTests.swift */,
56A238131B9C74A90082EB20 /* DatabaseTests.swift */,
@@ -1366,6 +1504,7 @@
56A238741B9C75030082EB20 /* DatabaseQueue.swift */,
563363BF1C942C04000BE133 /* DatabaseReader.swift */,
569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */,
564CE5B521B8FBEA00652B19 /* DatabaseRegionObservation.swift */,
5695311E1C907A8C00CF1A2B /* DatabaseSchemaCache.swift */,
566A842B20413D9A00E50BFD /* DatabaseSnapshot.swift */,
56A238751B9C75030082EB20 /* DatabaseValue.swift */,
@@ -1380,8 +1519,8 @@
56A238781B9C75030082EB20 /* Statement.swift */,
566B912A1FA4D0CC0012D5B0 /* StatementAuthorizer.swift */,
560D923F1C672C3E00F4F92B /* StatementColumnConvertible.swift */,
566B91321FA4D3810012D5B0 /* TransactionObserver.swift */,
5605F1471C672E4000235C62 /* Support */,
566B91321FA4D3810012D5B0 /* TransactionObserver.swift */,
);
path = Core;
sourceTree = "<group>";
@@ -1518,6 +1657,7 @@
56A2389F1B9C753B0082EB20 /* Record */,
DC37743319C8CFCE004FCF85 /* Supporting Files */,
5659F4861EA8D94E004A4992 /* Utils */,
5613ED5821A95E6100DC7A68 /* ValueObservation */,
);
path = GRDB;
sourceTree = "<group>";
@@ -1817,10 +1957,12 @@
buildActionMask = 2147483647;
files = (
56873BF11F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
563EF4392161182C007DAACD /* AssociationAggregate.swift in Sources */,
56BF6D421DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5616AAF7207CD59400AC3664 /* RequestProtocols.swift in Sources */,
5636E9C11D22574100B9B05F /* FetchRequest.swift in Sources */,
F3BA801B1CFB2886003DC1BA /* CGFloat.swift in Sources */,
563EF44E2161F196007DAACD /* Inflections.swift in Sources */,
566B910E1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
566B91281FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
5653EB4E20961F6100F46237 /* AssociationRequest.swift in Sources */,
@@ -1831,20 +1973,25 @@
56BB6EAE1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
F3BA801A1CFB2876003DC1BA /* StatementColumnConvertible.swift in Sources */,
5653EB4C20961F6100F46237 /* ForeignKeyRequest.swift in Sources */,
5613ED6821A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */,
566B91381FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
56D1215F1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
5613ED7021A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */,
566475D81D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
5653EB4420961F6100F46237 /* HasOneAssociation.swift in Sources */,
56CEB5661EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56CEB4FF1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
5698AD3A1DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
564CE5A321B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
566B91181FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
F3BA80181CFB2876003DC1BA /* SerializedDatabase.swift in Sources */,
5674A7051F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
5659F4A51EA8D997004A4992 /* Result.swift in Sources */,
564CE52521B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */,
F3BA800D1CFB2871003DC1BA /* DatabasePool.swift in Sources */,
F3BA800B1CFB286D003DC1BA /* Database.swift in Sources */,
F3BA80341CFB28A4003DC1BA /* Record.swift in Sources */,
563EF421215F8A76007DAACD /* OrderedDictionary.swift in Sources */,
F3BA80161CFB2876003DC1BA /* Row.swift in Sources */,
569EF0E7200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */,
F3BA80101CFB2876003DC1BA /* DatabaseReader.swift in Sources */,
@@ -1864,6 +2011,7 @@
F3BA80131CFB2876003DC1BA /* DatabaseValue.swift in Sources */,
56B964B61DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */,
F3BA80171CFB2876003DC1BA /* RowAdapter.swift in Sources */,
564CE4DB21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */,
F3BA802F1CFB289B003DC1BA /* QueryInterfaceQuery.swift in Sources */,
56CEB5061EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
56CEB55F1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */,
@@ -1873,6 +2021,7 @@
5656BF5B20C7247100F98521 /* QueryOrdering.swift in Sources */,
56D51D051EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
F3BA80151CFB2876003DC1BA /* DatabaseWriter.swift in Sources */,
5613ED6E21A95E6100DC7A68 /* ValueReducer.swift in Sources */,
F3BA800A1CFB286A003DC1BA /* Configuration.swift in Sources */,
566475BF1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
5671FC251DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
@@ -1881,6 +2030,7 @@
F3BA801D1CFB288C003DC1BA /* DatabaseDateComponents.swift in Sources */,
5674A6ED1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
5657AB141D10899D006283EF /* URL.swift in Sources */,
5613ED6A21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
5644DE7920F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */,
56DAA2E01DE9C827006E10C8 /* Cursor.swift in Sources */,
F3BA800C1CFB286F003DC1BA /* DatabaseError.swift in Sources */,
@@ -1899,19 +2049,25 @@
56B964BE1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */,
F3BA80211CFB288C003DC1BA /* NSNull.swift in Sources */,
56CEB51E1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
564CE43D21AA955B00652B19 /* ValueObserver.swift in Sources */,
5674A6FD1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */,
F3BA80141CFB2876003DC1BA /* DatabaseValueConvertible.swift in Sources */,
5698AC7D1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
566AD8B71D5318F4002EC1A8 /* TableDefinition.swift in Sources */,
5613ED6621A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */,
5698AD261DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
564CE5B821B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */,
F3BA802C1CFB289B003DC1BA /* SQLCollatedExpression.swift in Sources */,
5653EB4A20961F6100F46237 /* ForeignKey.swift in Sources */,
569A98F92039B716008D7DBF /* Fixits-3.0.swift in Sources */,
5613ED6C21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5653EB4820961F6100F46237 /* HasManyAssociation.swift in Sources */,
F3BA80301CFB289F003DC1BA /* DatabaseMigrator.swift in Sources */,
5613ED6221A95E6100DC7A68 /* ValueObservation.swift in Sources */,
F3BA80361CFB28A4003DC1BA /* TableRecord.swift in Sources */,
567071F5208A00BE006AD95A /* SQLiteDateParser.swift in Sources */,
F3BA80271CFB2891003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
5613ED6421A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */,
5653EC092098737400F46237 /* SQLGenerationContext.swift in Sources */,
566475A71D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
5657AABE1D107001006283EF /* NSData.swift in Sources */,
@@ -1936,6 +2092,7 @@
F3BA811E1CFB3063003DC1BA /* RecordMinimalPrimaryKeyRowIDTests.swift in Sources */,
562EA8361F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EB6D20961FB200F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45721631E3F007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
F3BA80DD1CFB300E003DC1BA /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
5644488A1EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
F3BA80521CFB2B59003DC1BA /* DatabaseQueueSchemaCacheTests.swift in Sources */,
@@ -1955,12 +2112,14 @@
F3BA81221CFB3063003DC1BA /* RecordPrimaryKeyRowIDTests.swift in Sources */,
F3BA80F81CFB3021003DC1BA /* StatementArgumentsTests.swift in Sources */,
5653EB7D20961FB200F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B070021861D9D00B38F35 /* ValueObservationCountTests.swift in Sources */,
5698AC0A1D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */,
56EA63CA209C7F1E009715B8 /* DerivableRequestTests.swift in Sources */,
F3BA80E91CFB3016003DC1BA /* RowAdapterTests.swift in Sources */,
562393371DEDFC5700A6B01F /* AnyCursorTests.swift in Sources */,
5674A7161F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
56B021D01D8C0D3900B239BB /* MutablePersistableRecordPersistenceConflictPolicyTests.swift in Sources */,
563B0703218627DF00B38F35 /* ValueObservationRowTests.swift in Sources */,
5623935E1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
56B14E861D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */,
566AD8CD1D531BEE002EC1A8 /* TableDefinitionTests.swift in Sources */,
@@ -1986,12 +2145,15 @@
56CC9235201E009100CB597E /* DropWhileCursorTests.swift in Sources */,
56D507651F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
5657AB651D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
563B06D82185E04600B38F35 /* ValueObservationReducerTests.swift in Sources */,
5657AB6D1D108BA9006283EF /* FoundationURLTests.swift in Sources */,
563B06D42185E04600B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
567F45AF1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
F3BA804C1CFB2B24003DC1BA /* GRDBTestCase.swift in Sources */,
5698ACBD1DA6285E0056AF8C /* FTS3TokenizerTests.swift in Sources */,
5623931F1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
562393701DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
563B071321862C3E00B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF61208CB746002F0ACB /* ColumnExpressionTests.swift in Sources */,
F3BA81121CFB3059003DC1BA /* DatabaseMigratorTests.swift in Sources */,
56176C801EACCD31000F3F2B /* EncryptionTests.swift in Sources */,
@@ -2002,6 +2164,7 @@
5653EB8120961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
56B964CA1DA521450002DA19 /* FTS5PatternTests.swift in Sources */,
564E73F4203DA2AD000C443C /* JoinSupportTests.swift in Sources */,
563B071C21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5674A70E1F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
5657AB551D108BA9006283EF /* FoundationNSNumberTests.swift in Sources */,
5665F869203EF4650084C6C0 /* ColumnInfoTests.swift in Sources */,
@@ -2013,6 +2176,7 @@
5653EB6920961FB200F46237 /* AssociationParallelSQLTests.swift in Sources */,
F3BA80B71CFB2FCD003DC1BA /* DatabaseErrorTests.swift in Sources */,
5698ACCC1DA62A2D0056AF8C /* FTS5TokenizerTests.swift in Sources */,
5613EDA421A96A8100DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EB6B20961FB200F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
5690C33E1D23E7D200E59934 /* FoundationDateTests.swift in Sources */,
567A805A1D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
@@ -2030,8 +2194,10 @@
5698AC471DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
F3BA80D61CFB2FFD003DC1BA /* DatabaseReaderTests.swift in Sources */,
5653EB7520961FB200F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06D22185E04600B38F35 /* ValueObservationExtentTests.swift in Sources */,
5698AC9D1DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
5665FA3E2129EED8004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06DA2185E04600B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE8020F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
56A4CDB71D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */,
56CC924A201E058900CB597E /* DropFirstCursorTests.swift in Sources */,
@@ -2039,13 +2205,16 @@
F3BA80F91CFB3021003DC1BA /* UpdateStatementTests.swift in Sources */,
56A5EF161EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
F3BA80DA1CFB300E003DC1BA /* DatabaseTimestampTests.swift in Sources */,
563EF443216131F5007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EB7920961FB200F46237 /* AssociationChainRowScopesTests.swift in Sources */,
F3BA81201CFB3063003DC1BA /* RecordPrimaryKeyMultipleTests.swift in Sources */,
5653EB7120961FB200F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
F3BA812B1CFB3063003DC1BA /* RecordWithColumnNameManglingTests.swift in Sources */,
5698ACA51DA4B0430056AF8C /* FTS4TableBuilderTests.swift in Sources */,
5653EB6F20961FB200F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C721B8FFE600652B19 /* DatabaseRegionObservationTests.swift in Sources */,
F3BA80B11CFB2FC4003DC1BA /* DatabaseTests.swift in Sources */,
564CE4E121B2E04500652B19 /* ValueObservationCompactMapTests.swift in Sources */,
56A8C24E1D1918F30096E9D4 /* FoundationUUIDTests.swift in Sources */,
564F9C251F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
5657AB3D1D108BA9006283EF /* FoundationDataTests.swift in Sources */,
@@ -2055,6 +2224,7 @@
562393551DEDFEFB00A6B01F /* EnumeratedCursorTests.swift in Sources */,
F3BA804F1CFB2B59003DC1BA /* DatabasePoolReleaseMemoryTests.swift in Sources */,
561667081D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */,
563B06D62185E04600B38F35 /* ValueObservationFetchTests.swift in Sources */,
565EFAF51D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */,
F3BA81231CFB3063003DC1BA /* RecordPrimaryKeySingleTests.swift in Sources */,
F3BA80541CFB2B59003DC1BA /* DatabaseRegionTests.swift in Sources */,
@@ -2070,6 +2240,7 @@
5657AB5D1D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
F3BA81241CFB3063003DC1BA /* RecordPrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
5674A71F1F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4E421B2E05400652B19 /* ValueObservationMapTests.swift in Sources */,
F3BA80E81CFB3016003DC1BA /* RowFromDictionaryTests.swift in Sources */,
562393671DEE06D300A6B01F /* CursorTests.swift in Sources */,
F3BA80B41CFB2FC9003DC1BA /* DatabaseQueueReadOnlyTests.swift in Sources */,
@@ -2094,10 +2265,12 @@
buildActionMask = 2147483647;
files = (
56873BEE1F2CB400004D24B4 /* Fixits-1.2.swift in Sources */,
563EF4382161182C007DAACD /* AssociationAggregate.swift in Sources */,
56BF6D3F1DEF47DA006039A3 /* Fixits-Swift2.swift in Sources */,
5616AAF6207CD59400AC3664 /* RequestProtocols.swift in Sources */,
5636E9BE1D22574100B9B05F /* FetchRequest.swift in Sources */,
F3BA80771CFB2E5C003DC1BA /* CGFloat.swift in Sources */,
563EF44D2161F196007DAACD /* Inflections.swift in Sources */,
566B910B1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
566B91251FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
5653EB4D20961F6100F46237 /* AssociationRequest.swift in Sources */,
@@ -2108,20 +2281,25 @@
56BB6EAB1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */,
F3BA80761CFB2E55003DC1BA /* StatementColumnConvertible.swift in Sources */,
5653EB4B20961F6100F46237 /* ForeignKeyRequest.swift in Sources */,
5613ED6721A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */,
566B91351FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
56D1215C1ED34978001347D2 /* Fixits-0.109.0.swift in Sources */,
5613ED6F21A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */,
566475D51D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
5653EB4320961F6100F46237 /* HasOneAssociation.swift in Sources */,
56CEB5631EAA359A00BFAF62 /* SQLSelectable.swift in Sources */,
56CEB4FC1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
5698AD371DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
564CE5A221B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */,
566B91151FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */,
F3BA80741CFB2E55003DC1BA /* SerializedDatabase.swift in Sources */,
5674A7041F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
5659F4A21EA8D997004A4992 /* Result.swift in Sources */,
564CE52421B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */,
F3BA80691CFB2E55003DC1BA /* DatabasePool.swift in Sources */,
F3BA80671CFB2E55003DC1BA /* Database.swift in Sources */,
F3BA80901CFB2E7A003DC1BA /* Record.swift in Sources */,
563EF420215F8A76007DAACD /* OrderedDictionary.swift in Sources */,
F3BA80721CFB2E55003DC1BA /* Row.swift in Sources */,
569EF0E6200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */,
F3BA806C1CFB2E55003DC1BA /* DatabaseReader.swift in Sources */,
@@ -2141,6 +2319,7 @@
F3BA806F1CFB2E55003DC1BA /* DatabaseValue.swift in Sources */,
56B964B31DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */,
F3BA80731CFB2E55003DC1BA /* RowAdapter.swift in Sources */,
564CE4DA21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */,
F3BA808B1CFB2E70003DC1BA /* QueryInterfaceQuery.swift in Sources */,
56CEB5031EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
56CEB55C1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */,
@@ -2150,6 +2329,7 @@
5656BF5A20C7247100F98521 /* QueryOrdering.swift in Sources */,
56D51D021EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
F3BA80711CFB2E55003DC1BA /* DatabaseWriter.swift in Sources */,
5613ED6D21A95E6100DC7A68 /* ValueReducer.swift in Sources */,
F3BA80661CFB2E55003DC1BA /* Configuration.swift in Sources */,
566475BC1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
5671FC221DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
@@ -2158,6 +2338,7 @@
F3BA80791CFB2E61003DC1BA /* DatabaseDateComponents.swift in Sources */,
5674A6EC1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
5657AB111D10899D006283EF /* URL.swift in Sources */,
5613ED6921A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */,
5644DE7820F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */,
56DAA2DD1DE9C827006E10C8 /* Cursor.swift in Sources */,
F3BA80681CFB2E55003DC1BA /* DatabaseError.swift in Sources */,
@@ -2176,19 +2357,25 @@
56B964BB1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */,
F3BA807D1CFB2E61003DC1BA /* NSNull.swift in Sources */,
56CEB51B1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */,
564CE43C21AA955B00652B19 /* ValueObserver.swift in Sources */,
5674A6FC1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */,
F3BA80701CFB2E55003DC1BA /* DatabaseValueConvertible.swift in Sources */,
5698AC7A1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */,
566AD8B41D5318F4002EC1A8 /* TableDefinition.swift in Sources */,
5613ED6521A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */,
5698AD231DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
564CE5B721B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */,
F3BA80881CFB2E70003DC1BA /* SQLCollatedExpression.swift in Sources */,
5653EB4920961F6100F46237 /* ForeignKey.swift in Sources */,
569A98F82039B716008D7DBF /* Fixits-3.0.swift in Sources */,
5613ED6B21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */,
5653EB4720961F6100F46237 /* HasManyAssociation.swift in Sources */,
F3BA808C1CFB2E75003DC1BA /* DatabaseMigrator.swift in Sources */,
5613ED6121A95E6100DC7A68 /* ValueObservation.swift in Sources */,
F3BA80921CFB2E7A003DC1BA /* TableRecord.swift in Sources */,
567071F4208A00BE006AD95A /* SQLiteDateParser.swift in Sources */,
F3BA80831CFB2E67003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */,
5613ED6321A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */,
5653EC082098737400F46237 /* SQLGenerationContext.swift in Sources */,
566475A41D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */,
5657AABB1D107001006283EF /* NSData.swift in Sources */,
@@ -2213,6 +2400,7 @@
5698AC991DA4B0430056AF8C /* FTS4RecordTests.swift in Sources */,
562EA8321F17B9EB00FA528C /* CompilationSubClassTests.swift in Sources */,
5653EB6C20961FB200F46237 /* AssociationParallelDecodableRecordTests.swift in Sources */,
563EF45621631E3F007DAACD /* QueryInterfacePromiseTests.swift in Sources */,
56A8C2451D1918EF0096E9D4 /* FoundationNSUUIDTests.swift in Sources */,
5657AB591D108BA9006283EF /* FoundationNSStringTests.swift in Sources */,
564448861EF56B1B00DD2861 /* DatabaseAfterNextTransactionCommitTests.swift in Sources */,
@@ -2232,12 +2420,14 @@
F3BA80F61CFB301E003DC1BA /* StatementColumnConvertibleFetchTests.swift in Sources */,
F3BA80E61CFB3012003DC1BA /* DatabaseFunctionTests.swift in Sources */,
5653EB7C20961FB200F46237 /* AssociationBelongsToSQLTests.swift in Sources */,
563B06FF21861D9D00B38F35 /* ValueObservationCountTests.swift in Sources */,
5698ACDA1DA925430056AF8C /* RowTestCase.swift in Sources */,
56EA63C9209C7F1E009715B8 /* DerivableRequestTests.swift in Sources */,
F3BA811D1CFB305F003DC1BA /* TableRecord+QueryInterfaceRequestTests.swift in Sources */,
F3BA80AD1CFB2FA6003DC1BA /* DataMemoryTests.swift in Sources */,
5698ACB91DA6285E0056AF8C /* FTS3TokenizerTests.swift in Sources */,
5674A7141F3087710095F066 /* DatabaseValueConvertibleDecodableTests.swift in Sources */,
563B0702218627DF00B38F35 /* ValueObservationRowTests.swift in Sources */,
567A80561D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
F3BA81301CFB3064003DC1BA /* RecordPrimaryKeyRowIDTests.swift in Sources */,
56DAA2D51DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */,
@@ -2263,12 +2453,15 @@
56CC9234201E009000CB597E /* DropWhileCursorTests.swift in Sources */,
56D507611F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */,
F3BA80B01CFB2FB2003DC1BA /* DatabaseCollationTests.swift in Sources */,
563B06D72185E04600B38F35 /* ValueObservationReducerTests.swift in Sources */,
56C7A6AE1D2DFF6100EFB0C2 /* FoundationNSDateTests.swift in Sources */,
563B06D32185E04600B38F35 /* ValueObservationReadonlyTests.swift in Sources */,
567F45AB1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */,
F3BA80A61CFB2F91003DC1BA /* GRDBTestCase.swift in Sources */,
5657AB411D108BA9006283EF /* FoundationNSDataTests.swift in Sources */,
56B964C61DA521450002DA19 /* FTS5PatternTests.swift in Sources */,
562205FA1E420E49005860AC /* DatabasePoolReleaseMemoryTests.swift in Sources */,
563B071221862C3E00B38F35 /* ValueObservationRecordTests.swift in Sources */,
56B6EF60208CB746002F0ACB /* ColumnExpressionTests.swift in Sources */,
562205FD1E420EA2005860AC /* DatabasePoolBackupTests.swift in Sources */,
562206091E420EB2005860AC /* DatabaseQueueConcurrencyTests.swift in Sources */,
@@ -2279,6 +2472,7 @@
5653EB8020961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */,
5657AB611D108BA9006283EF /* FoundationNSURLTests.swift in Sources */,
564E73F3203DA2AC000C443C /* JoinSupportTests.swift in Sources */,
563B071B21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */,
5674A70C1F3087710095F066 /* DatabaseValueConvertibleEncodableTests.swift in Sources */,
5698AC8C1DA389380056AF8C /* FTS3TableBuilderTests.swift in Sources */,
5665F868203EF4640084C6C0 /* ColumnInfoTests.swift in Sources */,
@@ -2290,6 +2484,7 @@
5653EB6820961FB200F46237 /* AssociationParallelSQLTests.swift in Sources */,
F3BA80F21CFB301A003DC1BA /* DatabaseSavepointTests.swift in Sources */,
F3BA80B81CFB2FCD003DC1BA /* DatabaseErrorTests.swift in Sources */,
5613EDA321A96A8100DC7A68 /* ValueObservationCombineTests.swift in Sources */,
5653EB6A20961FB200F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */,
5698AC061D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */,
F3BA80FA1CFB3021003DC1BA /* SelectStatementTests.swift in Sources */,
@@ -2307,8 +2502,10 @@
F3BA80D51CFB2FFB003DC1BA /* DatabaseReaderTests.swift in Sources */,
F3BA81321CFB3064003DC1BA /* RecordPrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
5653EB7420961FB200F46237 /* AssociationRowScopeSearchTests.swift in Sources */,
563B06D12185E04600B38F35 /* ValueObservationExtentTests.swift in Sources */,
5623935A1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
5665FA3D2129EED8004D8612 /* DatabaseDateEncodingStrategyTests.swift in Sources */,
563B06D92185E04600B38F35 /* ValueObservationSchedulingTests.swift in Sources */,
5644DE7F20F8D1D1001FFDDE /* DatabaseValueConversionErrorTests.swift in Sources */,
F3BA80FC1CFB3021003DC1BA /* UpdateStatementTests.swift in Sources */,
56CC9249201E058900CB597E /* DropFirstCursorTests.swift in Sources */,
@@ -2316,13 +2513,16 @@
F3BA80E01CFB300F003DC1BA /* DatabaseTimestampTests.swift in Sources */,
56A5EF121EF7F20B00F03071 /* ForeignKeyInfoTests.swift in Sources */,
F3BA80B21CFB2FC5003DC1BA /* DatabaseTests.swift in Sources */,
563EF442216131F5007DAACD /* AssociationAggregateTests.swift in Sources */,
5653EB7820961FB200F46237 /* AssociationChainRowScopesTests.swift in Sources */,
F3BA80AE1CFB2FA6003DC1BA /* DatabaseRegionTests.swift in Sources */,
5653EB7020961FB200F46237 /* AssociationTableAliasTestsSQLTests.swift in Sources */,
F3BA81311CFB3064003DC1BA /* RecordPrimaryKeySingleTests.swift in Sources */,
5698AC431DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */,
5653EB6E20961FB200F46237 /* AssociationBelongsToSQLDerivationTests.swift in Sources */,
564CE5C621B8FFE600652B19 /* DatabaseRegionObservationTests.swift in Sources */,
F3BA80E11CFB300F003DC1BA /* DatabaseValueConversionTests.swift in Sources */,
564CE4E021B2E04500652B19 /* ValueObservationCompactMapTests.swift in Sources */,
5623931B1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
564F9C211F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */,
F3BA80ED1CFB3017003DC1BA /* RowFromDictionaryTests.swift in Sources */,
@@ -2332,6 +2532,7 @@
562205FF1E420EA2005860AC /* DatabasePoolReadOnlyTests.swift in Sources */,
562205FC1E420E49005860AC /* DatabaseQueueReleaseMemoryTests.swift in Sources */,
562393631DEE06D300A6B01F /* CursorTests.swift in Sources */,
563B06D52185E04600B38F35 /* ValueObservationFetchTests.swift in Sources */,
562205FE1E420EA2005860AC /* DatabasePoolConcurrencyTests.swift in Sources */,
565EFAF11D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */,
F3BA812E1CFB3064003DC1BA /* RecordPrimaryKeyMultipleTests.swift in Sources */,
@@ -2347,6 +2548,7 @@
56741EAB1E66A8B3003E422D /* FetchRequestTests.swift in Sources */,
56B964D61DA521450002DA19 /* FTS5TableBuilderTests.swift in Sources */,
5674A71D1F30A8DF0095F066 /* MutablePersistableRecordEncodableTests.swift in Sources */,
564CE4E321B2E05400652B19 /* ValueObservationMapTests.swift in Sources */,
562393511DEDFEFB00A6B01F /* EnumeratedCursorTests.swift in Sources */,
F3BA812D1CFB3064003DC1BA /* RecordMinimalPrimaryKeySingleTests.swift in Sources */,
5698AC831DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */,
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDBPlus'
s.version = '3.3.0'
s.version = '3.6.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (C) 2018 Gwendal Roué
Copyright (C) 2019 Gwendal Roué
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+20 -9
View File
@@ -37,6 +37,12 @@ XCODEVERSION := $(XCODEVERSION_MAJOR).$(XCODEVERSION_MINOR)
# Used to determine if xcpretty is available
XCPRETTY_PATH := $(shell command -v xcpretty 2> /dev/null)
# Avoid the "No output has been received in the last 10m0s" error on Travis:
COCOAPODS_EXTRA_TIME =
ifeq ($(TRAVIS),true)
COCOAPODS_EXTRA_TIME = --verbose
endif
# Tests
# =====
@@ -45,7 +51,12 @@ XCPRETTY_PATH := $(shell command -v xcpretty 2> /dev/null)
TEST_ACTIONS = clean build build-for-testing test-without-building
# When adding support for an Xcode version, look for available devices with `instruments -s devices`
ifeq ($(XCODEVERSION),10.0)
ifeq ($(XCODEVERSION),10.1)
MIN_SWIFT_VERSION = 4.0
MAX_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone XS,OS=12.1"
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
else ifeq ($(XCODEVERSION),10.0)
MIN_SWIFT_VERSION = 4.0
MAX_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=12.0"
@@ -334,7 +345,7 @@ endif
test_CocoaPodsLint_GRDB:
ifdef POD
$(POD) lib lint GRDB.swift.podspec --allow-warnings
$(POD) lib lint GRDB.swift.podspec --allow-warnings $(COCOAPODS_EXTRA_TIME)
else
@echo CocoaPods must be installed for test_CocoaPodsLint_GRDB
@exit 1
@@ -342,7 +353,7 @@ endif
test_CocoaPodsLint_GRDBPlus:
ifdef POD
$(POD) lib lint GRDBPlus.podspec --allow-warnings
$(POD) lib lint GRDBPlus.podspec --allow-warnings $(COCOAPODS_EXTRA_TIME)
else
@echo CocoaPods must be installed for test_CocoaPodsLint_GRDBPlus
@exit 1
@@ -350,7 +361,7 @@ endif
test_CocoaPodsLint_GRDBCipher:
ifdef POD
$(POD) lib lint GRDBCipher.podspec --allow-warnings
$(POD) lib lint GRDBCipher.podspec --allow-warnings $(COCOAPODS_EXTRA_TIME)
else
@echo CocoaPods must be installed for test_CocoaPodsLint_GRDBCipher
@exit 1
@@ -378,10 +389,10 @@ test_performance: Realm FMDB SQLite.swift
-scheme GRDBOSXPerformanceComparisonTests \
build-for-testing test-without-building
Realm: Tests/Performance/Realm/build/osx/swift-4.1.2/RealmSwift.framework
Realm: Tests/Performance/Realm/build/osx/swift-4.2.1/RealmSwift.framework
# Makes sure the Tests/Performance/Realm submodule has been downloaded, and Realm framework has been built.
Tests/Performance/Realm/build/osx/swift-4.1.2/RealmSwift.framework:
Tests/Performance/Realm/build/osx/swift-4.2.1/RealmSwift.framework:
$(GIT) submodule update --init --recursive Tests/Performance/Realm
cd Tests/Performance/Realm && sh build.sh osx-swift
@@ -430,10 +441,10 @@ ifdef JAZZY
--author 'Gwendal Roué' \
--author_url https://github.com/groue \
--github_url https://github.com/groue/GRDB.swift \
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v3.3.0 \
--module-version 3.3 \
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v3.6.2 \
--module-version 3.6 \
--module GRDB \
--root-url http://groue.github.io/GRDB.swift/docs/3.3/ \
--root-url http://groue.github.io/GRDB.swift/docs/3.6/ \
--output Documentation/Reference \
--xcodebuild-arguments -project,GRDB.xcodeproj,-scheme,GRDBiOS
else
@@ -24,10 +24,10 @@ configuration.trace = { print($0) }
let dbQueue = DatabaseQueue(configuration: configuration)
// Create a database table
// Create the database table to store the players
try dbQueue.inDatabase { db in
try db.create(table: "players") { t in
try db.create(table: "player") { t in
t.column("id", .integer).primaryKey()
t.column("name", .text)
t.column("score", .integer)
@@ -35,67 +35,48 @@ try dbQueue.inDatabase { db in
}
// Define the Player subclass of GRDB's Record.
//
// Record can compare against itself, and that helps avoiding useless UPDATE statements.
class Player : Record {
// Define the Player `Codable` that is a `FetchableRecord` and `MutablePersistableRecord`.
struct Player: Codable, FetchableRecord, MutablePersistableRecord {
var id: Int64
var name: String
var score: Int
convenience init(json: [String : Any]) {
// For convenience, assume JSON keys are database columns, and reuse row initializer
self.init(row: Row(json)!)
// Add ColumnExpression to Codable's CodingKeys so that we can use them
// as database columns.
//
// See https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types
// for more information about CodingKeys.
private enum CodingKeys: String, CodingKey, ColumnExpression {
case id, name, score
}
func update(from json: [String: Any]) {
id = json["id"] as! Int64
name = json["name"] as! String
score = json["score"] as! Int
}
// Record overrides
override class var databaseTableName: String {
return "players"
}
required init(row: Row) {
id = row["id"]
name = row["name"]
score = row["score"]
super.init(row: row)
}
override func encode(to container: inout PersistenceContainer) {
container["id"] = id
container["name"] = name
container["score"] = score
}
override func didInsert(with rowID: Int64, for column: String?) {
// Update a player id after it has been inserted in the database.
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
extension Player {
static func orderedById() -> QueryInterfaceRequest<Player> {
return order(CodingKeys.id)
}
}
// This is just the container of our incoming JSON
struct PlayersToSync: Codable {
let players: [Player]
}
// Synchronizes the players table with a JSON payload
func synchronizePlayers(with jsonString: String, in db: Database) throws {
let jsonData = jsonString.data(using: .utf8)!
let json = try JSONSerialization.jsonObject(with: jsonData, options: []) as! [String: Any]
// A support function that extracts an ID from a JSON player.
func jsonPlayerId(_ jsonPlayer: [String: Any]) -> Int64 {
return jsonPlayer["id"] as! Int64
}
// Sort JSON players by id:
let jsonPlayers = (json["players"] as! [[String: Any]]).sorted {
return jsonPlayerId($0) < jsonPlayerId($1)
}
let dataToSync = try JSONDecoder().decode(PlayersToSync.self, from: jsonData)
// Sort new players to sync by id:
let playersToSync = dataToSync.players.sorted { $0.id < $1.id }
// Sort database players by id:
let players = try Player.order(Column("id")).fetchAll(db)
let players = try Player.orderedById().fetchAll(db)
// Now that both lists are sorted by id, we can compare them with
// the sortedMerge() function (see https://gist.github.com/groue/7e8510849ded36f7d770).
@@ -104,28 +85,26 @@ func synchronizePlayers(with jsonString: String, in db: Database) throws {
// in either lists.
for mergeStep in sortedMerge(
left: players, // Database players
right: jsonPlayers, // JSON players
right: playersToSync, // PlayersToSync players (Decoded)
leftKey: { $0.id }, // The id of a database player
rightKey: jsonPlayerId) // The id of a JSON player
rightKey: { $0.id }) // The id of a PlayersToSync player
{
switch mergeStep {
case .left(let player):
// Delete database player without matching JSON player:
try player.delete(db)
case .right(let jsonPlayer):
// Insert JSON player without matching database player:
let player = Player(json: jsonPlayer)
try player.insert(db)
case .common(let player, let jsonPlayer):
case .right(var playerToSync):
// Insert the Codable player without matching database player:
try playerToSync.insert(db)
case .common(let player, let playerToSync):
// Update database player with its JSON counterpart:
player.update(from: jsonPlayer)
try player.updateChanges(db)
try playerToSync.updateChanges(db, from: player)
}
}
}
do {
let jsonString = """
let jsonString1 = """
{
"players": [
{ "id": 1, "name": "Arthur", "score": 1000},
@@ -134,18 +113,18 @@ do {
]
}
"""
print("---\nImport \(jsonString)")
print("---\nImport \(jsonString1)")
try dbQueue.inDatabase { db in
// SELECT * FROM players ORDER BY id
// INSERT INTO "players" ("id", "name", "score") VALUES (1,'Arthur',1000)
// INSERT INTO "players" ("id", "name", "score") VALUES (2,'Barbara',2000)
// INSERT INTO "players" ("id", "name", "score") VALUES (3,'Craig',500)
try synchronizePlayers(with: jsonString, in: db)
// SELECT * FROM player ORDER BY id
// INSERT INTO "player" ("id", "name", "score") VALUES (1,'Arthur',1000)
// INSERT INTO "player" ("id", "name", "score") VALUES (2,'Barbara',2000)
// INSERT INTO "player" ("id", "name", "score") VALUES (3,'Craig',500)
try synchronizePlayers(with: jsonString1, in: db)
}
}
do {
let jsonString = """
let jsonString2 = """
{
"players": [
{ "id": 2, "name": "Barbara", "score": 3000},
@@ -154,12 +133,12 @@ do {
]
}
"""
print("---\nImport \(jsonString)")
print("---\nImport \(jsonString2)")
try dbQueue.inDatabase { db in
// SELECT * FROM players ORDER BY id
// DELETE FROM "players" WHERE "id"=1
// UPDATE "players" SET "score"=3000 WHERE "id"=2
// INSERT INTO "players" ("id", "name", "score") VALUES (4,'Daniel',1500)
try synchronizePlayers(with: jsonString, in: db)
// SELECT * FROM player ORDER BY id
// DELETE FROM "player" WHERE "id"=1
// UPDATE "player" SET "score"=3000 WHERE "id"=2
// INSERT INTO "player" ("id", "name", "score") VALUES (4,'Daniel',1500)
try synchronizePlayers(with: jsonString2, in: db)
}
}
+1203 -446
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.3.0</string>
<string>3.6.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+1
View File
@@ -24,6 +24,7 @@
- [ ] Allow joining methods on DerivableRequest
- [ ] DatabaseWriter.assertWriteAccess()
- [ ] Configuration.crashOnError = true
- [ ] Remove associated record from PersistenceError.recordNotFound. It should be possible, in userland, to write a method that throws this error without having a fully constructed record.
- [ ] Support for "INSERT INTO ... SELECT ...". For example:
```swift
File diff suppressed because it is too large. Load diff
@@ -33,6 +33,18 @@ private struct PlayerWithOptionalTeam: Decodable, FetchableRecord {
static let team = Player.team.forKey(CodingKeys.team)
}
extension QueryInterfaceRequest where T == Player {
func filter(teamName: String) -> QueryInterfaceRequest<Player> {
return joining(required: PlayerWithOptionalTeam.team.filter(Column("name") == teamName))
}
func orderedByTeamName() -> QueryInterfaceRequest<Player> {
let teamAlias = TableAlias()
return joining(optional: PlayerWithOptionalTeam.team.aliased(teamAlias))
.order(teamAlias[Column("name")], Column("name"))
}
}
/// Test support for Decodable records
class AssociationBelongsToDecodableRecordTests: GRDBTestCase {
@@ -108,4 +120,26 @@ class AssociationBelongsToDecodableRecordTests: GRDBTestCase {
XCTAssertNil(players[1].teamId)
XCTAssertEqual(players[1].name, "Barbara")
}
func testRequestRefining() throws {
let dbQueue = try makeDatabaseQueue()
let request = Player
.including(required: PlayerWithRequiredTeam.team.select(Column("name"), Column("id")))
.filter(teamName: "Reds")
.orderedByTeamName()
.asRequest(of: PlayerWithRequiredTeam.self)
let records = try dbQueue.inDatabase { try request.fetchAll($0) }
XCTAssertEqual(lastSQLQuery, """
SELECT "players".*, "teams"."name", "teams"."id" \
FROM "players" \
JOIN "teams" ON (("teams"."id" = "players"."teamId") AND ("teams"."name" = 'Reds')) \
ORDER BY "teams"."name", "players"."name"
""")
XCTAssertEqual(records.count, 1)
XCTAssertEqual(records[0].player.id, 1)
XCTAssertEqual(records[0].player.teamId, 1)
XCTAssertEqual(records[0].player.name, "Arthur")
XCTAssertEqual(records[0].team.id, 1)
XCTAssertEqual(records[0].team.name, "Reds")
}
}
+632 -40
View File
@@ -67,7 +67,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c)), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
@@ -87,7 +87,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
@@ -97,6 +97,154 @@ class AssociationChainSQLTests: GRDBTestCase {
}
}
func testChainOfTwoIncludingIncludingIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b.including(required: B.c).including(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(required: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c).including(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c).including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c).including(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c).including(required: B.c)), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.c.including(required: C.d).including(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(required: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(optional: C.d).including(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d).including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d).including(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.including(optional: C.d).including(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.including(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoIncludingIncludingJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b.including(required: B.c).joining(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(required: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c).joining(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c).joining(required: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c).joining(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c).joining(required: B.c)), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.c.including(required: C.d).joining(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(required: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(optional: C.d).joining(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.including(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d).joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.including(required: C.d).joining(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.including(optional: C.d).joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.including(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoIncludingJoining() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -113,7 +261,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c)), "")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c)), "")
try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
@@ -133,7 +281,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.joining(optional: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
@@ -143,6 +291,154 @@ class AssociationChainSQLTests: GRDBTestCase {
}
}
func testChainOfTwoIncludingJoiningIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b.joining(required: B.c).including(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(required: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c).including(required: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c).including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c).including(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c).including(required: B.c)), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(required: C.d).including(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(required: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(optional: C.d).including(required: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d).including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d).including(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.joining(optional: C.d).including(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.joining(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "c".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoIncludingJoiningJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b.joining(required: B.c).joining(required: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(required: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c).joining(required: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c).joining(required: B.c)), "")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c).joining(optional: B.c)), "")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c).joining(required: B.c)), "")
try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "b".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(required: C.d).joining(required: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(required: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(optional: C.d).joining(required: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.including(required: B.c.joining(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d).joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.joining(required: C.d).joining(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.including(optional: B.c.joining(optional: C.d).joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.including(optional: B.c.joining(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "c".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoJoiningIncluding() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -159,7 +455,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
@@ -179,7 +475,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
@@ -189,6 +485,154 @@ class AssociationChainSQLTests: GRDBTestCase {
}
}
func testChainOfTwoJoiningIncludingIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b.including(required: B.c).including(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(required: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c).including(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c).including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c).including(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c).including(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(required: C.d).including(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(required: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(optional: C.d).including(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d).including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d).including(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.including(optional: C.d).including(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.including(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoJoiningIncludingJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b.including(required: B.c).joining(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(required: B.c).joining(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c).joining(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c).joining(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c).joining(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c).joining(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c).joining(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(required: C.d).joining(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(required: C.d).joining(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(optional: C.d).joining(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.including(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d).joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.including(required: C.d).joining(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.including(optional: C.d).joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.including(optional: C.d).joining(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoJoiningJoining() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -205,7 +649,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c)), """
SELECT "a".* \
FROM "a" \
@@ -225,7 +669,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.joining(optional: C.d)), """
SELECT "b".* \
FROM "b" \
@@ -235,6 +679,154 @@ class AssociationChainSQLTests: GRDBTestCase {
}
}
func testChainOfTwoJoiningJoiningIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b.joining(required: B.c).including(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(required: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c).including(required: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c).including(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c).including(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c).including(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c).including(optional: B.c)), """
SELECT "a".*, "c".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(required: C.d).including(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(required: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(optional: C.d).including(required: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d).including(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d).including(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.joining(optional: C.d).including(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.joining(optional: C.d).including(optional: C.d)), """
SELECT "b".*, "d".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfTwoJoiningJoiningJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b.joining(required: B.c).joining(required: B.c)), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(required: B.c).joining(optional: B.c)), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c).joining(required: B.c)), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c).joining(optional: B.c)), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c).joining(required: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c).joining(optional: B.c)), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c).joining(required: B.c)), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c).joining(optional: B.c)), """
SELECT "a".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid") \
LEFT JOIN "c" ON ("c"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(required: C.d).joining(required: C.d)), """
SELECT "b".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(required: C.d).joining(optional: C.d)), """
SELECT "b".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(optional: C.d).joining(required: C.d)), """
SELECT "b".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
JOIN "d" ON ("d"."id" = "c"."did")
""")
try assertEqualSQL(db, B.joining(required: B.c.joining(optional: C.d).joining(optional: C.d)), """
SELECT "b".* \
FROM "b" \
JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d).joining(required: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.joining(required: C.d).joining(optional: C.d)), "TODO")
// try assertEqualSQL(db, B.joining(optional: B.c.joining(optional: C.d).joining(required: C.d)), "TODO")
try assertEqualSQL(db, B.joining(optional: B.c.joining(optional: C.d).joining(optional: C.d)), """
SELECT "b".* \
FROM "b" \
LEFT JOIN "c" ON ("c"."bid" = "b"."id") \
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
}
}
func testChainOfThreeIncludingIncludingIncluding() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -253,7 +845,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "b".*, "c".*, "d".* \
FROM "a" \
@@ -262,9 +854,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "b".*, "c".*, "d".* \
FROM "a" \
@@ -293,7 +885,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(required: A.b.including(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
@@ -302,9 +894,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.including(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "b".*, "c".* \
FROM "a" \
@@ -333,7 +925,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "b".*, "d".* \
FROM "a" \
@@ -342,9 +934,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "b".*, "d".* \
FROM "a" \
@@ -373,7 +965,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(required: A.b.joining(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "b".* \
FROM "a" \
@@ -382,9 +974,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.including(optional: A.b.joining(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "b".* \
FROM "a" \
@@ -413,7 +1005,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "c".*, "d".* \
FROM "a" \
@@ -422,9 +1014,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "c".*, "d".* \
FROM "a" \
@@ -453,7 +1045,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(required: A.b.including(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "c".* \
FROM "a" \
@@ -462,9 +1054,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(required: B.c.joining(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.including(optional: B.c.joining(optional: C.d))), """
SELECT "a".*, "c".* \
FROM "a" \
@@ -493,7 +1085,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "d".* \
FROM "a" \
@@ -502,9 +1094,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.including(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.including(optional: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.including(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.including(optional: C.d))), """
SELECT "a".*, "d".* \
FROM "a" \
@@ -533,7 +1125,7 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(required: A.b.joining(optional: B.c.joining(optional: C.d))), """
SELECT "a".* \
FROM "a" \
@@ -542,9 +1134,9 @@ class AssociationChainSQLTests: GRDBTestCase {
LEFT JOIN "d" ON ("d"."id" = "c"."did")
""")
// TODO: chainOptionalRequired
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.joining(optional: C.d))), "TODO)
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.joining(required: C.d))), "TODO")
// try assertEqualSQL(db, A.joining(optional: A.b.joining(required: B.c.joining(optional: C.d))), "TODO)
// try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.joining(required: C.d))), "TODO")
try assertEqualSQL(db, A.joining(optional: A.b.joining(optional: B.c.joining(optional: C.d))), """
SELECT "a".* \
FROM "a" \
File diff suppressed because it is too large. Load diff
@@ -108,6 +108,106 @@ class AssociationParallelSQLTests: GRDBTestCase {
}
}
func testParallelTwoIncludingIncludingOtherKey() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b).including(required: A.b.forKey("altb")), """
SELECT "a".*, "b1".*, "b2".* \
FROM "a" \
JOIN "b" "b1" ON ("b1"."id" = "a"."bid") \
JOIN "b" "b2" ON ("b2"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(required: A.b).including(optional: A.b.forKey("altb")), """
SELECT "a".*, "b1".*, "b2".* \
FROM "a" \
JOIN "b" "b1" ON ("b1"."id" = "a"."bid") \
LEFT JOIN "b" "b2" ON ("b2"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).including(required: A.b.forKey("altb")), """
SELECT "a".*, "b1".*, "b2".* \
FROM "a" \
LEFT JOIN "b" "b1" ON ("b1"."id" = "a"."bid") \
JOIN "b" "b2" ON ("b2"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).including(optional: A.b.forKey("altb")), """
SELECT "a".*, "b1".*, "b2".* \
FROM "a" \
LEFT JOIN "b" "b1" ON ("b1"."id" = "a"."bid") \
LEFT JOIN "b" "b2" ON ("b2"."id" = "a"."bid")
""")
try assertEqualSQL(db, B.including(required: B.a).including(required: B.a.forKey("alta")), """
SELECT "b".*, "a1".*, "a2".* \
FROM "b" \
JOIN "a" "a1" ON ("a1"."bid" = "b"."id") \
JOIN "a" "a2" ON ("a2"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.a).including(optional: B.a.forKey("alta")), """
SELECT "b".*, "a1".*, "a2".* \
FROM "b" \
JOIN "a" "a1" ON ("a1"."bid" = "b"."id") \
LEFT JOIN "a" "a2" ON ("a2"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).including(required: B.a.forKey("alta")), """
SELECT "b".*, "a1".*, "a2".* \
FROM "b" \
LEFT JOIN "a" "a1" ON ("a1"."bid" = "b"."id") \
JOIN "a" "a2" ON ("a2"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).including(optional: B.a.forKey("alta")), """
SELECT "b".*, "a1".*, "a2".* \
FROM "b" \
LEFT JOIN "a" "a1" ON ("a1"."bid" = "b"."id") \
LEFT JOIN "a" "a2" ON ("a2"."bid" = "b"."id")
""")
}
}
func testParallelTwoIncludingIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b).including(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(required: A.b).including(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).including(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).including(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, B.including(required: B.a).including(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.a).including(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).including(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).including(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
LEFT JOIN "a" ON ("a"."bid" = "b"."id")
""")
}
}
func testParallelTwoIncludingJoining() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -162,6 +262,52 @@ class AssociationParallelSQLTests: GRDBTestCase {
}
}
func testParallelTwoIncludingJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.including(required: A.b).joining(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(required: A.b).joining(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).joining(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.including(optional: A.b).joining(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, B.including(required: B.a).joining(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(required: B.a).joining(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).joining(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.including(optional: B.a).joining(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
LEFT JOIN "a" ON ("a"."bid" = "b"."id")
""")
}
}
func testParallelTwoJoiningIncluding() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -216,6 +362,52 @@ class AssociationParallelSQLTests: GRDBTestCase {
}
}
func testParallelTwoJoiningIncludingSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b).including(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(required: A.b).including(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(optional: A.b).including(required: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(optional: A.b).including(optional: A.b), """
SELECT "a".*, "b".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, B.joining(required: B.a).including(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.a).including(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(optional: B.a).including(required: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(optional: B.a).including(optional: B.a), """
SELECT "b".*, "a".* \
FROM "b" \
LEFT JOIN "a" ON ("a"."bid" = "b"."id")
""")
}
}
func testParallelTwoJoiningJoining() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
@@ -269,4 +461,258 @@ class AssociationParallelSQLTests: GRDBTestCase {
""")
}
}
func testParallelTwoJoiningJoiningSameAssociation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
try assertEqualSQL(db, A.joining(required: A.b).joining(required: A.b), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(required: A.b).joining(optional: A.b), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(optional: A.b).joining(required: A.b), """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, A.joining(optional: A.b).joining(optional: A.b), """
SELECT "a".* \
FROM "a" \
LEFT JOIN "b" ON ("b"."id" = "a"."bid")
""")
try assertEqualSQL(db, B.joining(required: B.a).joining(required: B.a), """
SELECT "b".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(required: B.a).joining(optional: B.a), """
SELECT "b".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(optional: B.a).joining(required: B.a), """
SELECT "b".* \
FROM "b" \
JOIN "a" ON ("a"."bid" = "b"."id")
""")
try assertEqualSQL(db, B.joining(optional: B.a).joining(optional: B.a), """
SELECT "b".* \
FROM "b" \
LEFT JOIN "a" ON ("a"."bid" = "b"."id")
""")
}
}
func testRequestRefiningFilter() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
do {
let request = A
.joining(required: A.b.filter(Column("id") > 1))
.joining(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON (("b"."id" = "a"."bid") AND ("b"."id" > 1))
""")
}
do {
let request = A
.joining(required: A.b)
.joining(required: A.b.filter(Column("id") < 3))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON (("b"."id" = "a"."bid") AND ("b"."id" < 3))
""")
}
do {
let request = A
.joining(required: A.b.filter(Column("id") > 1))
.joining(required: A.b.filter(Column("id") < 3))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON (("b"."id" = "a"."bid") AND (("b"."id" > 1) AND ("b"."id" < 3)))
""")
}
}
}
func testRequestRefiningOrder() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
do {
let request = A
.joining(required: A.b.order(Column("id")))
.joining(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
ORDER BY "b"."id"
""")
}
do {
let request = A
.joining(required: A.b)
.joining(required: A.b.order(Column("id").desc))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
ORDER BY "b"."id" DESC
""")
}
do {
let request = A
.joining(required: A.b.order(Column("id")))
.joining(required: A.b.order(Column("id").desc))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid") \
ORDER BY "b"."id" DESC
""")
}
}
}
func testRequestRefiningSelection() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
// joining + joining
do {
let request = A
.joining(required: A.b.select(Column("id"), 1.databaseValue))
.joining(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.joining(required: A.b)
.joining(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.joining(required: A.b.select(Column("id"), 1.databaseValue))
.joining(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
// joining + including
do {
let request = A
.joining(required: A.b.select(Column("id"), 1.databaseValue))
.including(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.joining(required: A.b)
.including(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 2 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.joining(required: A.b.select(Column("id"), 1.databaseValue))
.including(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 2 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
// including + joining
do {
let request = A
.including(required: A.b.select(Column("id"), 1.databaseValue))
.joining(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 1 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.including(required: A.b)
.joining(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.including(required: A.b.select(Column("id"), 1.databaseValue))
.joining(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 1 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
// including + including
do {
let request = A
.including(required: A.b.select(Column("id"), 1.databaseValue))
.including(required: A.b)
try assertEqualSQL(db, request, """
SELECT "a".*, "b".* \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.including(required: A.b)
.including(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 2 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
do {
let request = A
.including(required: A.b.select(Column("id"), 1.databaseValue))
.including(required: A.b.select(Column("id"), 2.databaseValue))
try assertEqualSQL(db, request, """
SELECT "a".*, "b"."id", 2 \
FROM "a" \
JOIN "b" ON ("b"."id" = "a"."bid")
""")
}
}
}
}
@@ -337,4 +337,146 @@ class AssociationTableAliasTestsSQLTests : GRDBTestCase {
}
}
}
func testAssociationRewrite() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
do {
let request: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return A
.joining(required: A.parent.aliased(parentAlias))
.filter(parentAlias[name] == "foo")
}()
let request2: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return request
.joining(optional: A.parent.aliased(parentAlias))
.order(parentAlias[name])
}()
let request3 = request2.including(optional: A.parent)
try assertEqualSQL(db, request3, """
SELECT "a1".*, "a2".* \
FROM "a" "a1" \
JOIN "a" "a2" ON ("a2"."id" = "a1"."parentId") \
WHERE ("a2"."name" = 'foo') \
ORDER BY "a2"."name"
""")
}
do {
let request: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias(name: "parent")
let name = Column("name")
return A
.joining(required: A.parent.aliased(parentAlias))
.filter(parentAlias[name] == "foo")
}()
let request2: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return request
.joining(optional: A.parent.aliased(parentAlias))
.order(parentAlias[name])
}()
let request3 = request2.including(optional: A.parent)
try assertEqualSQL(db, request3, """
SELECT "a".*, "parent".* \
FROM "a" \
JOIN "a" "parent" ON ("parent"."id" = "a"."parentId") \
WHERE ("parent"."name" = 'foo') \
ORDER BY "parent"."name"
""")
}
do {
let request: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return A
.joining(required: A.parent.aliased(parentAlias))
.filter(parentAlias[name] == "foo")
}()
let request2: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias(name: "parent")
let name = Column("name")
return request
.joining(optional: A.parent.aliased(parentAlias))
.order(parentAlias[name])
}()
let request3 = request2.including(optional: A.parent)
try assertEqualSQL(db, request3, """
SELECT "a".*, "parent".* \
FROM "a" \
JOIN "a" "parent" ON ("parent"."id" = "a"."parentId") \
WHERE ("parent"."name" = 'foo') \
ORDER BY "parent"."name"
""")
}
do {
let request: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias(name: "parent")
let name = Column("name")
return A
.joining(required: A.parent.aliased(parentAlias))
.filter(parentAlias[name] == "foo")
}()
let request2: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias(name: "parent")
let name = Column("name")
return request
.joining(optional: A.parent.aliased(parentAlias))
.order(parentAlias[name])
}()
let request3 = request2.including(optional: A.parent)
try assertEqualSQL(db, request3, """
SELECT "a".*, "parent".* \
FROM "a" \
JOIN "a" "parent" ON ("parent"."id" = "a"."parentId") \
WHERE ("parent"."name" = 'foo') \
ORDER BY "parent"."name"
""")
}
do {
let request: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return A
.joining(required: A.parent.aliased(parentAlias))
.filter(parentAlias[name] == "foo")
}()
let request2: QueryInterfaceRequest<A> = {
let parentAlias = TableAlias()
let name = Column("name")
return request
.joining(optional: A.parent.aliased(parentAlias))
.order(parentAlias[name])
}()
let parentAlias = TableAlias(name: "parent")
let request3 = request2.including(optional: A.parent.aliased(parentAlias))
try assertEqualSQL(db, request3, """
SELECT "a".*, "parent".* \
FROM "a" \
JOIN "a" "parent" ON ("parent"."id" = "a"."parentId") \
WHERE ("parent"."name" = 'foo') \
ORDER BY "parent"."name"
""")
}
}
}
}
@@ -42,18 +42,6 @@ private class UserDatabaseAggregate2 : DatabaseAggregate {
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 {
@@ -66,23 +54,6 @@ private class UserDatabaseValueConvertible2 : DatabaseValueConvertible {
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 writeWithoutTransaction<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() }
func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> { preconditionFailure() }
}
// MARK: - FTS5Tokenizer
#if SQLITE_ENABLE_FTS5
+11
View File
@@ -9,6 +9,17 @@ import XCTest
class DatabaseErrorTests: GRDBTestCase {
func testDatabaseErrorMessage() {
// Error messages are not always available
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, iOSApplicationExtension 8.2, *) {
// We don't test for actual messages, since they may depend on SQLite version
XCTAssertEqual(DatabaseError().resultCode, .SQLITE_ERROR)
XCTAssertNotNil(DatabaseError().message)
XCTAssertNotNil(DatabaseError(resultCode: .SQLITE_BUSY).message)
XCTAssertNotEqual(DatabaseError().message, DatabaseError(resultCode: .SQLITE_BUSY).message)
}
}
func testDatabaseErrorInTransaction() throws {
let dbQueue = try makeDatabaseQueue()
do {
+4 -2
View File
@@ -12,9 +12,11 @@ class DatabaseLogErrorTests: GRDBTestCase {
func testErrorLog() throws {
let dbQueue = try makeDatabaseQueue()
dbQueue.inDatabase { db in
_ = try? db.execute("That's not SQL.")
_ = try? db.execute("Abracadabra")
}
XCTAssertEqual(lastResultCode!, ResultCode.SQLITE_ERROR)
XCTAssertEqual(lastMessage!, "near \"That\": syntax error")
// Don't check for exact error message because it depends on SQLite version
XCTAssert(lastMessage!.contains("syntax error"))
XCTAssert(lastMessage!.contains("Abracadabra"))
}
}
@@ -1,4 +1,5 @@
import XCTest
import Dispatch
#if GRDBCIPHER
import GRDBCipher
#elseif GRDBCUSTOMSQLITE
@@ -947,7 +948,6 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
}
do {
try future.wait()
XCTFail("Expected error")
} catch let error as DatabaseError {
XCTAssertEqual(error.resultCode, .SQLITE_BUSY)
XCTAssertEqual(error.message!, "database is locked")
@@ -1098,4 +1098,72 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
blocks[index]()
}
}
func testTargetQueue() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
func test(targetQueue: DispatchQueue) throws {
dbConfiguration.targetQueue = targetQueue
let dbPool = try makeDatabasePool()
try dbPool.write { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
try dbPool.read { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
}
// background queue
try test(targetQueue: .global(qos: .background))
// main queue
let expectation = self.expectation(description: "main")
DispatchQueue.global(qos: .default).async {
try! test(targetQueue: .main)
expectation.fulfill()
}
waitForExpectations(timeout: 1, handler: nil)
}
}
func testQoS() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
func test(qos: DispatchQoS) throws {
// https://forums.swift.org/t/what-is-the-default-target-queue-for-a-serial-queue/18094/5
//
// > [...] the default target queue [for a serial queue] is the
// > [default] overcommit [global concurrent] queue.
//
// We want this default target queue in order to test database QoS
// with dispatchPrecondition(condition:).
//
// > [...] You can get a reference to the overcommit queue by
// > dropping down to the C function dispatch_get_global_queue
// > (available in Swift with a __ prefix) and passing the private
// > value of DISPATCH_QUEUE_OVERCOMMIT.
// >
// > [...] Of course you should not do this in production code,
// > because DISPATCH_QUEUE_OVERCOMMIT is not a public API. I don't
// > know of a way to get a reference to the overcommit queue using
// > only public APIs.
let DISPATCH_QUEUE_OVERCOMMIT: UInt = 2
let targetQueue = __dispatch_get_global_queue(
Int(qos.qosClass.rawValue.rawValue),
DISPATCH_QUEUE_OVERCOMMIT)
dbConfiguration.qos = qos
let dbPool = try makeDatabasePool()
try dbPool.write { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
try dbPool.read { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
}
try test(qos: .background)
try test(qos: .userInitiated)
}
}
}
@@ -188,39 +188,6 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase {
XCTAssertEqual(openConnectionCount, 0)
}
// TODO: this test should be duplicated for all cursor types
func testDatabaseCursorRetainSQLiteConnection() throws {
let countQueue = DispatchQueue(label: "GRDB")
var openConnectionCount = 0
dbConfiguration.SQLiteConnectionDidOpen = {
countQueue.sync {
openConnectionCount += 1
}
}
dbConfiguration.SQLiteConnectionDidClose = {
countQueue.sync {
openConnectionCount -= 1
}
}
var cursor: FastDatabaseValueCursor<Int>? = nil
do {
try! makeDatabasePool().write { db in
try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
try db.execute("INSERT INTO items (id) VALUES (NULL)")
try db.execute("INSERT INTO items (id) VALUES (NULL)")
cursor = try Int.fetchCursor(db, "SELECT id FROM items")
XCTAssertTrue(try cursor!.next() != nil)
XCTAssertEqual(openConnectionCount, 1)
}
}
XCTAssertEqual(openConnectionCount, 0)
XCTAssertTrue(try! cursor!.next() != nil)
XCTAssertTrue(try! cursor!.next() == nil)
}
func testStatementDoNotRetainDatabaseConnection() throws {
// Block 1 Block 2
// create statement INSERT
@@ -102,39 +102,6 @@ class DatabaseQueueReleaseMemoryTests: GRDBTestCase {
// All connections are closed
XCTAssertEqual(openConnectionCount, 0)
}
// TODO: this test should be duplicated for all cursor types
func testDatabaseCursorRetainSQLiteConnection() throws {
let countQueue = DispatchQueue(label: "GRDB")
var openConnectionCount = 0
dbConfiguration.SQLiteConnectionDidOpen = {
countQueue.sync {
openConnectionCount += 1
}
}
dbConfiguration.SQLiteConnectionDidClose = {
countQueue.sync {
openConnectionCount -= 1
}
}
var cursor: FastDatabaseValueCursor<Int>? = nil
do {
try! makeDatabaseQueue().inDatabase { db in
try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
try db.execute("INSERT INTO items (id) VALUES (NULL)")
try db.execute("INSERT INTO items (id) VALUES (NULL)")
cursor = try Int.fetchCursor(db, "SELECT id FROM items")
XCTAssertTrue(try cursor!.next() != nil)
XCTAssertEqual(openConnectionCount, 1)
}
}
XCTAssertEqual(openConnectionCount, 0)
XCTAssertTrue(try! cursor!.next() != nil)
XCTAssertTrue(try! cursor!.next() == nil)
}
func testStatementDoNotRetainDatabaseConnection() throws {
// Block 1 Block 2
+68
View File
@@ -131,4 +131,72 @@ class DatabaseQueueTests: GRDBTestCase {
XCTAssertEqual(label, "Toreador")
}
}
func testTargetQueue() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
func test(targetQueue: DispatchQueue) throws {
dbConfiguration.targetQueue = targetQueue
let dbQueue = try makeDatabaseQueue()
try dbQueue.write { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
dbQueue.read { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
}
// background queue
try test(targetQueue: .global(qos: .background))
// main queue
let expectation = self.expectation(description: "main")
DispatchQueue.global(qos: .default).async {
try! test(targetQueue: .main)
expectation.fulfill()
}
waitForExpectations(timeout: 1, handler: nil)
}
}
func testQoS() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
func test(qos: DispatchQoS) throws {
// https://forums.swift.org/t/what-is-the-default-target-queue-for-a-serial-queue/18094/5
//
// > [...] the default target queue [for a serial queue] is the
// > [default] overcommit [global concurrent] queue.
//
// We want this default target queue in order to test database QoS
// with dispatchPrecondition(condition:).
//
// > [...] You can get a reference to the overcommit queue by
// > dropping down to the C function dispatch_get_global_queue
// > (available in Swift with a __ prefix) and passing the private
// > value of DISPATCH_QUEUE_OVERCOMMIT.
// >
// > [...] Of course you should not do this in production code,
// > because DISPATCH_QUEUE_OVERCOMMIT is not a public API. I don't
// > know of a way to get a reference to the overcommit queue using
// > only public APIs.
let DISPATCH_QUEUE_OVERCOMMIT: UInt = 2
let targetQueue = __dispatch_get_global_queue(
Int(qos.qosClass.rawValue.rawValue),
DISPATCH_QUEUE_OVERCOMMIT)
dbConfiguration.qos = qos
let dbQueue = try makeDatabaseQueue()
try dbQueue.write { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
dbQueue.read { _ in
dispatchPrecondition(condition: .onQueue(targetQueue))
}
}
try test(qos: .background)
try test(qos: .userInitiated)
}
}
}
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more