Compare commits

..
1568 Commits
Author SHA1 Message Date
Gwendal Roué 4c2290f84b Move Design Notes 2021-01-28 08:29:48 +01:00
Gwendal Roué efc8e4bbf9 Fetching players 2021-01-28 08:27:41 +01:00
Gwendal Roué 5c986b142b Saving playerrs 2021-01-28 08:10:30 +01:00
Gwendal Roué 4ec77f8d02 TODO 2021-01-28 08:10:30 +01:00
Gwendal Roué d7dfb4c2ed Precise documentation 2021-01-28 08:10:30 +01:00
Gwendal Roué f4a32edbb9 TODO 2021-01-28 08:10:30 +01:00
Gwendal Roué 8bb9ef0849 Indent raw SQL versions 2021-01-28 08:10:30 +01:00
Gwendal Roué 0210144ea9 Extract Player definition 2021-01-28 08:10:30 +01:00
Gwendal Roué 2842bc92ca Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 2ca857d895 Fix typo 2021-01-28 08:10:30 +01:00
Gwendal Roué 95ec107134 Group design notes at the end of the chapter 2021-01-28 08:10:30 +01:00
Gwendal Roué 18c65eecb6 Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 3c1ab47843 Group design notes at the end of the chapter 2021-01-28 08:10:30 +01:00
Gwendal Roué 6b706bbc85 Group design notes 2021-01-28 08:10:30 +01:00
Gwendal Roué e6435ade96 Talk about sample code 2021-01-28 08:10:30 +01:00
Gwendal Roué c854b5a88a Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué f2d51d2feb The Database Service rewrite 2021-01-28 08:10:30 +01:00
Gwendal Roué 95cd6f3c4f Introduction 2021-01-28 08:10:30 +01:00
Gwendal Roué 4a0d8602e2 Clarify the tutorial scope 2021-01-28 08:10:30 +01:00
Gwendal Roué a83f76be10 Remove a missing logical link 2021-01-28 08:10:30 +01:00
Gwendal Roué 10420e6426 Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 5ab90c1b6c More achievements 2021-01-28 08:10:30 +01:00
Gwendal Roué 5c70477a04 SwiftUI use in-memory databases 2021-01-28 08:10:30 +01:00
Gwendal Roué cb4a0f349e Rename the tutorial 2021-01-28 08:10:30 +01:00
Gwendal Roué 9a0db52c9b The Initial Application State 2021-01-28 08:10:30 +01:00
Gwendal Roué 7cf7300129 Fix typo and wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 6fbeed1a2a Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 1defe3aaf1 Why columns are hidden 2021-01-28 08:10:30 +01:00
Gwendal Roué 074af18152 Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué 43c9aa3474 Wording 2021-01-28 08:10:30 +01:00
Gwendal Roué d95a76a47a Compare with ActiveRecord 2021-01-28 08:10:30 +01:00
Gwendal Roué ae8c1f11a9 Player requests 2021-01-28 08:10:30 +01:00
Gwendal Roué 4decdd7dea SQL Interpolation: add support for collations 2021-01-28 08:10:30 +01:00
Gwendal Roué 1d41807e25 Add link 2021-01-28 08:10:30 +01:00
Gwendal Roué 571a70e073 Organization 2021-01-28 08:10:30 +01:00
Gwendal Roué 2822c959f8 Repurpose the focus of the tutorial 2021-01-28 08:10:30 +01:00
Gwendal Roué d8c5d85fcb Postpone name collation until the fetch 2021-01-28 08:10:30 +01:00
Gwendal Roué 3f493fa7a8 Mention ACID robustness against errors and crashes 2021-01-28 08:10:29 +01:00
Gwendal Roué cecc3cffdc Emphasis 2021-01-28 08:10:29 +01:00
Gwendal Roué 5ea0cf6cdd Introduce fetchable records 2021-01-28 08:10:29 +01:00
Gwendal Roué 3ebbddb9f3 Tip about helper methods 2021-01-28 08:10:29 +01:00
Gwendal Roué 238f01725b SQL version of AppDatabase.refreshPlayers() 2021-01-28 08:10:29 +01:00
Gwendal Roué 51b975e872 Fix typo 2021-01-28 08:10:29 +01:00
Gwendal Roué 4b9643daf2 Modifying Players chapter 2021-01-28 08:10:29 +01:00
Gwendal Roué 6daf078fc3 Fix focus 2021-01-28 08:10:29 +01:00
Gwendal Roué 7aced9b925 Documentation 2021-01-28 08:10:29 +01:00
Gwendal Roué 16fc88ba09 Wording 2021-01-28 08:10:29 +01:00
Gwendal Roué 4ac7e3d15c Avoid "such as" repetition 2021-01-28 08:10:29 +01:00
Gwendal Roué 48b8c1ee14 More notes about SQL injection prevention 2021-01-28 08:10:29 +01:00
Gwendal Roué 1af981255d How to deal with missing Swift versions of SQLite functions or operators? 2021-01-28 08:10:29 +01:00
Gwendal Roué 6a07361614 Indent design notes 2021-01-28 08:10:29 +01:00
Gwendal Roué f32f5e2d7b Describe the tutorial audience 2021-01-28 08:10:29 +01:00
Gwendal Roué 322959f1c4 Deleting players 2021-01-28 08:10:29 +01:00
Gwendal Roué eaca12aed1 Fix typo 2021-01-28 08:10:29 +01:00
Gwendal Roué 96a8b46214 Wording 2021-01-28 08:10:29 +01:00
Gwendal Roué 7f2f4fdfcc Wording 2021-01-28 08:10:29 +01:00
Gwendal Roué ceccbb38fb Wording 2021-01-28 08:10:29 +01:00
Gwendal Roué af21c82dd6 Better explain why id is autoincremented 2021-01-28 08:10:29 +01:00
Gwendal Roué b2573a12bc Explain why id is autoincremented 2021-01-28 08:10:29 +01:00
Gwendal Roué d00de45e4f Links & wording 2021-01-28 08:10:29 +01:00
Gwendal Roué 6512e7bf61 Fix typo 2021-01-28 08:10:29 +01:00
Gwendal Roué 1cd88114ec Rewrite introduction to migrations 2021-01-28 08:10:29 +01:00
Gwendal Roué 86cf024a78 AppDatabase error handling suggestion 2021-01-28 08:10:29 +01:00
Gwendal Roué afdde192cd Rewrite the AppDatabase introduction 2021-01-28 08:10:29 +01:00
Gwendal Roué 0b321dfedf Rewrite the introduction 2021-01-28 08:10:29 +01:00
Gwendal Roué 7617bb258d Getting Started tutorial 2021-01-28 08:10:29 +01:00
Gwendal Roué 104466170b Demo app feeds from a single observation 2021-01-28 08:10:29 +01:00
Gwendal Roué 4b5a1340aa Demo apps: store the database in its own folder
This is a recommended good practice
2021-01-28 08:10:29 +01:00
Gwendal Roué 6ea56060a2 Merge branch 'master' into development 2021-01-27 19:46:16 +01:00
Gwendal Roué 3733648598 [skip travis] Remove all details about SPM installation (#913) 2021-01-27 14:05:08 +01:00
Gwendal Roué 40341d4e98 Merge branch 'master' into development 2021-01-23 17:47:04 +01:00
Gwendal Roué 5393d97033 [skip travis] Update BRAG.md 2021-01-23 17:45:54 +01:00
Gwendal Roué 8bf9e5e30f Decouple associations from TableRecord
Associations is generic for type safety, not for defining the association (just as QueryInterfaceRequest)
2021-01-23 09:48:18 +01:00
Gwendal Roué bc5ba1fda5 Merge branch 'development' 2021-01-21 08:23:18 +01:00
Gwendal Roué 034cf065c1 Merge pull request #912 from groue/dev/demo-test
Add tests to the demo apps
2021-01-21 08:22:47 +01:00
Gwendal Roué d7743d0a56 Documentation 2021-01-21 08:21:48 +01:00
Gwendal Roué 5ed0a4a6ed Test that the SwiftUI demo app feeds on immediate publishers 2021-01-21 08:17:02 +01:00
Gwendal Roué dd2e8bb063 Documentation 2021-01-21 08:04:19 +01:00
Gwendal Roué 790b678c74 Documentation 2021-01-20 19:51:03 +01:00
Gwendal Roué abb50a0786 Restore fileprivate Player.Columns 2021-01-20 19:47:04 +01:00
Gwendal Roué 2862edcea8 Documentation 2021-01-20 19:42:32 +01:00
Gwendal Roué 91c17aca41 GRDBCombineDemo tests 2021-01-20 19:14:27 +01:00
Gwendal Roué fc546e25e2 GRDBDemoiOS tests 2021-01-20 19:14:02 +01:00
Gwendal Roué a5b6a0a51f [skip travis] Merge branch 'development' 2021-01-20 07:52:24 +01:00
Gwendal Roué befeb07234 Clarify FTS5Pattern(matchingPrefixPhrase:) behavior 2021-01-20 07:51:00 +01:00
Gwendal Roué 8fe3d41d18 Cleanup and harmonize demo apps 2021-01-20 07:48:05 +01:00
Gwendal Roué 9628eaffb9 Documentation improvement 2021-01-09 17:55:15 +01:00
Gwendal Roué 7be7e1cade Merge branch 'development' 2021-01-09 17:10:55 +01:00
Gwendal Roué db54c567de Performance tests: upgrade Realm, and set deployment target to macOS 10.15 2021-01-09 16:59:34 +01:00
Gwendal Roué db6ea3b85e Change demo app bundle ID
Xcode would no longer accept the previous one.
2021-01-09 16:33:12 +01:00
Gwendal Roué 33f3e868da v5.3.0 2021-01-09 15:47:00 +01:00
Gwendal Roué d4e380c35b Update thank you notice 2021-01-09 14:44:23 +01:00
Gwendal Roué 0dd78f1580 CHANGELOG 2021-01-09 14:43:40 +01:00
Gwendal Roué 267bfb29fe Merge pull request #892 from eburns-vmware/dev/data_passphrase
Provide SQLCipher passphrase as Data
2021-01-09 14:33:46 +01:00
Gwendal Roué 4e551c8c6e Fix Swiftlint errors 2021-01-09 13:09:44 +01:00
Gwendal Roué 554a84cf28 CHANGELOG 2021-01-09 12:57:26 +01:00
Gwendal Roué 2cfd51401a Merge pull request #903 from chrisballinger/patch-2
Fix SPM installation instructions
2021-01-06 09:06:06 +01:00
Chris Ballinger 948f9d3f22 Fix SPM installation instructions 2021-01-05 14:00:20 -08:00
Gwendal Roué 728efd3d67 Update the thank you notice 2021-01-01 13:59:42 +01:00
Gwendal Roué 1b0dd4ae25 CHANGELOG 2021-01-01 13:59:32 +01:00
Gwendal Roué e1b91e0642 Makefile documentation 2021-01-01 13:57:52 +01:00
Gwendal Roué 74b71b024b Merge pull request #901 from wuyuehyang/development
Fix creation of FTS5 tokenizer with arguments
2021-01-01 13:55:08 +01:00
wuyueyang c86d2d654f Fix failed to create unicode61 tokenizer as a wrapped tokenizer 2021-01-01 02:13:11 +08:00
wuyueyang ff6bdc38ef Add test case for custom tokenizer with a unicode61 tokenizer of multiple arguments wrapped 2021-01-01 00:44:00 +08:00
Gwendal Roué ef5b284f11 Remove TODO warning 2020-12-23 12:39:57 +01:00
Gwendal Roué 836efb120f Xcode 12.3 formatting 2020-12-23 12:13:05 +01:00
Gwendal Roué 3a76b84eae Documentation 2020-12-23 11:16:09 +01:00
Gwendal Roué ae17e9f893 Documentation 2020-12-23 11:11:27 +01:00
Gwendal Roué 6ea1e6aeaf Test that pragma tables are not tracked 2020-12-23 10:41:03 +01:00
Gwendal Roué ed32e44bc2 DRY 2020-12-23 10:31:16 +01:00
Gwendal Roué 60a9494434 Fix Swiftlint warnings 2020-12-23 10:10:10 +01:00
Gwendal Roué 51991213ef Stop observing pragma tables 2020-12-23 10:09:00 +01:00
Gwendal Roué dc16fae72e Documentation 2020-12-23 10:08:30 +01:00
Gwendal Roué b485d4d3dc forSingleResult is no longer mandatory 2020-12-23 10:08:16 +01:00
Gwendal Roué 7634d3f950 Documentation 2020-12-23 09:23:37 +01:00
Gwendal Roué 6abbf82a89 So long, visitor pattern! 2020-12-23 09:02:17 +01:00
Ed Burns 2de9b2d9ed Cleaned up documentation and addressed review comments. 2020-12-22 11:29:26 -06:00
Gwendal Roué cc0611847d Remove the CocoaPods lint job from Travis
It's too slow, and nearly always fails
2020-12-20 08:52:12 +01:00
Gwendal Roué c844438dd6 Xcode 12.2 touch 2020-12-20 08:51:42 +01:00
Gwendal Roué 0d6f68646c Turn warning into a TODO 2020-12-19 13:07:24 +01:00
Gwendal Roué af55215356 Travis: test with Xcode 12.2 2020-12-19 13:02:24 +01:00
Gwendal Roué f4f44c51d9 Makefile: support for Xcode 12.3 2020-12-19 11:18:46 +01:00
Ed Burns 77a1becba1 Fixed error in README. Sorry. 2020-12-17 17:17:26 -06:00
Ed Burns 5546961c8c Test fixes and cleanup. 2020-12-17 17:10:39 -06:00
Ed Burns d09571c0ad Added option to specify passphrase as a Data object, added section to README. 2020-12-17 11:19:05 -06:00
Gwendal Roué 9b15011f17 Move singularity test to SQLAssociationCardinality 2020-12-13 18:29:48 +01:00
Gwendal Roué e72007c1dd Make SQLiteral.subquery a promise
This allows us to postpone CTEs definition until a db connection is available
2020-12-13 18:29:43 +01:00
Gwendal Roué ab502baa20 CommonTableExpression.contains(_:) 2020-12-13 18:29:28 +01:00
Gwendal Roué eb0e0d4cdd Merge pull request #885 from groue/dev/cte+871
Robustness of eager loading of to-many associations based on compound foreign keys
2020-12-12 13:31:28 +01:00
Gwendal Roué c8818c1d44 CTEs are experimental 2020-12-12 12:47:44 +01:00
Gwendal Roué 1ff825c861 CHANGELOG 2020-12-12 12:41:10 +01:00
Gwendal Roué 13946f1d8d Remove unclear recommentation 2020-12-12 12:40:50 +01:00
Gwendal Roué 6a68e31903 Clarify handling of NULL in foreign keys 2020-12-12 12:40:50 +01:00
Gwendal Roué 618be9b5e4 Do not support null in foreign keys more than SQLite itself 2020-12-12 12:40:50 +01:00
Gwendal Roué 4a6a2c5495 Fix typo 2020-12-12 12:40:50 +01:00
Gwendal Roué 6082fc4e54 Tests for nullable compound foreign keys 2020-12-12 12:40:50 +01:00
Gwendal Roué 4e8d129162 Only use the CTE technique if foreign key columns are not null 2020-12-12 12:40:50 +01:00
Gwendal Roué 472b5bc604 Test two levels of include(all:) with compound foreign keys 2020-12-12 12:40:50 +01:00
Gwendal Roué cad788e59e Revert "Prefer CommonTableExpression.contains(_:)"
This reverts commit 87a0921586e319ccd4ee02e991ec555c6a915c13.
2020-12-12 12:40:49 +01:00
Gwendal Roué 2cb4cf51c3 TODO 2020-12-12 12:40:49 +01:00
Gwendal Roué 5eff2448bb Documentation 2020-12-12 12:40:49 +01:00
Gwendal Roué aabf6e6247 Prefer CommonTableExpression.contains(_:) 2020-12-12 12:40:49 +01:00
Gwendal Roué 23c93eebdf Remove fixed caveat from documentation 2020-12-12 12:40:49 +01:00
Gwendal Roué 732ec36b67 Documentation 2020-12-12 12:40:49 +01:00
Gwendal Roué f1196bf924 Limit availability of _SQLRowValue.isAvailable 2020-12-12 12:40:49 +01:00
Gwendal Roué fcd6a453f0 Replace CTE request with its table name 2020-12-12 12:40:49 +01:00
Gwendal Roué 85af2deced Document TODOs with row values 2020-12-12 12:40:49 +01:00
Gwendal Roué b70f85d94b Fix #871 2020-12-12 12:40:49 +01:00
Gwendal Roué b715206502 Row values 2020-12-12 12:40:49 +01:00
Gwendal Roué 18885d4ca1 CHANGELOG 2020-12-12 12:40:32 +01:00
Gwendal Roué 555ed025bc CHANGELOG 2020-12-12 12:30:45 +01:00
Gwendal Roué d0e4d536d9 Merge pull request #880 from groue/dev/cte
Common Table Expressions
2020-12-12 11:56:01 +01:00
Gwendal Roué 8c225105c2 Documentation 2020-12-12 11:21:49 +01:00
Gwendal Roué c36539adb3 CTEs can enter UPDATE and DELETE queries 2020-12-12 11:06:51 +01:00
Gwendal Roué b636c391df Fix typo 2020-12-11 08:33:13 +01:00
Gwendal Roué 659af2cd2a Documentation 2020-12-11 08:28:44 +01:00
Gwendal Roué f70e2b4e37 Mention that recursive CTEs require SQL 2020-12-11 08:24:05 +01:00
Gwendal Roué b16e12cb6e Documentation 2020-12-11 08:18:33 +01:00
Gwendal Roué df5c62d2d9 Documentation
Mention the CTE blog post found by @bellebethcooper
2020-12-11 08:17:12 +01:00
Gwendal Roué b89d11f8ec TODO 2020-12-09 09:23:42 +01:00
Gwendal Roué 992f2a2d83 Revert "CommonTableExpression.contains(_:)"
This reverts commit f94cecb329.

We can't expose a raw table name like that, because it may be used several times, and need an alias.
2020-12-08 18:36:51 +01:00
Gwendal Roué f94cecb329 CommonTableExpression.contains(_:) 2020-12-06 19:22:30 +01:00
Gwendal Roué 89c117425e Mention minimal SQLite version in README 2020-12-06 16:40:40 +01:00
Gwendal Roué 26c7441b49 Documentation 2020-12-06 13:16:27 +01:00
Gwendal Roué a6d80ce208 Update Makefile for Xcode 12.2 2020-12-06 13:11:36 +01:00
Gwendal Roué c287449258 Documentation 2020-12-05 20:50:58 +01:00
Gwendal Roué f9c98b4a1f Fix documentation typo 2020-12-05 20:47:59 +01:00
Gwendal Roué 86cfee4e23 Fix typo 2020-12-05 19:57:54 +01:00
Gwendal Roué a3351513ce Optimize inclusion of CTE association
In order to count the selected columns of a CTE, we do not need to have SQLite compile the whole CTE request when we have information about the selected columns.
2020-12-05 19:50:47 +01:00
Gwendal Roué 95be9b7bb6 Documentation 2020-12-05 19:17:47 +01:00
Gwendal Roué 1c2dd8617b Fix Documentation typo 2020-12-05 19:15:20 +01:00
Gwendal Roué 7f71174159 Fix typo 2020-12-05 18:26:46 +01:00
Gwendal Roué 098ddf27ec Documentation 2020-12-05 18:25:51 +01:00
Gwendal Roué bbce741688 Documentation 2020-12-05 18:22:26 +01:00
Gwendal Roué c56382f04a Documentation 2020-12-05 18:19:01 +01:00
Gwendal Roué 71841f0a07 Documentation 2020-12-05 18:16:20 +01:00
Gwendal Roué e43fae2a63 Fix sample code 2020-12-05 18:13:42 +01:00
Gwendal Roué 022a06b4bc Documentation 2020-12-05 18:10:13 +01:00
Gwendal Roué 7df77aa2d0 Documentation 2020-12-05 18:05:52 +01:00
Gwendal Roué f18bcb67e4 Documentation 2020-12-05 17:56:39 +01:00
Gwendal Roué cc68ef5872 Caveat documentation 2020-12-05 16:13:48 +01:00
Gwendal Roué 5b3eee53c2 SQL interpolation of CTEs 2020-12-05 16:13:24 +01:00
Gwendal Roué 63255cabf8 SQL interpolation of CTEs 2020-12-05 13:40:56 +01:00
Gwendal Roué 9d1bcec132 Cleanup filtering of trivially true joining conditions 2020-12-05 12:49:31 +01:00
Gwendal Roué b60f39e7cc Merge branch 'development' into dev/cte
# Conflicts:
#	GRDB/QueryInterface/Request/Association/Association.swift
#	GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
#	GRDB/QueryInterface/SQL/SQLQuery.swift
#	GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift
#	GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift
2020-12-05 12:31:52 +01:00
Gwendal Roué 5464d64180 Prevent an infinite loop of self-proxying TableAlias I saw once 2020-12-05 12:24:05 +01:00
Gwendal Roué 1e2d07a16f Simplify SQLSource
SQLSource used to be more or less able to deal with subqueries, as in SELECT ... FROM (SELECT ...).

But we had only one use case for it, the "trivial count query": SELECT COUNT(*) FROM (SELECT ...). And many opportunities for fatal errors, because such subqueries were not generally supported.

So we simplify SQLSource, and implement the trivial count query in another way.
2020-12-05 12:21:14 +01:00
Gwendal Roué 66b23d423f Cleanup JoinAssociation 2020-12-05 10:54:31 +01:00
Gwendal Roué 3094c274df Enhance error message 2020-12-05 10:34:32 +01:00
Gwendal Roué 378279ee1a Move the isRecursive flag where it belongs 2020-12-05 10:32:46 +01:00
Gwendal Roué e509d7af65 Merge branch 'development' into dev/cte 2020-12-04 07:10:12 +01:00
Gwendal Roué 9da4bc09c3 Fix typos 2020-12-04 07:09:54 +01:00
Gwendal Roué 462461c1c9 Merge pull request #883 from professordeng/patch-1
Update README.md
2020-12-04 05:34:41 +01:00
peofessordeng 7ded56dfc4 Update README.md 2020-12-04 11:07:37 +08:00
Gwendal Roué 836a0a5e37 Documentation 2020-12-03 19:15:57 +01:00
Gwendal Roué 91dd13e2be Merge cte support into AllColumns 2020-12-03 18:51:26 +01:00
Gwendal Roué a1f0f2c9b7 TODO 2020-12-03 09:24:56 +01:00
Gwendal Roué 6f409f2140 Fix typo 2020-12-03 09:22:15 +01:00
Gwendal Roué 64776682fe Drop USING clause until actually needed 2020-12-03 09:21:19 +01:00
Gwendal Roué a21e6575d8 _AllCTEColumns delegates to AllColumns and _SQLQualifiedAllColumns 2020-12-03 08:37:55 +01:00
Gwendal Roué 4ee6f3293a CTE columns are provided as strings 2020-12-03 08:34:43 +01:00
Gwendal Roué 17b884b3dc Recursive CTEs 2020-12-03 08:28:14 +01:00
Gwendal Roué 0f6d36bfc2 Cleanup 2020-12-03 07:07:39 +01:00
Gwendal Roué 0dc9215df6 Documentation 2020-12-02 22:15:50 +01:00
Gwendal Roué 333ffc1ebe Documentation 2020-12-02 21:55:51 +01:00
Gwendal Roué 181c930e39 Cleanup 2020-12-02 19:29:35 +01:00
Gwendal Roué 65337e74d9 Solve #856 with a CTE :-) 2020-12-02 19:14:53 +01:00
Gwendal Roué 69c116507b Fetch straight from a CTE 2020-12-02 18:40:58 +01:00
Gwendal Roué 2b82de42d8 Merge branch 'development' into dev/cte 2020-12-02 18:30:31 +01:00
Gwendal Roué 10dfa3fba9 Merge pull request #881 from felixscheinost/patch-1
Fix try-catch blocks in documentation
2020-12-02 10:41:06 +01:00
Felix Scheinost 339062f01f Fix try-catch blocks in documentation 2020-12-02 10:08:55 +01:00
Gwendal Roué eb2346dfce Couting requests with CTE uses trivial SQL 2020-12-02 08:26:35 +01:00
Gwendal Roué 1d0adaacf6 including(all:) accepts associations based on the .using condition 2020-12-02 08:20:50 +01:00
Gwendal Roué 5e8f95ca09 Improve CTE columns counting 2020-12-02 08:09:07 +01:00
Gwendal Roué b085a29c8c Cleanup 2020-12-02 08:02:42 +01:00
Gwendal Roué 992e8f3423 Remove header 2020-12-02 06:25:18 +01:00
Gwendal Roué 49e6923156 Prepare recursive CTEs 2020-12-02 06:22:55 +01:00
Gwendal Roué a7a4858364 Refactor CommonTableExpression initializers 2020-12-02 06:12:55 +01:00
Gwendal Roué 3a38cbe87f Create CTE without request 2020-12-02 06:00:04 +01:00
Gwendal Roué 2c42d0129c CTE columns: WITH cte(a, b) AS ... 2020-12-02 05:36:56 +01:00
Gwendal Roué da5ef961d6 Expose CTE creation method at a documented level 2020-12-02 05:14:26 +01:00
Gwendal Roué d35373dcdf Fix typo 2020-12-01 20:48:40 +01:00
Gwendal Roué adc6ba1226 Delete dead code 2020-12-01 20:45:11 +01:00
Gwendal Roué b1d162c14e Filter, order, alias CTE 2020-12-01 20:38:37 +01:00
Gwendal Roué 2b6c3fb868 Remove misleading comment 2020-12-01 20:38:19 +01:00
Gwendal Roué a70b42cbf5 Extract SQLAssociationCondition.using 2020-12-01 20:30:36 +01:00
Gwendal Roué 06000abbfd Type-safe CTE associations, part 2 2020-12-01 20:04:35 +01:00
Gwendal Roué 67bc47c3b5 Type-safe CTE associations 2020-12-01 20:00:04 +01:00
Gwendal Roué 5c34ab19e2 API rationalization 2020-12-01 19:50:16 +01:00
Gwendal Roué 6d14f792e6 Remove dead code 2020-12-01 19:36:50 +01:00
Gwendal Roué 1238843a44 Cleanup 2020-12-01 19:33:43 +01:00
Gwendal Roué 8000332ec4 Gather CTE methods 2020-12-01 19:29:39 +01:00
Gwendal Roué 9896607dff Test for filtered CTE 2020-12-01 19:17:47 +01:00
Gwendal Roué 1be0a6cd5c Add JoinAssociation to GRDBCustom 2020-12-01 19:17:34 +01:00
Gwendal Roué 0191676063 Using clause for CTE associations 2020-12-01 09:17:05 +01:00
Gwendal Roué c16da693df More cte association api experiments 2020-12-01 08:38:39 +01:00
Gwendal Roué f31dd0033c Remove non-composable cte association methods 2020-12-01 08:21:04 +01:00
Gwendal Roué b7b89c5fa9 CTE associations 2020-11-30 21:51:17 +01:00
Gwendal Roué c776ee8d47 Association: remove TableRecord requirement 2020-11-30 21:50:18 +01:00
Gwendal Roué c36fc2813b Include a raw SQL CTE 2020-11-30 19:29:54 +01:00
Gwendal Roué ec2640a459 CommonTableExpression is a table, after all 2020-11-30 19:21:46 +01:00
Gwendal Roué 755782759a Cleanup 2020-11-30 18:14:03 +01:00
Gwendal Roué 9275d4ddf8 Need to deal with CTE subqueries 2020-11-30 18:10:21 +01:00
Gwendal Roué 96951b3d4e Remove dead code 2020-11-30 18:10:06 +01:00
Gwendal Roué 36a8cd1352 CTE merging WIP: we need to postpone TableAlias creation 2020-11-29 19:33:46 +01:00
Gwendal Roué 2bb9f5ce0d First joins with CommonTableExpression 2020-11-29 19:05:12 +01:00
Gwendal Roué e1d3c1d7dc Give CommonTableExpression a key, for joins 2020-11-29 18:23:41 +01:00
Gwendal Roué 00a7eb53e8 First successful SQL generation with CTE 2020-11-29 16:51:52 +01:00
Gwendal Roué e7dcf25063 CTE aliases 2020-11-29 15:49:55 +01:00
Gwendal Roué d2b7b4240a CTE basis 2020-11-29 15:06:45 +01:00
Gwendal Roué b6ef89c116 Prefetch cleanup 2020-11-29 11:58:15 +01:00
Gwendal Roué 2a917823ed Merge branch 'development' 2020-11-29 06:59:23 +01:00
Gwendal Roué 2135f8e768 v5.2.0 2020-11-28 13:46:26 +01:00
Gwendal Roué 2c45ecf56c CHANGELOG 2020-11-28 13:41:50 +01:00
Gwendal Roué 52f831936e Document the including(all:) caveat with compound foreign keys 2020-11-28 13:26:21 +01:00
Gwendal Roué 28f6b64f67 Document the including(all:) caveat with compound foreign keys 2020-11-28 13:24:25 +01:00
Gwendal Roué cc0365d794 Document the including(all:) caveat with compound foreign keys 2020-11-28 13:21:12 +01:00
Gwendal Roué 59ad47d640 Merge pull request #872 from groue/dev/timezone
Parse time zones
2020-11-14 18:33:42 +01:00
Gwendal Roué 27662f99b0 [skip travis] profile date parsing 2020-11-14 13:18:21 +01:00
Gwendal Roué 4c5c2dfb6c [skip travis] CHANGELOG 2020-11-14 13:16:38 +01:00
Gwendal Roué 517a7b2984 Update documentation 2020-11-14 11:16:47 +01:00
Gwendal Roué 10bb596b7c Update documentation 2020-11-14 11:15:09 +01:00
Gwendal Roué 6913f1e39b Update documentation 2020-11-14 10:51:30 +01:00
Gwendal Roué fe8e32586b Parse time zones 2020-11-14 10:35:04 +01:00
Gwendal Roué e0c91ed2ee Merge pull request #868 from groue/dev/varying-region
ValueObservation optimization is opt-in
2020-11-08 11:15:41 +01:00
Gwendal Roué 428433672c Documentation 2020-11-07 13:55:57 +01:00
Gwendal Roué f71a2f7cd8 CHANGELOG 2020-11-07 13:39:49 +01:00
Gwendal Roué 102b037c7d Update documentation 2020-11-07 13:02:47 +01:00
Gwendal Roué 46c3839ea0 ValueObservation tracks a varying database region by defaut 2020-11-07 13:01:51 +01:00
Gwendal Roué 2c51c04708 Merge branch 'development' 2020-11-01 13:27:29 +01:00
Gwendal Roué d0a7a49c19 v5.1.0 2020-11-01 13:27:04 +01:00
Gwendal Roué 0024a4e654 Merge pull request #864 from groue/dev/filter-ergonomics
Prevent filter misuse with a deprecation warning
2020-11-01 13:18:05 +01:00
Gwendal Roué d66a3f4ab3 Fix Swiftlint warning 2020-11-01 10:39:48 +01:00
Gwendal Roué 645aa1d67b CHANGELOG 2020-11-01 10:34:21 +01:00
Gwendal Roué 06db4af649 Enhance warning 2020-11-01 10:33:05 +01:00
Gwendal Roué baf1ef32d1 Document why filter(_:) prefers SQLSpecificExpressible over SQLExpressible 2020-11-01 10:29:07 +01:00
Gwendal Roué d5638f8e53 Update tests and replace filter(value) with filter(databaseValue) 2020-11-01 09:44:13 +01:00
Gwendal Roué c65b5b28b9 Update tests and replace filter(value) with filter { _ in value }
We just want to make sure that no nasty overload alters the meaning of expressions such as `2 + 2`
2020-11-01 09:43:37 +01:00
Gwendal Roué 1301e16f6e Update tests and replace filter(false) with none() 2020-11-01 09:42:00 +01:00
Gwendal Roué caa382f41b Deprecate filter(value)
Some people use Player.filter(id) instead of Player.filter(key: id). This is what this commit prevents.
2020-11-01 09:41:16 +01:00
Gwendal Roué 24fd69a9be [skip travis] CHANGELOG 2020-10-31 19:56:25 +01:00
Gwendal Roué 2389ec691b Merge pull request #855 from mallman/generated_columns
SQLite 3.33.0 + Support for generated columns
2020-10-31 18:56:34 +01:00
Gwendal Roué b8dd2ce2f4 Generate columns from query interface expressions
This allows to avoid SQL injection
2020-10-31 14:16:04 +01:00
Gwendal Roué 5114cc4d6d Fix documentation 2020-10-31 13:56:22 +01:00
Gwendal Roué 57036c4470 Use SQLite ergonomics, and create virtual generated columns by default 2020-10-31 13:55:07 +01:00
Gwendal Roué 81166432a8 Documentation for generatedAs(sql:) 2020-10-31 13:45:58 +01:00
Gwendal Roué 5dc8502c8b Test that update(_:) and insert(_:) throw when persisting generated columns 2020-10-31 13:23:42 +01:00
Gwendal Roué 67e10926db Restore logic 2020-10-31 13:09:49 +01:00
Gwendal Roué e971e210a3 Update documentation about PRAGMA table_info and table_xinfo 2020-10-31 13:09:05 +01:00
Gwendal Roué f7e6169c23 Test that TableRecord.numberOfSelectedColumns(_:) includes generated columns 2020-10-31 13:07:58 +01:00
Gwendal Roué 6fc4e31dfb Test that Database.columns(in:) returns generated columns 2020-10-31 12:55:56 +01:00
Gwendal Roué dfc22bdf00 Skip tests for generated columns unless custom SQLite build 2020-10-31 12:14:52 +01:00
Gwendal Roué 54b5f47ffa Upgrade custom SQLite builds to v3.33.0 2020-10-31 12:09:49 +01:00
Gwendal Roué 62a4251f90 Merge pull request #862 from groue/dev/fix-861
Improve documentation of observations of varying regions
2020-10-31 11:34:07 +01:00
Gwendal Roué a41c12252a Documentation 2020-10-30 09:12:47 +01:00
Gwendal Roué e7cf816062 Documentation 2020-10-30 06:25:20 +01:00
Gwendal Roué ff28cadd57 More tests for optimized regions 2020-10-30 06:20:50 +01:00
Gwendal Roué 9039b18b84 Documentation 2020-10-30 06:05:52 +01:00
Gwendal Roué 480381deb5 Documentation 2020-10-30 05:59:20 +01:00
Gwendal Roué 84dbace4af Documentation 2020-10-30 05:56:58 +01:00
Gwendal Roué 44f80f4c7c Wording 2020-10-30 05:49:42 +01:00
Gwendal Roué 1cb9e52123 Legibility 2020-10-29 19:12:29 +01:00
Gwendal Roué 4d7ddb9c26 Wording 2020-10-29 19:07:31 +01:00
Gwendal Roué 1b29d7eca3 CHANGELOG 2020-10-29 19:02:00 +01:00
Gwendal Roué 5c779b11db Improve documentation of observations of a varying region 2020-10-29 18:47:34 +01:00
Gwendal Roué dc344c07de Wording 2020-10-29 18:16:37 +01:00
Gwendal Roué b7b3c3ab32 Wording 2020-10-29 18:15:23 +01:00
Gwendal Roué 6fa20284ec Wording 2020-10-29 18:14:14 +01:00
Gwendal Roué 978b570826 FAQ: Why is ValueObservation not publishing value changes? 2020-10-29 18:13:06 +01:00
Gwendal Roué 688e393ed1 Don't track prefetched associations when the parent is provably empty 2020-10-29 17:05:26 +01:00
Gwendal Roué 8ede868068 More tests for empty regions of empty requests 2020-10-29 16:05:35 +01:00
Gwendal Roué 667d42eeb4 [skip travis] Fix release date 2020-10-28 07:43:01 +01:00
Michael Allman 1f87d5a375 Add rudimentary tests for the generated column table definition API 2020-10-25 12:19:01 -07:00
Michael Allman 4f0a6cf9e1 Extract common filter predicate in AssociationPrefetchingSQLTests into a
reusable method
2020-10-25 11:55:49 -07:00
Michael Allman 3318858b80 Wrap the generatedAs column definition API with the GRDBCUSTOMSQLITE
Swift compiler flag
2020-10-25 11:44:09 -07:00
Michael Allman 9c6f19f55f Condition table column info query on SQLite version 2020-10-25 11:42:43 -07:00
Gwendal Roué 48ee93c244 CHANGELOG 2020-10-25 10:38:22 +01:00
Gwendal Roué ee4197bcc0 Merge branch 'development' 2020-10-25 10:33:57 +01:00
Gwendal Roué 079c476148 v5.0.3 2020-10-25 10:33:32 +01:00
Gwendal Roué aa909b7635 Merge branch 'master' into development 2020-10-25 10:33:21 +01:00
Gwendal Roué 9167ebda98 Merge pull request #859 from groue/dev/deinit-change
Database.close() is idempotent
2020-10-25 10:15:49 +01:00
Gwendal Roué 38682c69da CHANGELOG 2020-10-25 10:15:27 +01:00
Gwendal Roué 2a7f41c494 Database.close() is idempotent
This change addresses https://bugs.swift.org/browse/SR-13746
2020-10-25 10:12:42 +01:00
Michael Allman 071bbc7905 Initial commit for generated column support 2020-10-19 21:25:36 -07:00
Gwendal Roué ca18f509e7 Merge pull request #850 from DiligentRobot/development
Add buildActiveScheme to playground settings so they'll build under Xcode 12
2020-10-15 17:57:34 +02:00
Matt Tancock 5e2bb1d57a Add buildActiveScheme to playground settings so they'll build under Xcode 12 2020-10-15 15:10:28 +01:00
Gwendal Roué dd2950e4ca [skip travis] Merge pull request #849 from MarshalGeazipp/MarshalGeazipp-fix-grammar
Fix grammar mistake AssociationsBasics.md
2020-10-08 17:42:40 +02:00
Sebastian Nicklas 34f3097616 Update AssociationsBasics.md 2020-10-08 17:19:17 +02:00
Gwendal Roué 948e91126a Merge branch 'development' 2020-10-06 19:21:43 +02:00
Gwendal Roué 85b781bf0e v5.0.2 2020-10-06 14:10:06 +02:00
Gwendal Roué bd853a8bc0 CHANGELOG 2020-10-06 14:08:21 +02:00
Gwendal Roué bfc76b96f3 Fix #844 2020-10-06 14:03:41 +02:00
Gwendal Roué 99ea59ee06 Demo app builds in Debug configuration 2020-10-06 14:03:41 +02:00
Gwendal Roué f8a0e8e4b5 Merge pull request #847 from groue/dev/remove-snapshots
Remove dependency on SQLITE_ENABLE_SNAPSHOT
2020-10-06 13:32:26 +02:00
Gwendal Roué 14e32a2bd1 [skip travis] CHANGELOG 2020-10-06 13:31:52 +02:00
Gwendal Roué f84e25f929 Remove dependency on SQLITE_ENABLE_SNAPSHOT
Address #845 and #846
2020-10-06 08:30:41 +02:00
Gwendal Roué 6884bf10b0 Merge branch 'development' 2020-09-27 15:52:03 +02:00
Gwendal Roué 8803eafe31 v5.0.1 2020-09-27 15:20:42 +02:00
Gwendal Roué 9909ca4c96 [skip travis] CHANGELOG 2020-09-27 15:17:12 +02:00
Gwendal Roué 5d36d5735d [skip travis] Update GRDBCombineDemo for iOS 14
Address both #842 and #843
2020-09-27 14:46:43 +02:00
Gwendal Roué ef368a2bc2 Merge pull request #841 from groue/dev/840
Fix GRDB 5 regression with indexes on expressions
2020-09-27 12:06:02 +02:00
Gwendal Roué 8433b09650 [skip travis] CHANGELOG 2020-09-27 12:04:40 +02:00
Gwendal Roué d2eb92d1a2 Travis: test Xcode 12 2020-09-26 15:27:49 +02:00
Gwendal Roué ba98aab046 Fix failing test for #840 2020-09-26 14:46:39 +02:00
Gwendal Roué 00d15339b6 Failing test for #840 2020-09-26 14:45:49 +02:00
Gwendal Roué 1ea4a44bb8 Merge branch 'development' 2020-09-20 16:47:45 +02:00
Gwendal Roué 5119c065bd v5.0.0 2020-09-20 15:54:56 +02:00
Gwendal Roué 8be6aa7358 Fix GRDBCombineDemo on the device 2020-09-20 15:35:25 +02:00
Gwendal Roué 438f99deff GRDBCombineDemo Xcode 12 changes 2020-09-20 15:27:52 +02:00
Gwendal Roué c556c056d8 GRDBCombineDemo: animate list changes 2020-09-20 15:27:36 +02:00
Gwendal Roué 613baf30f9 GRDBCombineDemo: fix compiler error 2020-09-20 15:27:10 +02:00
Gwendal Roué 0ac7e2d299 Xcode 12 2020-09-20 15:05:20 +02:00
Gwendal Roué 929465eb52 UIKit demo: use UITableViewDiffableDataSource 2020-09-20 15:05:07 +02:00
Gwendal Roué 13de0a5cce Demo apps: move from unfamiliar World-based dependency injection to plain shared global 2020-09-20 14:37:01 +02:00
Gwendal Roué c12f42b385 Fix warnings 2020-09-20 14:11:29 +02:00
Gwendal Roué 2ccd01299c In performance report, the hardware model and Xcode version are dynamic 2020-09-20 14:05:08 +02:00
Gwendal Roué fb2efb8df9 Upgrade Realm 2020-09-20 14:04:24 +02:00
Gwendal Roué 795daf284f Remove performance database resources 2020-09-20 13:31:11 +02:00
Gwendal Roué 354b815835 Remove obsolete todos 2020-09-20 11:38:37 +02:00
Gwendal Roué 7d8e20685d CHANGELOG 2020-09-20 11:19:11 +02:00
Gwendal Roué 5050c36c4e Fix wording of root key decoding error 2020-09-19 15:52:50 +02:00
Gwendal Roué 6348c6f151 Merge branch 'dev/decodingErrorAmbiguity' into development 2020-09-19 15:50:35 +02:00
Gwendal Roué 8cb468cf05 Fix failing test for #836 2020-09-19 15:50:21 +02:00
Gwendal Roué 55c9e48a21 Failing test for #836 2020-09-19 15:50:07 +02:00
Gwendal Roué db3ae357ea Merge branch 'dev/indexIfNotExists' into development 2020-09-19 13:12:30 +02:00
Gwendal Roué f62b952d70 Fix failing test for #838 2020-09-19 13:11:44 +02:00
Gwendal Roué bf1c025612 Failing test for #838 2020-09-19 13:11:30 +02:00
Gwendal Roué ba253dcbf2 [skip travis] fix indentation 2020-09-11 14:36:41 +02:00
Gwendal Roué 1829706faa [skip travis] don’t talk about "misuse" when it’s all about an SQLite misfeature 2020-09-11 14:34:55 +02:00
Gwendal Roué f9f16df065 [skip travis] don’t talk about "misuse" when it’s all about an SQLite misfeature 2020-09-11 14:33:40 +02:00
Gwendal Roué 66173b345f [skip travis] wording 2020-09-11 14:30:25 +02:00
Gwendal Roué ac54c808c5 [skip travis] fix documentation layout 2020-09-11 13:37:52 +02:00
Gwendal Roué 7761b137ba Fix wording 2020-09-11 13:37:04 +02:00
Gwendal Roué 3d144b9e5d [skip travis] FAQ about SQLite error 1 "no such column" 2020-09-11 13:27:30 +02:00
Gwendal Roué b2f5d425b6 Merge branch 'development' 2020-09-07 13:42:58 +02:00
Gwendal Roué 64028e03dc v5.0.0-beta.11 2020-09-07 13:36:44 +02:00
Gwendal Roué e52047d82e Fix #828 2020-09-07 13:29:13 +02:00
Gwendal Roué 5adbd9b3e3 Merge pull request #831 from groue/dev/more-preparation
Improve Configuration.prepareDatabase
2020-09-07 13:26:50 +02:00
Gwendal Roué fd21f97007 Update migration guide 2020-09-06 18:40:15 +02:00
Gwendal Roué d74c5264d3 Update documentation for functions, collations, and tokenizers 2020-09-06 18:28:22 +02:00
Gwendal Roué 654611c365 Fix OTHER_SWIFT_FLAGS 2020-09-06 14:38:30 +02:00
Gwendal Roué 18e09ec061 Configuration.prepareDatabase updates 2020-09-06 14:06:25 +02:00
Gwendal Roué 8e2fb1fb22 Update tests 2020-09-06 13:57:16 +02:00
Gwendal Roué 7a2c1413fe Fix DatabaseSnapshot 2020-09-06 13:40:03 +02:00
Gwendal Roué 3c38aa1996 Functions, Collations, and tokenizers are no longer available on DatabaseQueue, Pool, and Snapshot 2020-09-06 13:18:58 +02:00
Gwendal Roué 886f75bbea Configuration.prepareDatabase in now a method 2020-09-06 13:15:51 +02:00
Gwendal Roué 5820b30cc6 DatabaseError.description: output SQLite message before statement #820 2020-08-25 19:48:00 +02:00
Gwendal Roué ce4bfb9df6 [skip travis] Explain that date and uuid strategies do not apply to requests (#821) 2020-08-23 11:07:02 +02:00
Gwendal Roué be787d3e8a [skip travis] Tell that demo apps are not templates. Addresses #823 2020-08-23 10:36:44 +02:00
Gwendal Roué ededd8668a Merge branch 'development' 2020-07-30 08:29:47 +02:00
Gwendal Roué 7b788e3988 v5.0.0-beta.10 2020-07-30 08:29:27 +02:00
Gwendal Roué 0eb854cebd Merge pull request #817 from groue/dev/boolean-checks
Allow query planner to optimize some boolean tests
2020-07-30 08:24:36 +02:00
Gwendal Roué 9529939262 Documentation 2020-07-27 06:40:18 +02:00
Gwendal Roué 6ee7db48c8 Take care of indexes on expressions as well
sqlite> create table t(a,b);
sqlite> create index i on t(a like '%a', a, b);
sqlite> explain query plan select * from t where a like '%a';
QUERY PLAN
`--SCAN TABLE t
sqlite> explain query plan select * from t where a not like '%a';
QUERY PLAN
`--SCAN TABLE t
sqlite> explain query plan select * from t where (a like '%a') = 1;
QUERY PLAN
`--SEARCH TABLE t USING COVERING INDEX i (<expr>=?)
sqlite> explain query plan select * from t where (a like '%a') = 0;
QUERY PLAN
`--SEARCH TABLE t USING COVERING INDEX i (<expr>=?)
2020-07-26 16:04:02 +02:00
Gwendal Roué 8cc82ae2b7 Update migration guide 2020-07-26 15:16:19 +02:00
Gwendal Roué 474c2c3a76 Thank you notice 2020-07-26 15:09:43 +02:00
Gwendal Roué 843624044c CHANGELOG 2020-07-26 15:08:21 +02:00
Gwendal Roué 454b9d5546 More tests for boolean tests 2020-07-26 14:19:46 +02:00
Gwendal Roué c532b8709c Refactor boolean tests (fix #816) 2020-07-26 14:19:31 +02:00
Gwendal Roué bf1d6038e1 Failing tests for #816 2020-07-26 13:33:35 +02:00
Gwendal Roué 86b9616dd7 DatabasePool readers don't invalidate their database schema cache until schema is actually changed. 2020-07-25 18:20:43 +02:00
Gwendal Roué bc993f63f5 Merge branch 'development' 2020-07-24 06:07:54 +02:00
Gwendal Roué 531d732437 Travis: bump to Xcode 11.6 2020-07-23 20:38:19 +02:00
Gwendal Roué 24f9b2c01b Makefile: add support for Xcode 11.6 2020-07-23 20:27:05 +02:00
Gwendal Roué c4991176f4 v5.0.0-beta.9 2020-07-23 19:04:58 +02:00
Gwendal Roué 0ea70d6bfc CHANGELOG 2020-07-23 19:00:58 +02:00
Gwendal Roué 845ae7e0e4 Merge pull request #814 from groue/dev/views
Fix regression with views
2020-07-23 18:59:16 +02:00
Gwendal Roué dc8d74b609 Merge pull request #813 from groue/dev/SQLite3.31.1
Expose SQLite 3.31.1 APIs to iOS, macOS, tvOS, watchOS
2020-07-23 18:58:56 +02:00
Gwendal Roué 2f54eda08a Fix #812 2020-07-23 08:46:05 +02:00
Gwendal Roué a526351b4c Failing test for #812 2020-07-23 08:31:53 +02:00
Gwendal Roué d08d3b311f Fix for GRDB+SQLCipher 2020-07-23 07:55:34 +02:00
Gwendal Roué 25baecdc39 CHANGELOG 2020-07-22 20:36:32 +02:00
Gwendal Roué e2816905bb OSX 11 is OSX 10.16 2020-07-22 20:22:03 +02:00
Gwendal Roué ee2d8eae50 Expose ascNullLast and descNullFirst
This is because iOS 14 runs SQLite 3.31.1
2020-07-22 20:17:52 +02:00
Gwendal Roué 1823e11090 Expose remove_diacritics=2 option of unicode61 FTS5 tokenizer
This is because iOS 14 runs SQLite 3.31.1
2020-07-22 20:07:27 +02:00
Gwendal Roué 294ed772c1 Expose remove_diacritics=2 option of unicode61 FTS tokenizer
This is because iOS 14 runs SQLite 3.31.1
2020-07-22 20:07:27 +02:00
Gwendal Roué 62f33e1d55 Dictionary(grouping:by:) with Cursor 2020-07-22 08:39:45 +02:00
Gwendal Roué e3f1992536 [skip travis] Mention update with primary key 2020-07-19 13:42:12 +02:00
Gwendal Roué baf3a8ec26 [skip travis] Simplify introduction to record protocols 2020-07-19 13:26:56 +02:00
Gwendal Roué a9ca4450f8 [skip travis] Mention unadapted 2020-07-19 13:09:27 +02:00
Gwendal Roué 54ceba6dfa [skip travis] Update observation usage 2020-07-19 13:00:29 +02:00
Gwendal Roué fc64d868ef [skip travis] Update observation usage 2020-07-19 12:53:48 +02:00
Gwendal Roué 45fdb50dc2 [skip travis] Mention RenameColumnAdapter in the migration guide 2020-07-19 12:27:49 +02:00
Gwendal Roué e704ffeba1 Merge branch 'development' 2020-07-19 12:09:50 +02:00
Gwendal Roué 2fb2cee5db v5.0.0-beta.8 2020-07-19 10:04:05 +02:00
Gwendal Roué 3fa8c15c33 Merge pull request #811 from groue/dev/RenameColumAdapter
Introduce RenameColumAdapter
2020-07-19 09:59:05 +02:00
Gwendal Roué 70b70a069a Fix typo 2020-07-19 09:54:39 +02:00
Gwendal Roué f16dcc56ae Add SQLLiteral.isEmpty 2020-07-19 09:41:45 +02:00
Gwendal Roué 4bf21cc5ce Introduce RenameColumAdapter 2020-07-19 09:33:13 +02:00
Gwendal Roué b9bb514709 Merge branch 'development' 2020-07-14 20:44:11 +02:00
Gwendal Roué 67db8a0f3e v5.0.0-beta.7 2020-07-14 20:43:38 +02:00
Gwendal Roué 606cc2cb37 Give more time to SQLCipher4 Travis tests 2020-07-14 18:25:31 +02:00
Gwendal Roué bed1f28b30 Give more time to SQLCipher4 Travis tests 2020-07-14 16:41:05 +02:00
Gwendal Roué 5c6130fbed More Xcode 12 adaptation 2020-07-14 14:02:24 +02:00
Gwendal Roué c1079ac1a9 Remove xcconfig-based settings from target 2020-07-14 13:55:37 +02:00
Gwendal Roué ef7d2e06f6 Restore FTS5 tests from GRDB.xcodeproj 2020-07-14 09:35:03 +02:00
Gwendal Roué 08d235bdc3 Documentation 2020-07-14 09:34:19 +02:00
Gwendal Roué ac8af6bbf0 CHANGELOG 2020-07-14 09:34:05 +02:00
Gwendal Roué 1729c0b967 Merge pull request #802 from GetToSet/development
Add tokenchars support for ascii tokenizer in FTS5.
2020-07-14 09:24:09 +02:00
Gwendal Roué b02b995b76 Give more time to SQLCipher4 Travis tests 2020-07-13 20:15:27 +02:00
Gwendal Roué 7f229468d2 Documentation 2020-07-12 15:12:04 +02:00
Gwendal Roué ebae30342b Defining custom RowAdapter types is no longer supported. 2020-07-12 14:22:53 +02:00
Gwendal Roué 07092169bf Documentation 2020-07-12 14:17:58 +02:00
Bunny Wong 838a03c0ef Added tests for ascii tokenizer. 2020-07-12 19:43:23 +08:00
Bunny Wong 4565c1fff9 Add tokenchars support for ascii tokenizer in FTS5. 2020-07-12 19:43:23 +08:00
Gwendal Roué 519410fc3a Fix availability 2020-07-12 12:03:46 +02:00
Gwendal Roué 9743c89c56 Documentation 2020-07-12 11:59:01 +02:00
Gwendal Roué 94d1134ec2 fetchSet 2020-07-12 10:49:47 +02:00
Gwendal Roué df92e350c0 Documentation 2020-07-11 20:29:47 +02:00
Gwendal Roué 065913f6ab Remove useless makeSelectStatement(literal:) 2020-07-11 19:52:33 +02:00
Gwendal Roué a75a7b82ce Work around an SQLite bug which prevents rollbacking a transaction with sqlite3_commit_hook 2020-07-11 19:47:12 +02:00
Gwendal Roué 90e7449d6a Documentation 2020-07-11 19:21:33 +02:00
Gwendal Roué f9bd457cbd Cleanup 2020-07-11 18:33:43 +02:00
Gwendal Roué 2f6f8f88f8 Cleanup 2020-07-11 17:43:51 +02:00
Gwendal Roué 604ac92a6d Move PreparedRequest where it belongs 2020-07-11 17:40:22 +02:00
Gwendal Roué 4718de0f6c CHANGELOG 2020-07-11 17:36:41 +02:00
Gwendal Roué 002287ca28 Close FetchRequest, make it visitable 2020-07-11 17:30:11 +02:00
Gwendal Roué 31e8d926a8 Remove _SQLExpressionVisitor default handling of _SQLExpressionCollate 2020-07-11 13:41:44 +02:00
Gwendal Roué 99ed742555 "row id" -> "rowid" 2020-07-11 13:21:14 +02:00
Gwendal Roué 67d3fa1e68 Document removal of query interface internals from public interface 2020-07-11 11:44:50 +02:00
Gwendal Roué 8a8518a961 Update playgrounds 2020-07-11 11:17:23 +02:00
Gwendal Roué ae41859bbb Cleanup 2020-07-11 10:57:24 +02:00
Gwendal Roué 813950f832 Avoid SQLITE_BUSY when opening a DatabaseSnapshot. 2020-07-09 17:45:57 +02:00
Gwendal Roué cce8c832c7 [nil].contains(expr) now generates expr = NULL 2020-07-06 20:40:37 +02:00
Gwendal Roué fc3e64989d Cleanup _SQLExpressionContains 2020-07-06 20:18:21 +02:00
Gwendal Roué d05f11293e NULL is falsey 2020-07-06 15:14:43 +02:00
Gwendal Roué b36a92c853 Towards increased SQLCollection.contains robustness 2020-07-06 15:13:55 +02:00
Gwendal Roué 995d90ae86 Cleanup SQLExpression.identifyingRowIDs(_:for:) 2020-07-06 12:01:18 +02:00
Gwendal Roué 229fb36074 Fix test 2020-07-05 16:23:19 +02:00
Gwendal Roué 68785d1c2d Hide _SQLAssociation 2020-07-05 16:21:28 +02:00
Gwendal Roué ed7faa3714 Documentation 2020-07-05 16:14:44 +02:00
Gwendal Roué 90f2642ec6 Make good use of the visitor pattern 2020-07-05 15:07:52 +02:00
Gwendal Roué 4c3029e5c1 Not a bug after all
But add comments, and an extra test for compound primary keys
2020-07-02 19:09:46 +02:00
Gwendal Roué 46e9e28a3f Spot a bug in JoinMapping.joinExpression(leftRows:) 2020-07-02 08:49:55 +02:00
Gwendal Roué effdc8df6c Remove a debugging print() 2020-07-02 08:31:25 +02:00
Gwendal Roué 268a45a635 Prepare for different kinds of SQLAssociationCondition 2020-07-02 08:29:49 +02:00
Gwendal Roué 97cb1d595e Improve groupByPrimaryKey()
Using the rowID when possible yields better performance
2020-07-01 21:25:33 +02:00
Gwendal Roué a328faa834 Allow grouping by FastPrimaryKeyExpression 2020-07-01 21:24:27 +02:00
Gwendal Roué 2201026ce8 Introduce FastPrimaryKeyExpression, drop SQLPrimaryKeyExpression
Also, don't let the user access this expression, so that he does not attempt at decoding it. Its only purpose is to generate efficient SQL.
2020-07-01 20:40:11 +02:00
Gwendal Roué bd4a76d5de TODO 2020-06-30 19:31:03 +02:00
Gwendal Roué 63d5fb1d2b Merge pull request #803 from groue/dev/RemoveFetchedRecordsController
Remove FetchedRecordsController
2020-06-29 19:15:38 +02:00
Gwendal Roué cea8c1708f BRAG 2020-06-29 19:15:08 +02:00
Gwendal Roué ad7b044e20 CHANGELOG 2020-06-29 18:49:40 +02:00
Gwendal Roué 1123fdbb23 Mention that FetchedRecordsController is removed in the Migration Guide 2020-06-29 18:49:32 +02:00
Gwendal Roué baa86102ff Fix typo 2020-06-29 18:49:07 +02:00
Gwendal Roué 0d514b56f6 Remove more references to FetchedRecordsController 2020-06-29 18:45:58 +02:00
Gwendal Roué 138cc752a6 Remove FetchedRecordsController 2020-06-29 18:29:29 +02:00
Gwendal Roué 924a596873 Merge branch 'development' 2020-06-29 08:18:06 +02:00
Gwendal Roué 4266b1fb45 v5.0.0-beta.6 2020-06-29 08:17:17 +02:00
Gwendal Roué f58c7f6701 Documentation tweaks 2020-06-29 08:13:00 +02:00
Gwendal Roué a9b02a2d2e Merge pull request #801 from groue/dev/Combine
Combine support
2020-06-29 08:04:47 +02:00
Gwendal Roué 74459be4f7 Delete obsolete file 2020-06-28 23:40:37 +02:00
Gwendal Roué bcf912079b Merge branch 'development' into dev/Combine
# Conflicts:
#	CHANGELOG.md
2020-06-28 23:18:22 +02:00
Gwendal Roué 2a640823c7 Backport https://github.com/groue/GRDBCombine/pull/42 2020-06-28 22:50:37 +02:00
Gwendal Roué 9e77083d40 Relax profiling test 2020-06-28 21:53:34 +02:00
Gwendal Roué e4fbeb1c81 CHANGELOG 2020-06-28 21:23:45 +02:00
Gwendal Roué 733b405f79 Combine + SwiftUI demo 2020-06-28 21:23:39 +02:00
Gwendal Roué 66f0314542 CHANGELOG 2020-06-27 16:08:01 +02:00
Gwendal Roué 039f2661b6 2x faster SQLiteDateParser
GRDBPerformance > DateParsingTests

testParseDateComponents
old 0.296
new 0.073

testParseDate
old 0.431
new 0.181
2020-06-27 16:04:37 +02:00
Gwendal Roué 48bc859801 Add Xcode 12 to Makefile 2020-06-27 14:38:11 +02:00
Gwendal Roué 672e10a0ff Add missing imports for SPM 2020-06-26 06:36:22 +02:00
Gwendal Roué 0fe7b2985b Cleanup SQLCipher test projects 2020-06-25 22:53:09 +02:00
Gwendal Roué 9b24c8213e Skip unavailable tests 2020-06-25 22:16:51 +02:00
Gwendal Roué a193ac1474 Documentation for Combine support 2020-06-25 21:24:17 +02:00
Gwendal Roué 7066980f7b CHANGELOG 2020-06-25 20:11:31 +02:00
Gwendal Roué f27a297e95 Run GRDBCombine tests 2020-06-25 20:08:11 +02:00
Gwendal Roué 11fcb4c749 Embed GRDBCombine tests 2020-06-25 19:25:30 +02:00
Gwendal Roué 22bb800f2e Embed CombineExpectations 2020-06-25 19:25:30 +02:00
Gwendal Roué a0ce362197 Combine publishers 2020-06-25 19:25:29 +02:00
Gwendal Roué 329b010bfa Merge pull request #800 from groue/dev/Xcode12
Xcode 12 support
2020-06-25 19:24:57 +02:00
Gwendal Roué 6470141f17 CHANGELOG 2020-06-25 19:24:36 +02:00
Gwendal Roué 994893951d Temporary disable savepoint tests 2020-06-25 18:52:15 +02:00
Gwendal Roué 4573e80e1c #file vs. #filePath dance 2020-06-25 18:49:58 +02:00
Gwendal Roué 4cdb71bfda Thread-safe SQLite error logging 2020-06-25 08:32:07 +02:00
Gwendal Roué 7820b59996 Fix Swift 5.3 warnings 2020-06-25 08:27:57 +02:00
Gwendal Roué 8be9acf9a6 Fix Xcode 12 project warnings 2020-06-25 08:27:05 +02:00
Gwendal Roué 3a4ab7a6aa ValueObservation.print() tweaks 2020-06-22 19:01:29 +02:00
Gwendal Roué 115f293e26 Merge pull request #798 from groue/dev/ValueObservation-debug
Debugging operators for ValueObservation
2020-06-22 18:43:13 +02:00
Gwendal Roué 4e8b231c42 Rename handleEvents arguments 2020-06-22 14:23:33 +02:00
Gwendal Roué 54adc18988 Fix buggy test 2020-06-21 12:15:43 +02:00
Gwendal Roué e7b17ea0a9 Fix typo 2020-06-21 11:38:40 +02:00
Gwendal Roué 0e12a9acba Fix typo 2020-06-21 11:36:46 +02:00
Gwendal Roué 099d5a311e Cleanup 2020-06-21 11:32:43 +02:00
Gwendal Roué d199f0da83 Cleanup 2020-06-21 11:30:50 +02:00
Gwendal Roué 9e37b6b68e CHANGELOG 2020-06-21 11:20:07 +02:00
Gwendal Roué 006492a02c CHANGELOG 2020-06-21 11:17:34 +02:00
Gwendal Roué 07de1d0105 More ValueObservation event tests 2020-06-21 11:13:59 +02:00
Gwendal Roué 42cd8881a2 ValueObserver.observedRegion can now be private 2020-06-21 10:14:41 +02:00
Gwendal Roué 5c4b282e27 Refactor ValueObservation events handling 2020-06-21 09:17:12 +02:00
Gwendal Roué 7e7c232fc0 Tests for ValueObservation.print() 2020-06-20 22:09:28 +02:00
Gwendal Roué 2c90820f0f ValueObservation.handleEvents and .print documentation 2020-06-20 20:15:07 +02:00
Gwendal Roué dd76cdffec ValueObservation.handleEvents 2020-06-20 19:57:51 +02:00
Gwendal Roué 276c6a4acf Merge pull request #796 from Timac/setupMemoryManagementDocumentation
Fix inline documentation for the setupMemoryManagement() function
2020-06-20 13:17:44 +02:00
Alexandre Colucci f97e0cc540 Fix inline documentation for the setupMemoryManagement() function. In GRDB 5.0.0 and later, the parameter 'application' has been removed. 2020-06-20 12:09:59 +02:00
Gwendal Roué 0fedc0cdbb TODO 2020-06-16 08:59:33 +02:00
Gwendal Roué 0390c3ae93 Documentation 2020-06-16 08:56:48 +02:00
Gwendal Roué 4cdb45e012 Merge branch 'development' 2020-06-15 20:06:34 +02:00
Gwendal Roué 4e182a511f v5.0.0-beta.5 2020-06-15 20:05:13 +02:00
Gwendal Roué a4443b8ebb FAQ Navigation 2020-06-15 19:57:50 +02:00
Gwendal Roué 0f55f76caa Demo app tweaks 2020-06-15 19:45:00 +02:00
Gwendal Roué e3e1feee2b Demo app tweaks 2020-06-15 19:36:43 +02:00
Gwendal Roué 1a1c0cd3d1 Demo app tweaks 2020-06-15 19:23:21 +02:00
Gwendal Roué dd63ddf7f2 CHANGELOG 2020-06-15 17:04:16 +02:00
Gwendal Roué c4ab23761e QueryInterfaceRequest.selectPrimaryKey(as:) 2020-06-15 17:02:00 +02:00
Gwendal Roué 86a8439473 Fix typo 2020-06-15 14:14:09 +02:00
Gwendal Roué 47cf3b0108 Update FAQ sample code with TableRecord.primaryKey, and add tests for FAQ 2020-06-15 14:09:15 +02:00
Gwendal Roué ab97ceb784 TableRecord.primaryKey 2020-06-15 14:08:50 +02:00
Gwendal Roué ae7cdb1f5b Precision 2020-06-14 20:58:04 +02:00
Gwendal Roué c0cf3c0525 Fix wording 2020-06-14 20:51:38 +02:00
Gwendal Roué 82feed42c2 Fix wording 2020-06-14 20:50:46 +02:00
Gwendal Roué 5c697659b4 Foster SQLITE_ENABLE_SNAPSHOT in the "Custom SQLite Builds" guide 2020-06-14 20:49:22 +02:00
Gwendal Roué efc12c2ef9 CHANGELOG 2020-06-14 20:39:31 +02:00
Gwendal Roué 280c9f0155 Fix sample code 2020-06-14 20:33:49 +02:00
Gwendal Roué 9608b5edd5 Fix typo 2020-06-14 20:32:36 +02:00
Gwendal Roué 7662e53dce Fix typo 2020-06-14 20:31:29 +02:00
Gwendal Roué 1f5cc801e1 Fix typos 2020-06-14 20:29:38 +02:00
Gwendal Roué 2c6ca91985 Fix inner links 2020-06-14 20:28:16 +02:00
Gwendal Roué 023a04aff9 Associations FAQ 2020-06-14 20:25:22 +02:00
Gwendal Roué ffe40dbf79 Fix indentation 2020-06-14 17:10:24 +02:00
Gwendal Roué cf9b9206bd Fix typo 2020-06-14 17:06:36 +02:00
Gwendal Roué 0f70af7a22 Fix typo 2020-06-14 17:05:56 +02:00
Gwendal Roué 7068a4f149 Update the demo app for better alignment with "Good Practices for Designing Record Types" 2020-06-14 17:03:24 +02:00
Gwendal Roué 70714768d9 Always use snapshots apis through grdb_xxx shims 2020-06-14 15:38:16 +02:00
Gwendal Roué ec0e8672be Documentation, cleanup 2020-06-14 11:03:24 +02:00
Gwendal Roué 9215f88e7f Documentation, cleanup, and checkpoint prevention 2020-06-14 10:47:27 +02:00
Gwendal Roué 510daa84a7 This is hard 2020-06-14 06:36:53 +02:00
Gwendal Roué eacf48fef3 More snapshot-based optimization of ValueObservation with DatabasePool
This time, for the .immediate scheduler.
2020-06-14 06:34:08 +02:00
Gwendal Roué 0dee6425d1 Fix free function 2020-06-14 05:36:33 +02:00
Gwendal Roué 842846dbc4 Documentation 2020-06-14 05:36:12 +02:00
Gwendal Roué 8b800ecbe1 CHANGELOG 2020-06-13 20:19:00 +02:00
Gwendal Roué f1e65fbb2c Optimization of ValueObservation with DatabasePool thanks to SQLITE_ENABLE_SNAPSHOT
The difficulty is that system <sqlite3.h> does not contain the expected declarations, even when SQLite is compiled with SQLITE_ENABLE_SNAPSHOT :-(

Since snapshots are not exposed in any public API, we don't bother dealing with availability checks. We just add the missing declarations, and rely on the linker in order to spot eventual errors.

This commit is likely to break Linux builds, though.
2020-06-13 20:14:40 +02:00
Gwendal Roué 372996deb3 TODO
# Conflicts:
#	TODO.md
2020-06-13 13:36:51 +02:00
Gwendal Roué 45f5ece534 CHANGELOG 2020-06-12 14:22:47 +02:00
Gwendal Roué a95b3264de Fix documentation 2020-06-12 14:20:29 +02:00
Gwendal Roué 8d44ad7256 Database.maximumStatementArgumentCount 2020-06-12 14:19:31 +02:00
Gwendal Roué a136384c7d Merge pull request #795 from groue/dev/more-checkpoint
Enhanced support for WAL Checkpoints
2020-06-12 12:46:52 +02:00
Gwendal Roué b15999e4c9 TODO 2020-06-12 12:45:12 +02:00
Gwendal Roué e8235f8d6a Database.columnsForUniqueKey(_:in:) does not hit the database for empty column sequences 2020-06-11 12:49:22 +02:00
Gwendal Roué e31f7a4763 CHANGELOG 2020-06-07 17:07:31 +02:00
Gwendal Roué 3103e6e373 Fix Swiftlint warning 2020-06-07 17:07:31 +02:00
Gwendal Roué 3a42a4bf9f Rename checkpoint tuple members 2020-06-07 17:07:31 +02:00
Gwendal Roué 3e5a21b49b Tests for Database.checkpoint(_🔛) 2020-06-07 17:07:31 +02:00
Gwendal Roué 6f3ec89bcd Update checkpointing tests 2020-06-07 17:07:31 +02:00
Gwendal Roué 56f6984f9d Introduce Database.checkpoint(_🔛) 2020-06-07 17:07:31 +02:00
Gwendal Roué 5f88a400d5 DatabasePool.checkpoint(_:) is unavailable 2020-06-07 17:07:31 +02:00
Gwendal Roué 91ed7d762b Setup busy handler as soon as possible 2020-06-07 17:07:30 +02:00
Gwendal Roué 668c1d632e f67f9ebd4b did spot an oddity
This is a temp fix
2020-06-07 17:07:02 +02:00
Gwendal Roué 20f693c508 Disable two SQLCipher tests until we understand what is happening 2020-06-07 16:36:55 +02:00
Gwendal Roué f67f9ebd4b Add a sanity transaction assertion 2020-06-07 15:57:50 +02:00
Gwendal Roué 53dade2740 Merge branch 'development' 2020-06-06 15:12:27 +02:00
Gwendal Roué 9ec9880889 v5.0.0-beta.4 2020-06-06 15:11:56 +02:00
Gwendal Roué eb27b0cfc5 BRAG 2020-06-06 15:11:28 +02:00
Gwendal Roué d3cc23d5a3 Harmonize GRDB, GRDBCombine, RxGRDB for next beta 2020-06-06 15:04:13 +02:00
Gwendal Roué e129463bae Maybe fix a broken link in the generated jazzy doc 2020-06-06 13:46:32 +02:00
Gwendal Roué b567d64489 fix typo 2020-06-05 20:49:21 +02:00
Gwendal Roué d94fcc398b Date modifiers, more julianDay(), and dateTime() 2020-06-05 20:48:12 +02:00
Gwendal Roué 3c48a434f1 Tests for default SQLExpressible conformance for RawRepresentable 2020-06-05 12:27:58 +02:00
Gwendal Roué d04dda1888 Default SQLExpressible conformance for RawRepresentable 2020-06-05 12:27:42 +02:00
Gwendal Roué 842c6ced0c Documentation for julianDay function 2020-06-05 12:14:46 +02:00
Gwendal Roué 59c5d2e43b test for julianDay function 2020-06-05 12:14:40 +02:00
Gwendal Roué 2aeddda77d julianDay function 2020-06-05 12:14:34 +02:00
Gwendal Roué 9aeccce227 Makefile: support for Xcode 11.5 2020-06-05 08:33:20 +02:00
Gwendal Roué 45e5333c2c Test optimized SQLCipher 2020-06-05 08:32:05 +02:00
Gwendal Roué f4581b993b Merge pull request #794 from groue/dev/Database-description
Name of Database Connections
2020-06-04 18:20:18 +02:00
Gwendal Roué d2b1853b7b Database.debugDescription 2020-06-04 18:15:48 +02:00
Gwendal Roué 800b9ffc3d Name the temporary database used by DatabaseMigrator.eraseDatabaseOnSchemaChange 2020-06-03 20:09:22 +02:00
Gwendal Roué a93f75a6fc CHANGELOG 2020-06-03 20:01:59 +02:00
Gwendal Roué 04df4ba157 Documentation 2020-06-03 19:57:43 +02:00
Gwendal Roué d55e16de3c Database.description tests 2020-06-03 19:37:34 +02:00
Gwendal Roué 780ba744f1 Database.description 2020-06-03 19:37:24 +02:00
Gwendal Roué 8027925ae6 TODO 2020-06-03 19:07:03 +02:00
Gwendal Roué b29695b024 Link to statement profiling FAQ from SharingADatabase.md 2020-06-03 19:06:09 +02:00
Gwendal Roué d98904727f Thank you 2020-06-01 21:12:53 +02:00
Gwendal Roué 4cd421ff7c Merge branch 'development' 2020-06-01 20:21:22 +02:00
Gwendal Roué a8b58cb7e7 v5.0.0-beta.3 2020-06-01 20:20:52 +02:00
Gwendal Roué 578fa162f1 Merge pull request #791 from groue/dev/trace
Extend tracing of statement execution
2020-06-01 20:14:35 +02:00
Gwendal Roué 7333b1a080 Travis: no more stages 2020-06-01 18:20:02 +02:00
Gwendal Roué 961e5e46c1 Fix SQLCipher tests 2020-06-01 14:09:22 +02:00
Gwendal Roué a2dce4a238 Come on, Travis 2020-06-01 09:02:25 +02:00
Gwendal Roué 996c1c994f Documentation 2020-06-01 07:41:46 +02:00
Gwendal Roué 9540df84cf Documentation 2020-06-01 07:39:43 +02:00
Gwendal Roué b47680638d Trace statements by default 2020-06-01 07:16:48 +02:00
Gwendal Roué 5f7a9de8a5 Fix statement profiling test for slow setups 2020-06-01 06:28:46 +02:00
Gwendal Roué b80814a77e CHANGELOG 2020-05-31 20:16:00 +02:00
Gwendal Roué b95d7cb647 More Tests for Database.trace(options:_:) 2020-05-31 20:13:45 +02:00
Gwendal Roué 3e25faabba Update the migration guide 2020-05-31 19:16:35 +02:00
Gwendal Roué 2677cf8de8 Update documentation 2020-05-31 19:16:23 +02:00
Gwendal Roué 81213f2649 Tests for Database.trace(options:_:) 2020-05-31 19:08:42 +02:00
Gwendal Roué 30f619ca2c Refactor database tracing
- Make it possible to log the database label along with the executed SQL
- Make it possible to avoid arguments expansion
- Make it possible to profile statements
2020-05-31 19:08:08 +02:00
Gwendal Roué 9552a5ce40 Merge pull request #790 from groue/dev/iOS10
Bump required iOS version to 10.0
2020-05-31 14:20:33 +02:00
Gwendal Roué 318564a13c CHANGELOG 2020-05-31 14:02:18 +02:00
Gwendal Roué 9ee3fd38b5 Remove mentions of unsupported iOS versions 2020-05-31 13:54:02 +02:00
Gwendal Roué 03a66af35e Bump iOS requirement to iOS10+
iOS9 simulator is no longer available with the Xcode 11.4+ requirement. https://twitter.com/xenadu02/status/1140093901438689280
2020-05-31 13:48:59 +02:00
Gwendal Roué 00c2f61535 TODO 2020-05-30 13:54:45 +02:00
Gwendal Roué 289394c7ac Turn LockedBox and ReadWriteBox into property wrappers.
Also fix an old concurrency bug in tests, regarding query recording
2020-05-30 13:52:39 +02:00
Gwendal Roué a5de2b9288 Breaking: AnyFetchRequest.asRequest(of:) 2020-05-30 10:30:07 +02:00
Gwendal Roué e0266bdde3 Merge pull request #784 from groue/dev/fix-783
Fix observation of eager-loaded to-many associations
2020-05-25 18:34:30 +02:00
Gwendal Roué e82ecfee9f CHANGELOG 2020-05-25 13:41:41 +02:00
Gwendal Roué 80f0379d71 Remove database content unused by test 2020-05-25 13:39:35 +02:00
Gwendal Roué 449c0e37b1 Update regression tests for #783 2020-05-25 13:24:25 +02:00
Gwendal Roué f825c52ecf Update request region tests for both DatabaseRegionConvertible and statement region 2020-05-25 13:04:48 +02:00
Gwendal Roué 4c2042c3ce Cleanup 2bb53026ef 2020-05-25 13:04:10 +02:00
Gwendal Roué af0946fd21 Regression tests for #783 (WIP) 2020-05-25 09:34:35 +02:00
Gwendal Roué 2bb53026ef Fix #783 2020-05-25 09:34:11 +02:00
Gwendal Roué 0929fe72b8 Cleanup detection of queries that return a single row 2020-05-14 12:28:52 +02:00
Gwendal Roué e0a40776ee Makefile update for Travis 2020-05-12 07:21:13 +02:00
Gwendal Roué e99015bcff Merge branch 'development' 2020-05-11 18:50:35 +02:00
Gwendal Roué abd7ee9f17 v5.0.0-beta.2 2020-05-11 18:49:57 +02:00
Gwendal Roué 364c624a37 Update sample code for sharing databases 2020-05-11 18:44:38 +02:00
Gwendal Roué 00e10324d8 Merge pull request #775 from groue/dev/superseded-migrator
DatabaseMigrator can check if it has been superseded
2020-05-11 13:35:10 +02:00
Gwendal Roué 0539c41d17 CHANGELOG 2020-05-11 09:10:14 +02:00
Gwendal Roué 212a6f7e53 Documentation 2020-05-11 09:06:04 +02:00
Gwendal Roué cff769ddd5 Documentation 2020-05-11 08:54:31 +02:00
Gwendal Roué ed6ad9d373 Clean up DatabaseMigrator tests 2020-05-11 08:50:04 +02:00
Gwendal Roué 44772f89d7 More tests for DatabaseMigrator.hasBeenSuperseded(_:) 2020-05-11 08:46:41 +02:00
Gwendal Roué 2aa61c3403 Tests for DatabaseMigrator.hasBeenSuperseded(_:) 2020-05-11 08:28:02 +02:00
Gwendal Roué 3fea5db763 DatabaseMigrator.hasBeenSuperseded(_:) 2020-05-11 08:27:41 +02:00
Gwendal Roué b2bc0e7941 Merge pull request #774 from groue/dev/request-as-expression-and-collection
All requests are usable as SQL expressions and collections
2020-05-11 08:10:45 +02:00
Gwendal Roué c7d98e0231 CHANGELOG 2020-05-10 15:34:38 +02:00
Gwendal Roué 6fcf4f565a Relax test for various SQLite versions 2020-05-10 15:34:38 +02:00
Gwendal Roué 8c11a751ff TODO 2020-05-10 15:34:38 +02:00
Gwendal Roué c0217d56ca Remove doubt about how SQLRequest uses singleResult 2020-05-10 15:34:38 +02:00
Gwendal Roué 89ba8c3398 Remove unclear rationale 2020-05-10 15:34:38 +02:00
Gwendal Roué d814ab216d Documentation 2020-05-10 15:34:38 +02:00
Gwendal Roué 284ec22dd5 Documentation 2020-05-10 15:34:38 +02:00
Gwendal Roué 57e5735e9a Documentation 2020-05-10 15:34:38 +02:00
Gwendal Roué 5786d19ff4 Documentation 2020-05-10 15:34:38 +02:00
Gwendal Roué c73872549a Fix typo 2020-05-10 15:34:38 +02:00
Gwendal Roué f799d5f30c Documentation 2020-05-10 15:34:38 +02:00
Gwendal Roué e94be4a06e Upgrade path for FetchRequest 2020-05-10 15:34:38 +02:00
Gwendal Roué e9a68d82e6 Remove FetchRequest documentation from the main README 2020-05-10 15:34:38 +02:00
Gwendal Roué b16a0da88c Documentation 2020-05-10 15:34:37 +02:00
Gwendal Roué a318d4cc82 Test upgrade path from GRDB4 to GRDB5 2020-05-10 15:34:37 +02:00
Gwendal Roué 4f500de04b Expose SQLLiteral.sql(_:)
This is needed for custom FetchRequest types
2020-05-10 15:34:37 +02:00
Gwendal Roué a77b195c7c Reopen FetchRequest 2020-05-10 15:34:37 +02:00
Gwendal Roué d2928a9929 requestSQL(_:forSingleResult:) is experimental 2020-05-10 15:34:37 +02:00
Gwendal Roué 476e72cca2 requestSQL(_:forSingleResult:) is experimental 2020-05-10 15:34:37 +02:00
Gwendal Roué 375ed0135c PreparedRequest is still documented 2020-05-10 15:34:37 +02:00
Gwendal Roué 17e745f52b SQLRequestProtocol, close FetchRequest 2020-05-10 15:34:37 +02:00
Gwendal Roué a3cc5745ac Revert "Test for the immutable flag"
This reverts commit 8a595be54f.
2020-05-10 15:31:56 +02:00
Gwendal Roué 8a595be54f Test for the immutable flag
https://sqlite.org/uri.html#uriimmutable
2020-05-10 12:38:04 +02:00
Gwendal Roué 68203b5373 Merge pull request #773 from groue/dev/subqueries-and-aliases
Allow subqueries to refer to outer tables
2020-05-09 08:20:49 +02:00
Gwendal Roué a79fc34071 CHANGELOG 2020-05-08 20:57:50 +02:00
Gwendal Roué 7f66f41026 TODO 2020-05-08 20:43:10 +02:00
Gwendal Roué 956f419b20 TODO 2020-05-08 20:41:21 +02:00
Gwendal Roué e414aca05b Cleanup 2020-05-08 20:41:18 +02:00
Gwendal Roué 76e0a9f6b6 AnyFetchRequest is now generic on RowDecoder 2020-05-08 16:43:02 +02:00
Gwendal Roué 94b4131ce4 TODO 2020-05-08 15:07:18 +02:00
Gwendal Roué a26901cb80 Allow subqueries to refer to table aliases from parent query 2020-05-08 15:06:16 +02:00
Gwendal Roué a4d7f39ad8 Merge pull request #772 from groue/dev/SQLITE_FCNTL_PERSIST_WAL
Update the Database Sharing Guide with mention of the persistent WAL mode
2020-05-06 19:39:53 +02:00
Gwendal Roué 6f02a90a7a Remove link to deleted chapter 2020-05-06 19:38:24 +02:00
Gwendal Roué ae3c06f761 Remove the obsolete "Performance" chapter
It contained outdated information, and removing it helps GitHub preserve Markdown rendering of our looooong README.
2020-05-06 19:37:08 +02:00
Gwendal Roué f29a98aac3 Fix inner documentation links 2020-05-06 19:33:39 +02:00
Gwendal Roué a641b1efd4 Documentation 2020-05-06 19:29:48 +02:00
Gwendal Roué fc6c46e628 CHANGELOG 2020-05-06 19:25:11 +02:00
Gwendal Roué cb8c9f5ba3 SQLITE_FCNTL_PERSIST_WAL is always recommended 2020-05-06 19:13:16 +02:00
Gwendal Roué a8122b44f1 Wording 2020-05-06 18:52:39 +02:00
Gwendal Roué 6b86e61056 Cool URIs don't change 2020-05-06 18:38:36 +02:00
Gwendal Roué 97bbb5bced Rename AppGroupContainers.md to SharingADatabase.md 2020-05-06 18:34:45 +02:00
Gwendal Roué b3b155459f Document the "persistent WAL mode" and SQLITE_FCNTL_PERSIST_WAL 2020-05-06 18:24:06 +02:00
Gwendal Roué e4803c1e0c Cleanup SQLITE_FCNTL_PERSIST_WAL tests 2020-05-06 13:25:59 +02:00
Gwendal Roué db7fb96142 Tests for persistent WAL mode
Tests for SQLITE_FCNTL_PERSIST_WAL: https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpersistwal
2020-05-06 08:55:27 +02:00
Gwendal Roué 3eb7d57754 [skip travis] Documentation 2020-05-04 12:57:42 +02:00
Gwendal Roué 7af96a69a0 Merge pull request #753 from groue/GRDB5
GRDB 5
2020-05-02 18:07:54 +02:00
Gwendal Roué 00e6d4ed0e Give *even* more time to tests 2020-05-02 16:23:31 +02:00
Gwendal Roué f4b2c2d40a [skip travis] Bump release date 2020-05-02 15:36:10 +02:00
Gwendal Roué 75e9056ac8 [skip travis] Fix inner links 2020-05-02 15:22:19 +02:00
Gwendal Roué a69be48066 Give more time to tests 2020-05-02 15:13:02 +02:00
Gwendal Roué 420fb93356 Fix testErrorCompletesTheObservation 2020-05-02 12:30:54 +02:00
Gwendal Roué 425e506862 Make all ValueObservation tests deterministic (avoid inverted expectations)
Inverted expectations were just too flaky on Travis
2020-05-02 12:19:23 +02:00
Gwendal Roué f09a62415d Restore disabled Travis jobs
We'll need some stronger cure. All timeout-based tests are flaky on Travis :-(
2020-05-02 09:04:51 +02:00
Gwendal Roué 90028ee9f5 Give more time for Travis 2020-05-02 08:41:56 +02:00
Gwendal Roué e37d2ae18c [skip travis] Fix inner links 2020-05-02 05:51:14 +02:00
Gwendal Roué 0322537b63 [skip travis] Fix inner links 2020-05-02 05:42:33 +02:00
Gwendal Roué 7b6bd84ac2 Disable flaky tvOS tests
https://travis-ci.org/github/groue/GRDB.swift/jobs/682070292
2020-05-02 05:28:42 +02:00
Gwendal Roué 6a98a46c85 Speed up slow tests 2020-05-01 20:11:02 +02:00
Gwendal Roué 0ab974e1b7 [skip travis] Rename Travis jobs 2020-05-01 19:47:46 +02:00
Gwendal Roué 85b84f217d Fix for Travis 2020-05-01 19:27:17 +02:00
Gwendal Roué 5e9cbf41a5 Let people find the non-beta version 2020-05-01 19:02:24 +02:00
Gwendal Roué 773db56d79 Sort the section of moved chapters 2020-05-01 18:59:28 +02:00
Gwendal Roué f68cbb03ee Update link to migration guide 2020-05-01 18:57:32 +02:00
Gwendal Roué 15f1e5259d Extract the Migration guide from the main README
README is too big, and Github stops rendering Markdown
2020-05-01 18:56:05 +02:00
Gwendal Roué 7ede3edf0c v5.0.0-beta 2020-05-01 18:44:13 +02:00
Gwendal Roué 14d16ffd20 My 🦋 keyboard is 💩 2020-05-01 17:34:08 +02:00
Gwendal Roué a7df6cc7df CHANGELOG 2020-05-01 17:30:11 +02:00
Gwendal Roué aaa5986e33 CHANGELOG 2020-05-01 17:26:43 +02:00
Gwendal Roué 3173dd20fe CHANGELOG 2020-05-01 17:18:14 +02:00
Gwendal Roué a29ca8348f CHANGELOG: documentation diff 2020-05-01 17:15:44 +02:00
Gwendal Roué 278e72ecc8 Fix typo 2020-05-01 17:15:35 +02:00
Gwendal Roué cf738588f2 Fix typo 2020-05-01 16:30:41 +02:00
Gwendal Roué 146b06f27a bugfix 2020-05-01 16:15:54 +02:00
Gwendal Roué fa4a90f720 Improve SQLQueryGenerator.expectsSingleResult 2020-05-01 16:06:56 +02:00
Gwendal Roué 93f4d43ee6 Cleanup 2020-05-01 15:43:57 +02:00
Gwendal Roué da4b96c2ca Cleanup handling of subquery sources 2020-05-01 15:42:01 +02:00
Gwendal Roué 420a257650 Test for case insensitivity in association requests 2020-05-01 15:07:40 +02:00
Gwendal Roué 39f327fcb3 Optimize SQLAssociationCondition.filteringExpression(_:leftRows:)
And make sure we compute a correct database region for association requests
2020-05-01 15:06:47 +02:00
Gwendal Roué 27ffb2a418 Rename index(ofColumn:) to index(forColumn:) 2020-05-01 15:01:01 +02:00
Gwendal Roué 0dc18cdaab CHANGELOG 2020-05-01 13:17:23 +02:00
Gwendal Roué 1ac9051384 Merge pull request #770 from groue/dev/subqueries
Subqueries
2020-05-01 12:36:19 +02:00
Gwendal Roué 691bb73d3e Bump iOS version in Makefile 2020-05-01 12:07:32 +02:00
Gwendal Roué 61d7740767 Fix FTS5 2020-05-01 11:27:08 +02:00
Gwendal Roué 7f7554f601 Document support for subqueries 2020-05-01 11:12:44 +02:00
Gwendal Roué ee68550052 Fix typo 2020-05-01 10:59:10 +02:00
Gwendal Roué 4de63ca9a2 Documentation fix 2020-05-01 10:47:23 +02:00
Gwendal Roué ef42035fe4 Documentation 2020-05-01 10:36:36 +02:00
Gwendal Roué eb93b25301 Fix typo 2020-05-01 10:28:19 +02:00
Gwendal Roué 2502747a7b Update the "Joined Queries Support" chapter 2020-05-01 10:25:44 +02:00
Gwendal Roué de5477d8f0 Documentation 2020-05-01 09:47:27 +02:00
Gwendal Roué fae562f20d Documentation 2020-05-01 09:43:48 +02:00
Gwendal Roué 307c3d5a13 Documentation 2020-05-01 09:01:10 +02:00
Gwendal Roué 7a1afba26e Documentation 2020-05-01 08:59:00 +02:00
Gwendal Roué b2370dd597 TODO 2020-05-01 08:58:52 +02:00
Gwendal Roué 513b7e9379 Tests for interpolation of TableRecord selection 2020-05-01 08:58:46 +02:00
Gwendal Roué 9392722bab Restore and fix test for TableRecord selection interpolation 2020-04-30 19:47:35 +02:00
Gwendal Roué 321b6a3488 Fixits for renamed generic parameter 2020-04-30 19:37:02 +02:00
Gwendal Roué 443d44cc7a Restore TableRecord.selectionSQL in the form of SQL interpolation 2020-04-30 19:33:33 +02:00
Gwendal Roué df2cc0af36 Test for SQLCollection qualification 2020-04-30 19:01:14 +02:00
Gwendal Roué dfcc6f99a5 SQLCollection can be qualified, now 2020-04-30 18:49:20 +02:00
Gwendal Roué 664c1ed281 Documentation 2020-04-30 18:35:05 +02:00
Gwendal Roué 057679a2ba We don't need to prevent requests that select several columns 2020-04-30 18:22:59 +02:00
Gwendal Roué e05b8b2b47 Unify SQLGenerationContext 2020-04-30 17:56:15 +02:00
Gwendal Roué d67f4802d3 Documentation 2020-04-30 15:21:41 +02:00
Gwendal Roué 72e4fc620b Remove LIMIT 1 from aggregated requests 2020-04-30 15:16:00 +02:00
Gwendal Roué 9c53ed94a7 Documentation 2020-04-30 15:13:33 +02:00
Gwendal Roué cac605749d Cleanup SQLExpressionBinaryReduce.truthComponents 2020-04-30 14:21:25 +02:00
Gwendal Roué 9006c701b3 Replace the expectsSingleResult hint with an analysis of the query 2020-04-30 14:14:07 +02:00
Gwendal Roué 05c001865b Cleanup 2020-04-30 09:12:57 +02:00
Gwendal Roué cb7a7633b1 TODO 2020-04-30 09:04:17 +02:00
Gwendal Roué 1e92b98165 TODO 2020-04-30 08:40:35 +02:00
Gwendal Roué 0bf23477f8 Less TODO 2020-04-30 08:36:10 +02:00
Gwendal Roué 359df39b7e Make it easier to look for subquery tests 2020-04-30 08:36:04 +02:00
Gwendal Roué cfd4141469 CHANGELOG 2020-04-30 08:32:51 +02:00
Gwendal Roué 90415fa936 Documentation 2020-04-30 08:31:59 +02:00
Gwendal Roué 1d89d184fd Fix subqueries semantics 2020-04-30 08:19:00 +02:00
Gwendal Roué 026e5b288f Documentation 2020-04-29 23:46:42 +02:00
Gwendal Roué be249bc697 SQLRequestExpressible is a sub protocol of SQLSpecificExpressible 2020-04-29 23:40:37 +02:00
Gwendal Roué 69641ff7d6 Undo undesired change 2020-04-29 22:29:53 +02:00
Gwendal Roué 4245e8f09e Cleanup 2020-04-29 22:24:58 +02:00
Gwendal Roué 94fed7965b Cleanup 2020-04-29 22:16:19 +02:00
Gwendal Roué a15233eff1 SQLGenerationContext no longer needs to be mutated 2020-04-29 21:59:04 +02:00
Gwendal Roué e47a584c3e TableRecord.selectionSQL can no longer be implemented 🤷 2020-04-29 21:51:02 +02:00
Gwendal Roué 188f51c513 Refactor handling of arguments during SQL generation 2020-04-29 21:27:14 +02:00
Gwendal Roué e800c71cbc Refactor SQLLiteral so that subqueries are no longer a special case 2020-04-29 20:20:13 +02:00
Gwendal Roué 3d86f45aa2 SQLRequestExpressible
This protocol makes it possible to write request.filter(column == subRequest)
2020-04-29 20:18:00 +02:00
Gwendal Roué 473bc3a88e SQLQueryGenerator handles the single result optimization. Make sure a single column is selected for expression/collection requests 2020-04-29 18:30:46 +02:00
Gwendal Roué 4b9336f5c5 TODO 2020-04-29 15:21:22 +02:00
Gwendal Roué 8bcf9257f6 TODO 2020-04-29 14:32:53 +02:00
Gwendal Roué ca59d706e9 Cleanup 2020-04-29 14:27:58 +02:00
Gwendal Roué 82ff6cb4c5 Cleanup 2020-04-29 14:24:25 +02:00
Gwendal Roué 21552d8838 SQLRequest & QueryInterfaceRequest are SQLExpression 2020-04-29 14:24:18 +02:00
Gwendal Roué 26f40efece TODO 2020-04-29 13:54:00 +02:00
Gwendal Roué c82dbb35ad SQLLiteral and SQLRequest no longer have sql and arguments properties 2020-04-29 13:52:29 +02:00
Gwendal Roué 84ca69d27c Value quoting can now require a database connection 2020-04-29 11:03:51 +02:00
Gwendal Roué 6dca9e1068 Cleanup 2020-04-29 09:49:24 +02:00
Gwendal Roué 8cb75dd814 Subqueries wip 2020-04-28 21:03:58 +02:00
Gwendal Roué 59e81f70bd Cleanup aggregates 2020-04-28 19:49:41 +02:00
Gwendal Roué 399766fe10 Fix #739 2020-04-28 19:19:30 +02:00
Gwendal Roué f543784241 TODO 2020-04-28 14:20:05 +02:00
Gwendal Roué 0b0f0e53da TODO 2020-04-26 18:04:57 +02:00
Gwendal Roué f738fdfa8e Cleanup Decodable behavior regarding missing keys and optionals 2020-04-26 14:19:29 +02:00
Gwendal Roué a8f7978ec4 Update documention after d0ba9e342c 2020-04-26 11:55:53 +02:00
Gwendal Roué d1af9dbdf1 Fix documentation comment 2020-04-25 20:27:25 +02:00
Gwendal Roué d0ba9e342c Turn selection and having clauses into promises. Give association aggregates access to the actual primary key, for better support for WITHOUT ROW ID tables. 2020-04-25 19:51:03 +02:00
Gwendal Roué b38ccb5f40 TODO 2020-04-25 15:15:06 +02:00
Gwendal Roué 605aad79ad Replace use of rowid by primary key when possible. Cleanup management of association cardinality
This is a backport of enhancements brought by the failed pull request https://github.com/groue/GRDB.swift/pull/767
2020-04-25 15:15:01 +02:00
Gwendal Roué 6fd3a7b225 Merge branch 'development' into GRDB5
# Conflicts:
#	CHANGELOG.md
#	README.md
2020-04-25 13:21:20 +02:00
Gwendal Roué 6b1910fce7 [skip travis] fix typo in CHANGELOG 2020-04-23 09:08:27 +02:00
Gwendal Roué 5ee47c3c27 Merge branch 'development' 2020-04-23 08:56:55 +02:00
Gwendal Roué 5652a01366 v4.14.0 2020-04-23 08:55:38 +02:00
Gwendal Roué 132d01f9f7 Complete #766: use json objects in DatabaseDateComponents tests 2020-04-22 19:33:31 +02:00
Gwendal Roué 1d760ff9ce Extend congrats list 2020-04-22 18:45:34 +02:00
Gwendal Roué dc4d516493 Merge pull request #766 from DiligentRobot/development
Add Codable support to DatabaseDateComponents
2020-04-20 19:17:07 +02:00
Matt Tancock 62c6187ad4 Remove Format's Codable conformance. Use a singleValueContainer 2020-04-20 14:42:02 +01:00
Matt Tancock 18154f29be Simplify encoding format and add tests 2020-04-20 13:36:23 +01:00
Gwendal Roué a715c6328d Merge branch 'master' into GRDB5
# Conflicts:
#	CHANGELOG.md
#	GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
#	Makefile
#	README.md
#	Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.pbxproj
2020-04-18 16:36:26 +02:00
Matt Tancock bffe4d32f5 Add Codable support to DatabaseDateComponents 2020-04-17 16:16:34 +01:00
Gwendal Roué 3fd00012d1 Update obsolete observation usage in README 2020-04-17 09:03:03 +02:00
Gwendal Roué 6d901b06e9 TODO 2020-04-16 19:27:09 +02:00
Gwendal Roué f677310703 Merge branch 'development' 2020-04-15 08:27:35 +02:00
Gwendal Roué 0200f64e6c v4.13.0 2020-04-14 19:14:15 +02:00
Gwendal Roué c6b5c935bb Merge pull request #761 from groue/dev/deprecate-assignment-operator
Deprecate the batch update `<-` operator
2020-04-14 19:03:43 +02:00
Gwendal Roué 2d30f06f54 Update regression test introduced after commit cherry-picked from #750 2020-04-14 19:01:42 +02:00
Gwendal Roué a98350d206 CHANGELOG 2020-04-14 18:55:40 +02:00
Gwendal Roué 6918bda82d CHANGELOG 2020-04-14 18:51:21 +02:00
Gwendal Roué a065926fb1 Update documentation 2020-04-14 18:51:21 +02:00
Gwendal Roué 0569b95a5a Operator <- was ill-advised
# Conflicts:
#	GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
2020-04-14 18:51:21 +02:00
Gwendal Roué d17866d3fd Update Realm path 2020-04-14 18:50:51 +02:00
Gwendal Roué 6c0f1dc389 Merge pull request #759 from groue/dev/fix-758
Fix batch updates of complex requests
2020-04-14 18:50:26 +02:00
Gwendal Roué e7750e6fe0 Merge pull request #760 from andreasschmitz/development
README Typo Fixes
2020-04-14 17:33:01 +02:00
Andreas Schmitz e4addc4243 Fixes typos 2020-04-14 17:18:27 +02:00
Gwendal Roué d35ad59f9c Fix failing test for #758 2020-04-14 12:51:24 +02:00
Gwendal Roué 07609e8a3f Failing test for #758 2020-04-14 12:51:24 +02:00
Gwendal Roué f4e2645e13 CHANGELOG 2020-04-14 12:47:00 +02:00
Gwendal Roué c352ca70b2 A new kind tweet :-) 2020-04-14 12:17:38 +02:00
Gwendal Roué b182a26759 Fix compilation error with Xcode 10.1 2020-04-14 12:14:25 +02:00
Gwendal Roué c493b17232 Merge branch 'development' 2020-04-13 11:52:21 +02:00
Gwendal Roué 94d34a744d v4.12.2 2020-04-13 11:51:28 +02:00
Gwendal Roué 0cda88bd28 Merge pull request #757 from groue/dev/lazy-inflections
Don't load association inflections unless necessary
2020-04-13 11:47:20 +02:00
Gwendal Roué c62ccf1de7 Make sure Inflections.default is lazily loaded, even in optimized release builds
This commit addresses #755
2020-04-13 11:31:03 +02:00
Gwendal Roué 5760b9c0cc Migration Guide 2020-04-12 20:10:03 +02:00
Gwendal Roué 75525bdb56 Migration Guide 2020-04-12 17:33:04 +02:00
Gwendal Roué 2fa57cdafa Make CSQLite a system module
Attempt at fixing this GRDBCombine error:

$ swift build
...
'CSQLite' /.../GRDBCombine/.build/checkouts/CSQLite: error: configuration of package 'CSQLite' is invalid; the 'providers' property can only be used with a System Module Package
2020-04-12 15:07:39 +02:00
Gwendal Roué 2319572552 Remove unused file 2020-04-12 13:04:45 +02:00
Gwendal Roué 5f26a71c5b Migration Guide 2020-04-12 10:24:44 +02:00
Gwendal Roué d0558ee2f0 Migration Guide 2020-04-12 10:15:09 +02:00
Gwendal Roué fc09fd6654 Merge pull request #756 from groue/dev/export-SQLite
Export the underlying SQLite library
2020-04-12 10:05:19 +02:00
Gwendal Roué 1ea5d1713a Cleanup 2020-04-12 10:04:09 +02:00
Gwendal Roué aa0ae00c56 CHANGELOG 2020-04-12 09:44:11 +02:00
Gwendal Roué 0372c1dd63 Complete #747: export the underlying SQLite library 2020-04-12 07:27:50 +02:00
Gwendal Roué c052b44999 Cleanup 2020-04-11 20:56:36 +02:00
Gwendal Roué f27d6b07c0 Cleanup 2020-04-11 20:45:00 +02:00
Gwendal Roué 4f8b681737 Documentation 2020-04-11 18:26:42 +02:00
Gwendal Roué 5b9ae9371b Documentation 2020-04-11 17:37:12 +02:00
Gwendal Roué 68f4db468a Documentation 2020-04-11 17:25:16 +02:00
Gwendal Roué 62dbc78090 More migration guide 2020-04-11 13:57:19 +02:00
Gwendal Roué bd7bec22a1 More migration guide 2020-04-11 13:52:36 +02:00
Gwendal Roué 722e74db6a More migration guide 2020-04-11 13:49:26 +02:00
Gwendal Roué e9439a1d58 Fix typo 2020-04-11 13:39:02 +02:00
Gwendal Roué 3c70814cdc More ValueObservation migration doc 2020-04-11 13:38:01 +02:00
Gwendal Roué fea89100d9 Improve ValueObservation.trackingVaryingRegion example 2020-04-11 13:10:15 +02:00
Gwendal Roué 2c3d0b1e17 Organize migration guide 2020-04-11 13:05:11 +02:00
Gwendal Roué 478ae7bc24 Improve migration guide 2020-04-11 12:43:28 +02:00
Gwendal Roué da81c8b87c Fix typo 2020-04-11 10:33:12 +02:00
Gwendal Roué 4088a477ec Improve migration guide 2020-04-10 20:07:19 +02:00
Gwendal Roué 85dcd32c8d Improve the description of ValueObservation change 2020-04-10 18:52:24 +02:00
Gwendal Roué 62c72c20e9 CHANGELOG 2020-04-10 18:38:16 +02:00
Gwendal Roué 1b4e26f61c Cleanup 2020-04-10 12:35:33 +02:00
Gwendal Roué 474310e00b More inspiration from CocoaError 2020-04-10 09:30:34 +02:00
Gwendal Roué 7a475ad476 Cleanup 2020-04-10 08:58:29 +02:00
Gwendal Roué 65ac210dfb Merge pull request #754 from groue/dev/ResultCode-match
Match DatabaseError on ResultCode
2020-04-09 20:42:23 +02:00
Gwendal Roué f19e5bf67c CHANGELOG 2020-04-09 19:56:12 +02:00
Gwendal Roué 419bedd73b Update documentation for DatabaseError catching 2020-04-09 19:53:21 +02:00
Gwendal Roué 8eb58926a4 Test for ResultCode error matching 2020-04-09 19:53:02 +02:00
Gwendal Roué ccacbc9706 ResultCode match errors 2020-04-09 19:52:39 +02:00
Gwendal Roué 7db59867cb Documentation 2020-04-09 19:08:53 +02:00
Gwendal Roué 37aa7feee9 Rename KeyPathRefining to Refinable 2020-04-09 18:50:36 +02:00
Gwendal Roué e49800d21d Fix build warnings 2020-04-09 17:55:49 +02:00
Gwendal Roué 078aa83e3b Rename count(where:) to countElements(where:) 2020-04-09 17:47:07 +02:00
Gwendal Roué 8ef4c9b241 Remove convenience Result.tryMap 2020-04-09 17:45:12 +02:00
Gwendal Roué f9157da590 TODO 2020-04-09 17:44:41 +02:00
Gwendal Roué 27120643b9 SE-0255: Implicit returns from single-expression functions 2020-04-09 17:16:23 +02:00
Gwendal Roué 306033b63b Update Migration Guide 2020-04-09 13:43:56 +02:00
Gwendal Roué d988be49a6 Revert #748 2020-04-09 13:42:37 +02:00
Gwendal Roué 1a5661c890 Lift resolved attention point about custom SQLite builds 2020-04-09 08:55:40 +02:00
Gwendal Roué ccaad8d860 Restore backward compatibility for setup of custom SQLite builds
User only has to rename the `import` Swift statement
2020-04-09 08:50:24 +02:00
Gwendal Roué c9d95af646 Merge pull request #752 from groue/dev/drop-observation-combination
Remove ValueObservation.combine
2020-04-08 19:55:18 +02:00
Gwendal Roué 3e081f0dd6 Remove GRDBPerformance project from workspace
This avoids painful Xcode management of SPM packages
2020-04-08 19:13:08 +02:00
Gwendal Roué 444525d748 CHANGELOG 2020-04-08 18:54:08 +02:00
Gwendal Roué c778e1ac0c Add fixits 2020-04-08 18:53:08 +02:00
Gwendal Roué bfe037c61d Update documentation 2020-04-08 18:33:56 +02:00
Gwendal Roué e2790c863f Remove ValueObservation combine operator 2020-04-08 18:16:05 +02:00
Gwendal Roué 3c3df9ad24 Miigration Guide WIP 2020-04-08 08:40:54 +02:00
Gwendal Roué 3c30e6d0c1 Miigration Guide WIP 2020-04-08 08:30:10 +02:00
Gwendal Roué a5ad4dd23d Miigration Guide WIP 2020-04-07 22:24:25 +02:00
Gwendal Roué 0505b1cef9 Miigration Guide WIP 2020-04-07 22:20:35 +02:00
Gwendal Roué 2ac6f9766a Miigration Guide WIP 2020-04-07 22:16:44 +02:00
Gwendal Roué 10fcd1092f Miigration Guide WIP 2020-04-07 22:08:17 +02:00
Gwendal Roué cbcbbe9c8f Miigration Guide WIP 2020-04-07 22:04:47 +02:00
Gwendal Roué 2b7b03846e Miigration Guide WIP 2020-04-07 22:00:00 +02:00
Gwendal Roué 05f9854cea Miigration Guide WIP 2020-04-07 20:59:34 +02:00
Gwendal Roué 8cb67f1c22 Miigration Guide WIP 2020-04-07 20:47:56 +02:00
Gwendal Roué 48987f39c3 Miigration Guide WIP 2020-04-07 20:17:11 +02:00
Gwendal Roué e5f711f68c Miigration Guide WIP 2020-04-07 20:01:55 +02:00
Gwendal Roué ac92fc95e3 Merge branch 'development' into GRDB5 2020-04-06 20:16:53 +02:00
Gwendal Roué ed15498871 Merge branch 'master' into development 2020-04-06 20:16:19 +02:00
Gwendal Roué 97a05b97d9 [skip travis] Fix typo 2020-04-06 19:56:32 +02:00
Gwendal Roué 0b69aa82fd [skip travis] Add a Brag Document 2020-04-06 19:54:47 +02:00
Gwendal Roué bf07c49171 Merge pull request #750 from groue/dev/assignment-without-operator
Batch updates do not need any operator
2020-04-05 17:24:09 +02:00
Gwendal Roué c59d42dfca CHANGELOG 2020-04-05 16:43:00 +02:00
Gwendal Roué 80b15f7f07 Ignore GRDB.xcworkspace spm stuff 2020-04-05 16:28:04 +02:00
Gwendal Roué 9647a78ed6 Update documentation 2020-04-05 16:26:29 +02:00
Gwendal Roué 2c743531d0 Operator <- was ill-advised 2020-04-05 16:25:18 +02:00
Gwendal Roué 9e967ccc93 Merge pull request #749 from groue/dev/submodules
Drop submodules used by performance tests
2020-04-05 14:07:49 +02:00
Gwendal Roué 86330000db CHANGELOG 2020-04-05 13:36:41 +02:00
Gwendal Roué af597736f6 Wait before we look into the Xcode checkouts 2020-04-05 13:14:09 +02:00
Gwendal Roué 119ce30ad1 Pin versions GRDBPerformance of dependencies 2020-04-05 12:29:03 +02:00
Gwendal Roué 85c3f12b86 Extract versions of GRDBPerformance dependencies from Xcode SPM checkouts 2020-04-05 11:57:55 +02:00
Gwendal Roué f95e01cbd5 Remove submodule dependencies from Makefile 2020-04-05 10:34:21 +02:00
Gwendal Roué 21eb87fa49 Use SPM for GRDBPerformance dependencies 2020-04-05 10:25:54 +02:00
Gwendal Roué 4614cfda06 Removed test submodules 2020-04-05 09:58:53 +02:00
Gwendal Roué a4bda6da96 Merge pull request #748 from groue/dev/Request
Rename QueryInterfaceRequest to Request
2020-04-04 20:55:18 +02:00
Gwendal Roué 2d2b8494d0 CHANGELOG 2020-04-04 20:13:50 +02:00
Gwendal Roué 7ce6a8a094 Rename QueryInterfaceRequest to Request 2020-04-04 20:12:03 +02:00
Gwendal Roué 3756c43691 Merge pull request #747 from groue/dev/fix-743
Rename GRDBCustomSQLite to GRDB
2020-04-04 18:52:14 +02:00
Gwendal Roué bfc4738097 CHANGELOG 2020-04-04 18:48:35 +02:00
Gwendal Roué afcb9183ad Rename GRDBCustom schemes 2020-04-04 18:37:36 +02:00
Gwendal Roué c3474471f7 Don't include <sqlite3.h> for custom SQLite builds 2020-04-04 18:03:29 +02:00
Gwendal Roué 65c009a018 Rename GRDBCustomSQLite module to GRDB 2020-04-04 17:42:00 +02:00
Gwendal Roué d60fe3c22f Replace import GRDBCustomSQLite with import GRDB 2020-04-04 16:44:01 +02:00
Gwendal Roué 5727163966 SPM: export CSQLite package 2020-04-04 14:20:07 +02:00
Gwendal Roué d72000c6a3 Use scheduling paramater name for consistency with GRDBCombine and RxGRDB 2020-03-31 20:25:36 +02:00
Gwendal Roué 381f716e4b AnyDatabaseCancellable is public
This helps GRDBCombine defaulting to a default cancellable when database connection has been closed before the ValueObservation publisher has been subscribed to.
2020-03-29 20:31:02 +02:00
Gwendal Roué eee2c65c14 Merge branch 'development' into GRDB5
# Conflicts:
#	CHANGELOG.md
#	README.md
2020-03-29 18:55:06 +02:00
Gwendal Roué c01c4d6de5 Looks like jazzy and Xcode 11.4 go well together 2020-03-29 18:49:54 +02:00
Gwendal Roué f4c763dc31 Merge branch 'development' 2020-03-29 17:44:31 +02:00
Gwendal Roué 66989f2ff7 v4.12.1 2020-03-29 17:43:49 +02:00
Gwendal Roué 73aada9194 Merge pull request #745 from groue/dev/ValueObservation-cancellation
Explicit ValueObservation cancellation
2020-03-29 17:30:09 +02:00
Gwendal Roué 5665a2428a CHANGELOG 2020-03-29 16:49:21 +02:00
Gwendal Roué ba0c771346 Merge pull request #744 from groue/dev/fix-741
Fix DatabaseMigrator deadlock with serial target queues
2020-03-29 16:37:55 +02:00
Gwendal Roué 66dc482b02 Don't pretend database deallocation is a cancel event 2020-03-29 16:30:29 +02:00
Gwendal Roué 3c20adb0c6 Add test for explicit cancellation 2020-03-29 16:11:54 +02:00
Gwendal Roué 1bffc4f628 ValueObservation is cancellable 2020-03-29 16:06:24 +02:00
Gwendal Roué 97a84c6470 Fix failing test for #741 2020-03-29 12:09:58 +02:00
Gwendal Roué 70c6f3ec44 Failing test for #741 2020-03-29 12:09:24 +02:00
Gwendal Roué ccd73bf63d Don't parallelize SQLCipher tests 2020-03-29 11:45:52 +02:00
Gwendal Roué d4327faf0a Merge pull request #742 from groue/dev/ValueObservation-scheduling
ValueObservation scheduling is no longer an attribute of the observation
2020-03-29 11:14:48 +02:00
Gwendal Roué 87b54f5da2 Protect ValueObserver state behind a lock 2020-03-29 10:28:37 +02:00
Gwendal Roué a28ae9a523 Stronger tests 2020-03-28 20:50:40 +01:00
Gwendal Roué 055a4882f8 Fix compilation error 2020-03-28 20:14:30 +01:00
Gwendal Roué 90d5316781 Hide ValueObservationScheduler implementation 2020-03-28 19:53:18 +01:00
Gwendal Roué 303a0cc150 immediateInitialValue is a better name 2020-03-28 19:49:07 +01:00
Gwendal Roué 08ef740002 Optimize ValueObservation tests 2020-03-28 19:31:27 +01:00
Gwendal Roué 5d196c449d Value Observation does no longer retain DatabaseWriter 2020-03-28 17:11:57 +01:00
Gwendal Roué fdb2f63e60 Add missing file to iOS/tvOS/watchOS compilation 2020-03-28 14:26:08 +01:00
Gwendal Roué c83d390e60 More test rationalization 2020-03-28 14:07:36 +01:00
Gwendal Roué a6ac69eded Move view optimization test 2020-03-28 13:54:18 +01:00
Gwendal Roué 1914ace5f9 Test as much as possible value observations 2020-03-28 13:43:18 +01:00
Gwendal Roué 88ddce5fac Make sure the observer is cancelled on error 2020-03-28 11:42:53 +01:00
Gwendal Roué 23d428290b Assume that error ends the observation, and have database pool always perform a concurrent initial fetch 2020-03-28 10:30:36 +01:00
Gwendal Roué ff104686f6 Read-only observation: support for cancellation 2020-03-28 07:45:55 +01:00
Gwendal Roué a9ea6dd8bf CHANGELOG 2020-03-27 21:06:13 +01:00
Gwendal Roué 9866ed1dfc Remove useless change 2020-03-27 21:04:23 +01:00
Gwendal Roué 65a347fd98 Fix obsolete comment 2020-03-27 21:03:01 +01:00
Gwendal Roué 7e50869d39 Remove useless change 2020-03-27 21:01:34 +01:00
Gwendal Roué 703ce643b5 Remove useless change 2020-03-27 20:59:38 +01:00
Gwendal Roué 42d2891df8 Fix typo 2020-03-27 20:53:16 +01:00
Gwendal Roué f0effaa4fa Fix typo 2020-03-27 20:51:42 +01:00
Gwendal Roué 022fee8788 Remove dead code 2020-03-27 20:48:12 +01:00
Gwendal Roué 25a2bd653c Fix compiler warning 2020-03-27 20:48:03 +01:00
Gwendal Roué c03de9cc16 Fix documentation 2020-03-27 20:45:24 +01:00
Gwendal Roué 97d06a0fae Fix typo 2020-03-27 20:36:29 +01:00
Gwendal Roué 154125d3ae Update documentation 2020-03-27 20:19:55 +01:00
Gwendal Roué c4b7e0017b The main thread is enough 2020-03-27 20:19:44 +01:00
Gwendal Roué 469814985e Decrease nesting 2020-03-27 19:55:36 +01:00
Gwendal Roué f16105ad03 Add missing cancellation checks 2020-03-27 19:53:01 +01:00
Gwendal Roué 4309eaba64 Scheduling of fresh values is no longer an attribute of ValueObservation 2020-03-27 19:49:11 +01:00
Gwendal Roué 1580be3883 Update tests 2020-03-27 08:27:46 +01:00
Gwendal Roué b4b5d9b602 Simplify ValueObservation scheduling 2020-03-27 08:27:30 +01:00
Gwendal Roué 27dd08f945 Merge pull request #738 from groue/dev/drop-ObservationFor
Remove all observationForCount/All/First methods
2020-03-25 22:53:08 +01:00
Gwendal Roué b9c4d26731 Documentation 2020-03-25 22:36:33 +01:00
Gwendal Roué 7217f696b6 More row comparison technique 2020-03-25 22:23:12 +01:00
Gwendal Roué 880f8c8bdd More row comparison technique 2020-03-25 22:21:52 +01:00
Gwendal Roué 6f7efa2b9a CHANGELOG 2020-03-25 22:08:03 +01:00
Gwendal Roué 3a11d94bee Document the row comparison technique 2020-03-25 22:07:12 +01:00
Gwendal Roué e68bd077ee Remove all observationForCount/All/First methods 2020-03-25 21:44:10 +01:00
Gwendal Roué e84e984c23 Merge pull request #737 from groue/dev/ValueObservation-recording
Force implicit database region for ValueObservation
2020-03-25 19:41:12 +01:00
Gwendal Roué 12de05dc9b ValueObservation.trackingVaryingRegion documentation 2020-03-25 19:19:22 +01:00
Gwendal Roué ea8110110c Remove obsolete documentation 2020-03-25 14:04:42 +01:00
Gwendal Roué 79d6b02a2f Cleanup 2020-03-25 13:57:49 +01:00
Gwendal Roué 1195439226 Cleanup 2020-03-25 13:53:22 +01:00
Gwendal Roué ff2629a31c Cleanup 2020-03-25 13:05:39 +01:00
Gwendal Roué 61e74f9ad4 ValueObservation.trackingVaryingRegion documentation 2020-03-25 08:48:34 +01:00
Gwendal Roué f711978145 Documentation 2020-03-25 08:25:05 +01:00
Gwendal Roué a647e200d9 Replace Never with ValueReducers.Auto 2020-03-25 08:19:47 +01:00
Gwendal Roué 294a04e9f6 Rename tracking(value:) to tracking(_:) 2020-03-25 08:11:43 +01:00
Gwendal Roué 9792edc008 Rename trackingVolatile to trackingVaryingRegion 2020-03-25 00:13:51 +01:00
Gwendal Roué 143f3d1673 CHANGELOG 2020-03-25 00:03:09 +01:00
Gwendal Roué 121f7be847 ValueObservation is now fully based on region recording
And we introduce ValueObservation.trackingVolatile
2020-03-24 23:52:05 +01:00
Gwendal Roué 4af7fda4f2 Fix outdated documentation 2020-03-24 23:49:24 +01:00
Gwendal Roué 56f332122d The observed region is always recorded 2020-03-24 22:59:07 +01:00
Gwendal Roué d494d12293 Fix typo 2020-03-24 22:59:07 +01:00
Gwendal Roué ce6afd680d Merge pull request #736 from groue/dev/relax-ValueObservation
Relax ValueObservation Guarantees
2020-03-24 22:56:16 +01:00
Gwendal Roué dfd5dd2478 Add missing import for SPM 2020-03-24 22:55:18 +01:00
Gwendal Roué 327f07422f Add missing FailableTestCase.swift to custom SQLite tests 2020-03-24 22:35:32 +01:00
Gwendal Roué 6b33e656be CHANGELOG 2020-03-24 17:01:14 +01:00
Gwendal Roué 97a7117564 Rewrite ValueObservation documentation 2020-03-24 16:58:59 +01:00
Gwendal Roué e8fefc82a1 Drop obsolete warning against DatabaseRegionObservation 2020-03-24 16:29:56 +01:00
Gwendal Roué 0963b162e7 Rewrite ValueObservation documentation 2020-03-24 14:57:23 +01:00
Gwendal Roué 5210ae8385 Rewrite ValueObservation documentation 2020-03-24 14:36:29 +01:00
Gwendal Roué 78dc7aee15 Rewrite ValueObservation documentation 2020-03-24 14:35:43 +01:00
Gwendal Roué cf1360701c Rewrite ValueObservation documentation 2020-03-24 14:09:45 +01:00
Gwendal Roué b3fb61858a Rewrite ValueObservation documentation 2020-03-24 13:52:43 +01:00
Gwendal Roué 8d6708a12e Rewrite ValueObservation documentation 2020-03-24 13:49:09 +01:00
Gwendal Roué 06f6b31368 Rewrite ValueObservation documentation 2020-03-24 13:04:25 +01:00
Gwendal Roué 9562e8eac4 Rewrite ValueObservation documentation 2020-03-24 13:01:58 +01:00
Gwendal Roué 1325a3a6a2 Rewrite ValueObservation documentation 2020-03-24 11:47:55 +01:00
Gwendal Roué 89058f4447 Rewrite ValueObservation documentation 2020-03-24 11:39:21 +01:00
Gwendal Roué f6da862145 Rewrite ValueObservation documentation 2020-03-24 08:54:46 +01:00
Gwendal Roué 0c464def7f Fix documentation 2020-03-23 18:00:45 +01:00
Gwendal Roué e824c70e7d Fix SQLCipher tests 2020-03-22 13:46:34 +01:00
Gwendal Roué 7a583e02e8 Refactor ValueObservation tests around a common pattern 2020-03-22 13:31:05 +01:00
Gwendal Roué 98d381ed67 Cleanup 2020-03-22 10:27:10 +01:00
Gwendal Roué e16d29f277 More test refactoring with assertValueObservationRecordingMatch 2020-03-21 18:44:02 +01:00
Gwendal Roué 6bf322f79e More test refactoring with assertValueObservationRecordingMatch 2020-03-21 18:16:35 +01:00
Gwendal Roué c42aab26e3 Remove redundant test 2020-03-21 17:48:24 +01:00
Gwendal Roué e16b320cda More test refactoring with assertValueObservationRecordingMatch 2020-03-21 17:42:22 +01:00
Gwendal Roué 9d4bef1c9a More test refactoring with assertValueObservationRecordingMatch 2020-03-21 17:04:18 +01:00
Gwendal Roué b392458c1c More test refactoring with assertValueObservationRecordingMatch 2020-03-21 16:23:41 +01:00
Gwendal Roué 031b55eca6 More test refactoring with assertValueObservationRecordingMatch 2020-03-21 15:50:36 +01:00
Gwendal Roué 3e0486743b More test refactoring with assertValueObservationRecordingMatch 2020-03-21 15:21:24 +01:00
Gwendal Roué 7ab9a8b29a More test refactoring with assertValueObservationRecordingMatch 2020-03-21 14:36:48 +01:00
Gwendal Roué 22086c088f More test refactoring with assertValueObservationRecordingMatch 2020-03-21 14:36:48 +01:00
Gwendal Roué 3ee231afd3 Cleanup _OptionalProtocol 2020-03-21 14:36:48 +01:00
Gwendal Roué 4ffced0b7b assertValueObservationRecordingMatch 2020-03-21 14:36:48 +01:00
Gwendal Roué ed6673f2f5 ValueObservation test refactoring WIP 2020-03-21 14:36:48 +01:00
Gwendal Roué 7935168379 ValueObservation test refactoring WIP 2020-03-21 14:36:48 +01:00
Gwendal Roué 3c891b7ebd ValueObservationRecorder cleanup 2020-03-21 14:36:48 +01:00
Gwendal Roué 8f5c7985e5 ValueObservationRecorder 2020-03-21 14:36:48 +01:00
Gwendal Roué 2150b6688a Fix ValueObserver cancellation 2020-03-21 14:36:48 +01:00
Gwendal Roué 65b8fbb361 Remove useless print() statements 2020-03-21 14:36:48 +01:00
Gwendal Roué 2bb894108c Use the prependingConcurrentFetch flag 2020-03-21 14:36:48 +01:00
Gwendal Roué 26d2245ae8 Asynchronouslu remove observer when it is cancelled 2020-03-21 14:36:48 +01:00
Gwendal Roué 2b78a646ed Mor preparation for initiial concurrent fetch of ValueObservation in a DatabasePool 2020-03-21 14:36:48 +01:00
Gwendal Roué 1c59278115 Prefer dbResult argument name for async read closures 2020-03-21 14:36:48 +01:00
Gwendal Roué 2824636650 Prepare for initiial concurrent fetch of ValueObservation in a DatabasePool 2020-03-21 14:36:48 +01:00
Gwendal Roué 5a884ad93d Common ValueObservation code for all read-only database accessors 2020-03-21 14:36:48 +01:00
Gwendal Roué dab8e28f6d Merge branch 'master' into GRDB5
# Conflicts:
#	GRDB/Migration/DatabaseMigrator.swift
#	GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
#	README.md
2020-03-21 14:35:57 +01:00
Gwendal Roué e831c64e93 Merge branch 'development' 2020-03-21 12:54:52 +01:00
Gwendal Roué 50f64dc45d v4.12.0 2020-03-21 12:54:30 +01:00
Gwendal Roué 24872373c4 TODO 2020-03-21 12:26:35 +01:00
Gwendal Roué f04efea09c CHANGELOG 2020-03-18 20:47:04 +01:00
Gwendal Roué cda254bb2d Update documentation for eraseDatabaseOnSchemaChange 2020-03-18 20:43:09 +01:00
Gwendal Roué c1d1797576 Address #725 2020-03-18 20:36:56 +01:00
Gwendal Roué a0faf6aa68 Support for nil assignment 2020-03-18 19:34:43 +01:00
Gwendal Roué c6db8962b3 Merge pull request #732 from groue/dev/ValueObservation-mandatory-first-element
Remove ValueObservation.compactMap
2020-03-12 08:37:16 +01:00
Gwendal Roué 5a9085c34d CHANGELOG 2020-03-12 07:46:04 +01:00
Gwendal Roué c698b30c0a Add fixits 2020-03-12 07:43:57 +01:00
Gwendal Roué dfa40ea18f Rename ValueObservation.fetchFirst to fetchValue
"First", in Swift, hints that the result is optional. But the result of this function is no longer optional.
2020-03-12 07:34:43 +01:00
Gwendal Roué 936c92eba6 All value reducers must emit an initial value
This disqualifies compactMap as a valid ValueObservation transformation: it has been removed.

This simplifies implementation as well.
2020-03-12 07:18:40 +01:00
Gwendal Roué b0155b8aca Merge branch 'development' into GRDB5 2020-03-11 22:44:20 +01:00
Gwendal Roué 84eef52cb0 Merge branch 'master' into development 2020-03-11 22:44:05 +01:00
Gwendal Roué 46fba47efb Merge pull request #731 from groue/dev/private-ValueReducer
Hide ValueObservation implementation details
2020-03-11 22:43:10 +01:00
Gwendal Roué bf3f97b64d Fix compiler warning 2020-03-11 22:42:48 +01:00
Gwendal Roué b605076bd0 Remove value reducers from README 2020-03-11 22:15:04 +01:00
Gwendal Roué 329b034423 CHANGELOG 2020-03-11 22:13:51 +01:00
Gwendal Roué 5e0535d511 ValueReducer creation does not need database access 2020-03-11 22:00:07 +01:00
Gwendal Roué b96d71d937 Remove public ValueObservation factory methods that accept a _ValueReducer 2020-03-11 21:38:48 +01:00
Gwendal Roué 28c32c6af8 _ValueReducer is the only protocol accepted by ValueObservation
Also, we now use Never as the bottom reducer which helps us define the ValueObservation factory methods.
2020-03-11 21:38:41 +01:00
Gwendal Roué f80c5ce348 Make the ValueReducer protocol unavailable
# Conflicts:
#	GRDB/ValueObservation/ValueReducer/ValueReducer.swift
2020-03-11 21:38:20 +01:00
Gwendal Roué 6a582869c6 Merge pull request #730 from jackalcooper/patch-1
fix typo
2020-03-11 12:45:58 +01:00
Shenghang Tsai 813f28e5da fix typo 2020-03-11 19:35:48 +08:00
Gwendal Roué cc16a00f5a Merge pull request #729 from groue/dev/ValueObservation-initial-value
ValueObservation always emits an initial value
2020-03-10 23:03:39 +01:00
Gwendal Roué 4f74997235 Restore old disabled tests for cancelled ValueObservation 2020-03-10 22:06:41 +01:00
Gwendal Roué 2f4187b084 DatabaseWriter.remove(transactionObserver:) can run from the writer queue 2020-03-10 22:06:08 +01:00
Gwendal Roué 9a6d6cf9c0 Update documentation for ValueObservation scheduling 2020-03-10 22:04:58 +01:00
Gwendal Roué 26e2db02aa CHANGELOG 2020-03-10 21:04:38 +01:00
Gwendal Roué d66f2c8cfd Simplify ValueObservation starting process 2020-03-10 20:50:06 +01:00
Gwendal Roué 6f239a5ad3 All ValueObservationScheduling cases now trigger an initial fetch 2020-03-10 19:42:58 +01:00
Gwendal Roué 2224042114 Rename ValueScheduling to ValueObservationScheduling 2020-03-10 19:10:38 +01:00
Gwendal Roué 4fe201f8aa Merge branch 'development' into GRDB5 2020-03-10 19:05:29 +01:00
Gwendal Roué 3973b66ab3 Fix and test throwingFirstError 2020-03-10 09:16:24 +01:00
Gwendal Roué e48b654ad6 Merge pull request #728 from groue/dev/ValueObservation-error-handling
Make ValueObservation error handling mandatory
2020-03-10 08:26:09 +01:00
Gwendal Roué 3467376d7a Remove unused ErrorCatcher 2020-03-10 08:19:27 +01:00
Gwendal Roué 1b6f9f9971 CHANGELOG 2020-03-10 08:12:17 +01:00
Gwendal Roué c70b627f92 ValueObservation.start(in:onChange:) is unavailable
Hiding errors from user's sight was not a good idea
2020-03-10 08:09:53 +01:00
Gwendal Roué 435f5ff559 TODO: fix throwingFirstError 2020-03-10 07:41:15 +01:00
Gwendal Roué 0b34ad55b6 Merge pull request #724 from groue/dev/SE-0242
SE-0242: Synthesize default values for the memberwise initializer
2020-03-09 09:02:03 +01:00
Gwendal Roué 262cdc5b9a CHANGELOG 2020-03-09 08:50:43 +01:00
Gwendal Roué 19061934ce SE-0242: Synthesize default values for the memberwise initializer
...and more initializers cleanup
2020-03-09 08:49:06 +01:00
Gwendal Roué 7614f36bbd Merge pull request #723 from groue/dev/SE-0255
SE-0255: Implicit returns from single-expression functions
2020-03-09 08:17:24 +01:00
Gwendal Roué f48180549d make smokeTest
For "quick" sanity checks
2020-03-09 08:03:26 +01:00
Gwendal Roué 93aa9bf3e5 Comment out debugging configuration 2020-03-09 07:56:02 +01:00
Gwendal Roué 4d60dc6cbb Remove more redundant return keywords 2020-03-09 07:52:35 +01:00
Gwendal Roué 1698afadb9 CHANGELOG 2020-03-09 07:33:30 +01:00
Gwendal Roué 9aa67f9db9 SE-0255: Implicit returns from single-expression functions 2020-03-08 23:12:46 +01:00
Gwendal Roué 57d12e6c47 Merge pull request #722 from groue/dev/SE-0253
SE-0253: Callable values of user-defined nominal types
2020-03-08 20:40:17 +01:00
Gwendal Roué cc9fbed07e CHANGELOG 2020-03-08 20:39:54 +01:00
Gwendal Roué 8718d525d4 SE-0253: Callable values of user-defined nominal types 2020-03-08 20:36:49 +01:00
Gwendal Roué 3beba2b578 Merge pull request #721 from groue/dev/SE-0249
SE-0249: Key Path Expressions as Functions
2020-03-08 20:10:27 +01:00
Gwendal Roué 1b08a822ee CHANGELOG 2020-03-08 20:09:15 +01:00
Gwendal Roué 7865b0a2ee SE-0249: Key Path Expressions as Functions 2020-03-08 19:58:51 +01:00
Gwendal Roué a31984724e Merge pull request #720 from groue/dev/GRDB5-removeDeprecated
Turn deprecated APIs into unavailable ones
2020-03-08 19:15:41 +01:00
Gwendal Roué a504452846 CHANGELOG 2020-03-08 19:10:48 +01:00
Gwendal Roué 00b0dc2a04 Remove availability checks for macOS 10.10 (forgotten in #719) 2020-03-08 19:08:15 +01:00
Gwendal Roué 41e0885bce Fix deprecation warning 2020-03-08 18:10:02 +01:00
Gwendal Roué 694adcec64 Remove other deprecated methods 2020-03-08 18:03:11 +01:00
Gwendal Roué 5dd86d2453 Remove deprecated ValueObservation methods 2020-03-08 17:53:39 +01:00
Gwendal Roué b9d4a5215a Remove deprecated DatabaseMigrator methods 2020-03-08 17:13:31 +01:00
Gwendal Roué 456d2aee75 Remove deprecated SQLExpressionLiteral 2020-03-08 16:57:29 +01:00
Gwendal Roué 02890a6d3a Remove deprecated SQLLiteral.mapSQL(_:) 2020-03-08 16:28:44 +01:00
Gwendal Roué 0f503fe0db Remove deprecated FetchRequest.prepare(_: forSingleResult:) 2020-03-08 16:18:55 +01:00
Gwendal Roué bfdd0696da Remove deprecated setupMemoryManagement methods 2020-03-08 16:08:12 +01:00
Gwendal Roué 130e510f8c Remove deprecated passphrase methods 2020-03-08 16:00:19 +01:00
Gwendal Roué 512764403f Prepare for fixits for removed deprecated methods 2020-03-08 15:39:40 +01:00
Gwendal Roué b85eca3260 Merge pull request #719 from groue/dev/swift5.2
Bump required Swift version to 5.2
2020-03-08 14:59:53 +01:00
Gwendal Roué 73975e4462 CHANGELOG 2020-03-08 14:53:35 +01:00
Gwendal Roué 816887b811 Fix typo in README 2020-03-08 14:53:27 +01:00
Gwendal Roué 20baaf9a7f Update README for the new requirements 2020-03-08 13:54:00 +01:00
Gwendal Roué 9578f984ec Remove useless #if compiler/swift checks 2020-03-08 13:42:44 +01:00
Gwendal Roué 3b7f232aef WIP 2020-03-08 13:01:15 +01:00
Gwendal Roué df1ed3cf2f Apply requirements to .travis.yml
osx_image xcode11.4 is not yet shipped, according to https://docs.travis-ci.com/user/reference/osx/#xcode-version
2020-03-08 12:59:33 +01:00
Gwendal Roué 59eceb9af1 Apply requirements to Makefile 2020-03-08 12:57:09 +01:00
Gwendal Roué d7e821785d Fix podfiles of CocoaPods tests 2020-03-08 12:35:59 +01:00
Gwendal Roué b264087a3b Fixes for GRDBDemoWatchOS
Hide WKRefreshBackgroundTask use behind an availability check

Bump IPHONEOS_DEPLOYMENT_TARGET = 13.0, so that we can use CollectionDifference
2020-03-08 12:22:09 +01:00
Gwendal Roué 759bb8cd25 Fix dependencies of GRDBtvOSTests
It used to depend on the iOS version of GRDB - WTF
2020-03-08 11:28:04 +01:00
Gwendal Roué 4486f73432 Apply requirements to podspec and podfiles 2020-03-08 10:55:48 +01:00
Gwendal Roué 224e0b7d58 Apply requirements to Xcode projects
Update:
SWIFT_VERSION
IPHONEOS_DEPLOYMENT_TARGET
MACOSX_DEPLOYMENT_TARGET
TVOS_DEPLOYMENT_TARGET
WATCHOS_DEPLOYMENT_TARGET
2020-03-08 10:55:26 +01:00
Gwendal Roué 9db86ff2d6 Apply Swift version requirement to Tests/SPM/PlainPackage 2020-03-08 10:45:40 +01:00
Gwendal Roué f3af89cb6a Apply requirements to Package.swift 2020-03-08 10:26:01 +01:00
Gwendal Roué 98e9cc7861 Bump required macOS version to 10.10
This guarantees SQLite 3.7.16+, so that all migrations can recreate tables when needed
2020-03-08 10:24:27 +01:00
Gwendal Roué 30f7b39a42 Update requirements for Swift 5.2 2020-03-08 09:54:13 +01:00
Gwendal Roué 6b9e7e7eb3 Kick off GRDB5 2020-03-08 09:50:08 +01:00
Gwendal Roué f6e6758525 Merge branch 'master' into development 2020-03-07 15:13:33 +01:00
Gwendal Roué 039dd37759 [skip travis] Enhancements to WhyAdoptGRDB.md 2020-03-07 15:13:14 +01:00
Gwendal Roué e9dd8b2b09 Enhance DatabaseMigrator querying methods
// New
dbQueue.read(migrator.hasCompletedMigrations)
dbQueue.read(migrator.completedMigrations).contains("v2")
dbQueue.read(migrator.completedMigrations).last == "v2"
dbQueue.read(migrator.appliedMigrations)

// Deprecated
migrator.hasCompletedMigrations(in: dbQueue)
migrator.hasCompletedMigrations(in: dbQueue, through: "v2")
migrator.lastCompletedMigration(in: dbQueue) == "v2"
migrator.appliedMigrations(in: dbQueue)
2020-03-07 13:59:46 +01:00
Gwendal Roué ee64f8ff9d Rename statement argument methods 2020-03-04 08:43:31 +01:00
Gwendal Roué db546bf478 Merge branch 'development' 2020-03-02 08:01:55 +01:00
Gwendal Roué 5a7c6fb33f v4.11.0 2020-03-02 07:59:48 +01:00
Gwendal Roué fa7ae31894 TODO 2020-03-02 07:53:25 +01:00
Gwendal Roué 48097ba7e7 Update thank you notice 2020-03-01 18:42:05 +01:00
Gwendal Roué 7c684d06c1 Simplify schema cache management
We don't need EmptyDatabaseSchemaCache. It does not help unsafe reads to work better if concurrent writes modify the schema anyway.
2020-03-01 15:51:37 +01:00
Gwendal Roué c8321201d8 Merge pull request #713 from groue/dev/barrierMigrations
Enhance DatabaseMigrator isolation
2020-03-01 15:41:27 +01:00
Gwendal Roué ea421865aa Improve barrierWriteWithoutTransaction documentation 2020-03-01 11:34:58 +01:00
Gwendal Roué f5019eeb60 Merge branch 'development' into dev/barrierMigrations
# Conflicts:
#	GRDB/Migration/DatabaseMigrator.swift
2020-03-01 09:13:45 +01:00
Gwendal Roué 62222f441d Merge pull request #710 from groue/dev/unappliedMigrations
Check if all migrations have been applied
2020-03-01 09:00:20 +01:00
Gwendal Roué 0e43f1b95a appliedIdentifiers always filters out unknown migrations 2020-03-01 08:58:50 +01:00
Gwendal Roué 50cd4418d2 CHANGELOG 2020-02-29 17:32:15 +01:00
Gwendal Roué e1b14d4ee5 DatabaseMigrator uses barrierWriteWithoutTransaction
This prevents concurrent reads from reading right in between two migration transactions
2020-02-29 17:26:59 +01:00
Gwendal Roué ce0df653f4 Expose Database.erase() 2020-02-29 17:19:08 +01:00
Gwendal Roué 11f8807545 Make barrierWriteWithoutTransaction a requirement of DatabaseWriter 2020-02-29 16:01:45 +01:00
Gwendal Roué 7af846c87f Rename new DatabaseMigrator methods 2020-02-29 15:07:36 +01:00
Gwendal Roué 9f46f34d16 Merge branch 'development' into dev/unappliedMigrations
# Conflicts:
#	CHANGELOG.md
2020-02-29 14:46:50 +01:00
Gwendal Roué e62df26a53 Disable flaky testDatabasePoolReleaseMemoryClosesReaderConnections
See https://github.com/groue/GRDB.swift/issues/489
2020-02-29 14:45:06 +01:00
Gwendal Roué b71de1559a Disable flaky testCachedStatementsAreNotShared
See https://github.com/groue/GRDB.swift/issues/679
2020-02-29 14:43:17 +01:00
Gwendal Roué c2c587752c Disable flaky testBusyModeTimeoutTooShort
It just ruins Travis builds :-(
2020-02-29 14:41:46 +01:00
Gwendal Roué fd029ff230 Merge pull request #712 from pakko972/automatic-ios-memory-management
Automatic ios memory management
2020-02-29 14:38:00 +01:00
Gwendal Roué c534193f5c CHANGELOG 2020-02-29 14:36:07 +01:00
Gwendal Roué 7b29156664 Fix typo and improve wording 2020-02-29 14:33:02 +01:00
Gwendal Roué 9ed8cb3eff Fix Swiftlint warnings 2020-02-29 14:30:05 +01:00
Gwendal Roué a7d02b90a5 Update license year 2020-02-29 14:09:29 +01:00
Gwendal Roué 522639282d Update JSONSynchronization playground 2020-02-29 14:03:12 +01:00
Pakkito eb98f50891 Avoid breaking changes
- Deprecate setupMemoryManagement(application:)
- UIApplication is not available on watchOS, so instead of checking against `#if canImport(UIKit)` we use `#if os(iOS)`

Signed-off-by: Pakkito <pe@pierlis.com>
2020-02-28 18:00:16 +01:00
Pakkito f07735f05f Add support for xcode 11.4
Signed-off-by: Pakkito <pe@pierlis.com>
2020-02-28 17:21:53 +01:00
Pakkito 32675b38f1 Automatically setup memory management when UIKit is available
Signed-off-by: Pakkito <pe@pierlis.com>
2020-02-28 17:21:27 +01:00
Gwendal Roué d35d6fc2f8 Rename isMigrated(in:upTo:) to isMigrated(in:beyond:), introduce lastAppliedMigration(in:) 2020-02-28 14:27:52 +01:00
Gwendal Roué fa26faa6fd CHANGELOG 2020-02-28 07:42:38 +01:00
Gwendal Roué 91a3557281 Rename hasUnappliedMigrations to isMigrated 2020-02-28 07:40:19 +01:00
Gwendal Roué f09e0b5ed2 CHANGELOG 2020-02-27 21:19:57 +01:00
Gwendal Roué 0580705b1e Enhance App Group Container documentation with database schema check 2020-02-27 21:10:35 +01:00
Gwendal Roué 0c7e14eb9b Documentation for DatabaseMigrator.hasUnappliedMigrations 2020-02-27 21:02:17 +01:00
Gwendal Roué 92e8ef9b87 More DatabaseMigrator tests 2020-02-27 21:01:56 +01:00
Gwendal Roué 692af926be Tests for DatabaseMigrator.hasUnappliedMigrations 2020-02-27 20:51:44 +01:00
Gwendal Roué a17669b082 DatabaseMigrator.hasUnappliedMigrations 2020-02-27 20:50:25 +01:00
Gwendal Roué 2ff8c66b9e TODO 2020-02-27 19:29:21 +01:00
Gwendal Roué be53b0d403 Merge pull request #709 from groue/dev/migration
Simplify DatabaseMigrator API
2020-02-27 19:28:12 +01:00
Gwendal Roué ba02ba4237 CHANGELOG 2020-02-27 19:25:55 +01:00
Gwendal Roué 0d2ede4440 Document that migrations run with deferred foreign key checks 2020-02-27 08:43:51 +01:00
Gwendal Roué bf89883ff5 Import SQLite C functions for SPM 2020-02-26 22:26:29 +01:00
Gwendal Roué efcc3a3dfb Merge branch 'development' into dev/migration
# Conflicts:
#	CHANGELOG.md
2020-02-26 19:31:38 +01:00
Gwendal Roué fefeb1e9e2 Merge pull request #706 from groue/dev/690-improvement
Enhance SQLLiteral and SQL interpolation again
2020-02-26 19:28:39 +01:00
Gwendal Roué f12436e55b CHANGELOG 2020-02-26 14:09:24 +01:00
Gwendal Roué 98c4356638 Cleanup 2020-02-26 14:07:38 +01:00
Gwendal Roué e5c4fb7e30 Update DatabaseMigrator documentation 2020-02-26 13:59:04 +01:00
Gwendal Roué 4f9878a1da Update tests for the deprecated registerMigrationWithDeferredForeignKeyCheck method 2020-02-26 13:57:49 +01:00
Gwendal Roué 8557d113a3 Deprecate registerMigrationWithDeferredForeignKeyCheck
This method is now equivalent to registerMigration, starting SQLite 3.7.16
2020-02-26 13:57:14 +01:00
Gwendal Roué 9400e7f5d5 Fix tests for Xcode 10.3 2020-02-26 08:17:48 +01:00
Gwendal Roué 193509db58 Merge pull request #707 from haikusw/pr_docs_typos_fixes
Docs: Fix a collection of typos
2020-02-26 08:05:22 +01:00
Tyler Morrison d7ce175b8e Documentation: Fixes for some typos 2020-02-25 14:43:39 -08:00
Gwendal Roué 0a8001a128 CHANGELOG 2020-02-25 22:25:36 +01:00
Gwendal Roué b46a8c897a Update SQLLiteral documentation 2020-02-25 22:21:32 +01:00
Gwendal Roué bad8d85729 Add test for legacy literal expression function 2020-02-25 22:18:16 +01:00
Gwendal Roué eb6f6e57ff Fix failing test for literal expression function 2020-02-25 22:13:17 +01:00
Gwendal Roué cc495e3fd5 Failing test for literal expression function 2020-02-25 22:11:18 +01:00
Gwendal Roué d190a26737 More precise documentation vocabulary 2020-02-25 15:05:11 +01:00
Gwendal Roué 7ee4e269c3 Fix sample code 2020-02-25 15:02:18 +01:00
Gwendal Roué f7465896fa Enhance documentation for features brought by #690 2020-02-25 14:59:11 +01:00
Gwendal Roué 4c8574aa4c Merge branch 'development' 2020-02-23 14:09:57 +01:00
Gwendal Roué 7475c25fa7 v4.10.0 2020-02-23 13:17:32 +01:00
Gwendal Roué 3379bf3b08 Merge pull request #690 from groue/dev/qualifiedSQLLiteral
Enhance SQLLiteral and SQL interpolation
2020-02-15 09:34:23 +01:00
Gwendal Roué 7af3f48150 TODO 2020-02-15 07:04:50 +01:00
Gwendal Roué 1b8511ab51 Documentation 2020-02-14 12:59:06 +01:00
Gwendal Roué 355ae49bc2 CHANGELOG 2020-02-14 12:46:01 +01:00
Gwendal Roué 8c3274bd3c Cleanup 2020-02-14 12:36:36 +01:00
Gwendal Roué 591384576f SQLOrderingLiteral (and prevent reversing of requests ordered by literal) 2020-02-14 12:31:54 +01:00
Gwendal Roué cdda2852d3 Merge branch 'development' into dev/qualifiedSQLLiteral 2020-02-14 11:43:15 +01:00
Gwendal Roué 03992ab45c CHANGELOG 2020-02-14 11:41:37 +01:00
Gwendal Roué 1f4b374bce Documentation for #689 2020-02-14 11:40:17 +01:00
Gwendal Roué a5b2757128 Merge pull request #689 from groue/rename-column
Add support for renaming columns within a table
2020-02-14 11:25:42 +01:00
Gwendal Roué b961962f93 Cleanup 2020-01-25 16:29:04 +01:00
Gwendal Roué c64b2d1032 Cleanup 2020-01-25 16:18:12 +01:00
Gwendal Roué 3ccfcb61ce Cleanup SQLLiteral elements 2020-01-25 16:11:17 +01:00
Gwendal Roué e4c6029e72 Cleanup internal APIs 2020-01-25 14:37:32 +01:00
Gwendal Roué d448bd8bd5 Test SQLLiteral.mapSQL qualification 2020-01-25 14:32:13 +01:00
Gwendal Roué e999ab5ecb Don't deprecate SQLLiteral.mapSQL, after all 2020-01-25 13:46:00 +01:00
Gwendal Roué db8585aa85 Test for SQLLiteral(expression) 2020-01-25 12:34:22 +01:00
Gwendal Roué e2545b3427 Test for more complex SQLLiteral generation 2020-01-25 12:15:14 +01:00
gjeck 38a161f92b Fix imports for SPM tests 2020-01-24 10:53:34 -08:00
gjeck d14ac3e8d3 Resolve test issues with SQLCipher
Note: SQLCipher3 will have the new column rename method exposed, but it
will throw an error at runtime if used.
2020-01-24 09:22:43 -08:00
gjeck 09087bdbf9 Adjust available checks 2020-01-24 08:46:55 -08:00
gjeck 538252a4bf Allow column rename on custom sqlite target 2020-01-24 08:46:55 -08:00
gjeck 371e8f0dbe Add support for renaming columns within a table
SQLite introduced enhancements to the `ALTER TABLE` command in 3.25.0.
iOS 13.0+, macOS 10.15+, tvOS 13.0+, and watchOS 6.0+ have a SQLite
library bundled higher than 3.25.0.

For more information see https://www.sqlite.org/lang_altertable.html
2020-01-24 08:46:55 -08:00
Gwendal Roué b8c5af5cef Fix availability test 2020-01-24 09:03:06 +01:00
Gwendal Roué ddd22a1dfb Restore Swift 4.2 by default 2020-01-24 09:00:51 +01:00
Gwendal Roué 2d3a9991d4 Test documented use case 2020-01-24 08:55:55 +01:00
Gwendal Roué 7f513cbc1d SQLLiteral cleanup 2020-01-24 08:55:55 +01:00
Gwendal Roué 812f30fb75 Remove SQLLiteral.generate() 2020-01-24 08:55:55 +01:00
Gwendal Roué 86e32cdc23 Cleanup SQLGenerationContext 2020-01-24 08:55:55 +01:00
Gwendal Roué 554cbaa307 Stop using SQLExpression.sqlLiteral 2020-01-24 08:55:55 +01:00
Gwendal Roué 6a0cc838da Deprecate SQLLiteral.mapSQL and SQLExpression.sqlLiteral 2020-01-24 08:55:55 +01:00
Gwendal Roué 4811bc3c5b Test SQLLiteral qualification 2020-01-24 08:55:55 +01:00
Gwendal Roué 65c94590eb Make SQLLiteral able to be qualified with a table alias 2020-01-24 08:55:55 +01:00
Gwendal Roué 5e67ca5566 Deprecate SQLExpressionLiteral, hide SQLSelectionLiteral, introduce SQLLiteral.sqlExpression and .sqlSelectable 2020-01-24 08:55:55 +01:00
Gwendal Roué d7ef314a15 SQLLiteral is now a promise that needs an SQLGenerationContext 2020-01-24 08:55:55 +01:00
Gwendal Roué a3c43efb85 Fix KeyPathRefining for Xcode 10.0 2020-01-24 07:50:12 +01:00
Gwendal Roué 9dcd0b8f42 Fix KeyPathRefining for compiler(<5.1) 2020-01-24 07:45:20 +01:00
Gwendal Roué 349e34b1c1 Internal API experiment: KeyPathRefining 2020-01-21 19:37:19 +01:00
Gwendal Roué 66bce33a36 SPM installation technique: warn against #642 2020-01-19 12:27:30 +01:00
Gwendal Roué f67232b80f Merge branch 'development' 2020-01-17 07:41:27 +01:00
Gwendal Roué 6b32c3aeec v4.9.0 2020-01-17 07:40:42 +01:00
Gwendal Roué f3bc08160d Merge pull request #683 from groue/dev/concat
String concatenation
2020-01-17 07:34:44 +01:00
Gwendal Roué 1cca8a2303 Merge branch 'development' into dev/concat
# Conflicts:
#	CHANGELOG.md
2020-01-16 20:04:38 +01:00
Gwendal Roué ac215430c2 CHANGELOG and thank you notice 2020-01-16 19:48:29 +01:00
Gwendal Roué 7f8a088306 Merge pull request #685 from gjeck/defaultDatabaseTableName
Add cache for TableRecord.defaultDatabaseTableName
2020-01-16 19:42:12 +01:00
gjeck 2717b52e97 Add cache for TableRecord.defaultDatabaseTableName
Resolves cpu/memory impact from repeated calls by cacheing the name in a
private global NSCache.
2020-01-16 09:59:18 -08:00
Gwendal Roué 25cf030498 CHANGELOG 2020-01-16 18:51:47 +01:00
Gwendal Roué 4bfab90750 Restore and deprecate SQLLogicalBinaryOperator 2020-01-16 18:50:48 +01:00
Gwendal Roué 95ddae7968 More tests for associative operators 2020-01-16 09:08:30 +01:00
Gwendal Roué 62fad30af5 Documentation associative operator joining for add and multiply operations 2020-01-16 08:57:07 +01:00
Gwendal Roué c9373929ca Documentation for the || string concatenation operator 2020-01-16 08:50:40 +01:00
Gwendal Roué 01b47a833a Introduce the || string concatenation operator 2020-01-16 08:38:17 +01:00
Gwendal Roué a398c6dc99 Flattten stricly associative operators 2020-01-16 08:17:11 +01:00
Gwendal Roué 32a40b18fd Introduce associative binary operators 2020-01-16 08:01:48 +01:00
Gwendal Roué c7fcde83cf Merge branch 'development' 2020-01-12 12:53:40 +01:00
Gwendal Roué a9cd4faff0 v4.8.1 2020-01-12 12:53:18 +01:00
Gwendal Roué ddccbaacdb Merge pull request #677 from groue/dev/fixAssociationFiltering
Fix associations altered by another association
2020-01-12 09:52:51 +01:00
Gwendal Roué 6a7ecb2c63 CHANGELOG 2020-01-11 20:43:43 +01:00
Gwendal Roué 0b07a6a696 Cleanup 2020-01-11 20:43:37 +01:00
Gwendal Roué 58a36ec509 Add including(all:) test fixed by ebdfa9e52a 2020-01-11 19:00:57 +01:00
Gwendal Roué ebdfa9e52a Fix failiing tests for children relations 2020-01-11 18:36:36 +01:00
Gwendal Roué 4c145b11a5 OrderedDictionary.filter(_:) 2020-01-11 18:12:30 +01:00
Gwendal Roué c14739cb4a Failiing tests for children relations 2020-01-11 18:11:05 +01:00
Gwendal Roué 5b841cf4cb Cleanup 2020-01-09 08:24:00 +01:00
Gwendal Roué 8fa17c578c Fix typo 2020-01-08 08:46:17 +01:00
Gwendal Roué 183612a4e3 Merge branch 'development' 2020-01-08 08:25:30 +01:00
Gwendal Roué e3fbfe6541 v4.8.0 2020-01-08 07:49:12 +01:00
Gwendal Roué 69b9d04aad Less TODO 2020-01-07 08:01:25 +01:00
Gwendal Roué ffd1222990 Fix comment 2020-01-06 09:14:57 +01:00
Gwendal Roué 07266d0b31 Remove useless captures 2020-01-06 09:12:55 +01:00
Gwendal Roué eb8ec327a8 Cleanup 2020-01-06 09:09:27 +01:00
Gwendal Roué f79b60083e Remove TODO and document why 2020-01-06 08:36:53 +01:00
Gwendal Roué fc50302e14 Remove unwise TODO 2020-01-06 08:14:46 +01:00
Gwendal Roué 4896741706 Remove code smell 2020-01-06 08:13:32 +01:00
Gwendal Roué fd7783c39d Fix uses of throwingFirstError(execute:finally:) 2020-01-06 08:12:49 +01:00
Gwendal Roué c60a945610 Fix SQL 2020-01-05 20:36:49 +01:00
Gwendal Roué ef9bab627d Fix markdown 2020-01-05 14:28:41 +01:00
Gwendal Roué 9ca2a2e782 Add context to the "Refining Association Requests" chapter 2020-01-05 14:27:17 +01:00
Gwendal Roué 3613b6ed45 Add missing documentation for annotated(with: expression) 2020-01-05 13:56:25 +01:00
Gwendal Roué adc7079943 Cleanup 2020-01-05 13:55:10 +01:00
Gwendal Roué cd8fbbe8f2 Add a test for foreign column annotation 2020-01-05 13:45:23 +01:00
Gwendal Roué e5726f3993 throwingFirstError(execute:finally:) 2020-01-05 13:30:12 +01:00
Gwendal Roué 14c3c7865e Move association initialization where they belong 2020-01-03 08:27:15 +01:00
Gwendal Roué 9dd5fd198b Fix documentation bug - #672 2020-01-03 08:09:54 +01:00
Gwendal Roué 2595729c8c Documentation 2020-01-03 08:04:22 +01:00
Gwendal Roué 6b6a422ead Travis: only build master and development branches 2019-12-30 18:26:17 +01:00
Gwendal Roué 72a4e2073f Update make doc so that it works with Xcode 11 2019-12-30 18:23:26 +01:00
Gwendal Roué 1fa93abb5b Merge pull request #676 from groue/dev/moreDeleteAndUpdate
More batch delete and update
2019-12-30 13:37:44 +01:00
Gwendal Roué 81c763750f CHANGELOG 2019-12-29 19:14:28 +01:00
Gwendal Roué 944f4309a8 Cleanup 2019-12-29 19:06:29 +01:00
Gwendal Roué b302051f87 Cleanup 2019-12-29 18:46:06 +01:00
Gwendal Roué 070f85b541 More tests for batch update and delete 2019-12-29 18:26:47 +01:00
Gwendal Roué 71d97b04a5 Move code 2019-12-29 18:26:27 +01:00
Gwendal Roué b1edf78f13 Add missing reference to updateAll 2019-12-29 18:26:05 +01:00
Gwendal Roué fa5198354a Fix failing tests for deleteAll and updateAll for grouped and joined queries 2019-12-29 17:50:53 +01:00
Gwendal Roué e8803804ec Failing tests for deleteAll and updateAll for grouped and joined queries 2019-12-29 17:50:47 +01:00
Gwendal Roué baa9695678 SQLQueryGenerator.grouping(_:) 2019-12-29 17:18:17 +01:00
Gwendal Roué a42a5cc2ca SQLQualifiedRelation.selectOnly(_:) 2019-12-29 16:57:26 +01:00
Gwendal Roué db7edd389f rowid is a unique key 2019-12-29 16:40:57 +01:00
Gwendal Roué 985794e733 Merge pull request #670 from groue/development
GRDB 4.7.0
2019-12-18 08:01:17 +01:00
Gwendal Roué 5d0e37e2cc v4.7.0 2019-12-17 18:59:12 +01:00
Gwendal Roué e69fb4a0db Remove unused code 2019-12-17 18:58:51 +01:00
Gwendal Roué 8512607fb6 Merge pull request #668 from groue/dev/suspend
Database Suspension
2019-12-15 18:18:58 +01:00
Gwendal Roué 299bfef7b5 Busy timeouts are really weird 2019-12-15 13:17:47 +01:00
Gwendal Roué a7f99b83f9 fix busy timeout tests on macOS 2019-12-15 10:54:13 +01:00
Gwendal Roué e7f1153c85 [skip travis] FUNDING.yml 2019-12-15 10:44:45 +01:00
Gwendal Roué f873bb1cfb fix busy timeout tests on Xcode 10.3 2019-12-15 10:00:57 +01:00
Gwendal Roué aadc58d349 [skip travis] documentation tweak 2019-12-14 19:49:26 +01:00
Gwendal Roué 5e75f0e0aa [skip travis] remove outdated documentation 2019-12-14 19:45:33 +01:00
Gwendal Roué a450df823b [skip travis] fix typo 2019-12-14 19:44:16 +01:00
Gwendal Roué af305afc2a LastUpgradeVersion 1130 2019-12-14 18:33:00 +01:00
Gwendal Roué 3d15751e44 Don't code sign performance tests 2019-12-14 18:28:28 +01:00
Gwendal Roué a09b8522ad Update make test_performance 2019-12-13 09:06:55 +01:00
Gwendal Roué 16186b6ac7 Extract performance tests to their own project 2019-12-13 09:02:47 +01:00
Gwendal Roué 1c2bd4134c Upgrade performance tests for Xcode 11.3 2019-12-13 08:39:24 +01:00
Gwendal Roué c4b6fbec76 Interrupt documentation 2019-12-13 08:24:42 +01:00
Gwendal Roué 974055b90b Suspension is experimental 2019-12-13 08:24:27 +01:00
Gwendal Roué 4bf5724543 Can't issue ROLLBACK on suspension
This is because this would allow a database modification to run in an aborted transaction
2019-12-13 08:14:49 +01:00
Gwendal Roué 19ba7d67e8 Suspension is fully experimental 2019-12-12 19:26:08 +01:00
Gwendal Roué 34eff46e56 Sharing a Datatase in an App Group Container 2019-12-12 19:23:41 +01:00
Gwendal Roué 0529869617 Fix busyMode tests for encrypted databases 2019-12-12 18:57:37 +01:00
Gwendal Roué 81ce5c9134 CHANGELOG 2019-12-12 08:53:16 +01:00
Gwendal Roué 6656f72782 Rename "lock prevention" to "suspension" 2019-12-12 08:47:49 +01:00
Gwendal Roué dfb013bf78 #664 is not quite easy to fix with optionals :-/ 2019-12-09 19:54:06 +01:00
Gwendal Roué 2b37e28691 remove debugging code 2019-12-09 19:20:02 +01:00
Gwendal Roué 69fc6a0496 Test that RowDecoder won't decode several sub-records from the root row - addresses #664 2019-12-09 19:09:27 +01:00
Gwendal Roué daba7e13fc Merge branch 'master' into development 2019-12-09 08:08:36 +01:00
Gwendal Roué 580fa6a554 Merge pull request #662 from groue/dev/SQLite3.30.1
Upgrade custom SQLite builds to version 3.30.1
2019-12-09 08:06:45 +01:00
Gwendal Roué e90ef7aa6e Fix acceptsDoubleQuotedStringLiterals tests 2019-12-08 18:07:41 +01:00
Gwendal Roué d1e1dcd097 Fix test for SPM 2019-12-08 08:55:05 +01:00
Gwendal Roué 16354be1c5 Merge pull request #656 from groue/dev/request-selection-inference
Type inference of selected columns
2019-12-07 19:36:08 +01:00
Gwendal Roué a0fddfe7ec Documentation 2019-12-07 13:47:00 +01:00
Gwendal Roué d6a459ad78 CHANGELOG 2019-12-07 13:42:52 +01:00
Gwendal Roué 7b4dc14485 [breaking] disable double-quoted string literals by default 2019-12-07 13:32:33 +01:00
Gwendal Roué 7208f53176 Support for NULLS FIRST and NULLS LAST 2019-12-07 12:31:58 +01:00
Gwendal Roué 2c9bef6440 "*" is no longer a valid FTS5 pattern 2019-12-07 12:07:06 +01:00
Gwendal Roué 820772fc6d SQlite 3.30.1 2019-12-07 12:01:51 +01:00
Gwendal Roué 710cea5437 CHANGELOG 2019-12-07 11:56:37 +01:00
Gwendal Roué b6ede15b18 Static tests for QueryInterfaceRequest type inference 2019-12-07 10:37:02 +01:00
Gwendal Roué aa536813d9 Add request type inference - cc @pakko972 2019-12-07 10:24:15 +01:00
Gwendal Roué 2b9932c1ee [skip travis] demo app icon, dark mode, content category adjustment 2019-12-07 10:03:53 +01:00
Gwendal Roué 2efb4e0d7d [skip travis] logo 2019-12-06 19:57:12 +01:00
Gwendal Roué 64935e78e3 Update TODO.md 2019-12-04 11:53:43 +01:00
Gwendal Roué 831ded3ec2 beginReadOnly only increments _readOnlyDepth if it succeeds 2019-12-03 19:18:05 +01:00
Gwendal Roué bbf8e773f8 Remove useless code 2019-12-03 19:17:35 +01:00
Gwendal Roué e4073cbe9a Test for stopPreventingLock 2019-12-03 19:12:41 +01:00
Gwendal Roué 6d0bdd3a4d CHANGELOG 2019-12-03 19:09:35 +01:00
Gwendal Roué 698dc262e0 Merge pull request #660 from groue/dev/startPreventingExclusiveLock
Database Lock Prevention
2019-12-03 19:08:09 +01:00
Gwendal Roué 41cd4c2140 Check for aborted transactions before checking for lock prevention 2019-12-03 09:01:03 +01:00
Gwendal Roué 12106387d1 Cleanup 2019-12-03 08:51:10 +01:00
Gwendal Roué 17864d3dcc Documentation 2019-12-03 08:15:57 +01:00
Gwendal Roué 4e26e8e744 Lock prevention: better error message 2019-12-03 08:13:19 +01:00
Gwendal Roué 7f66c85e67 Cleanup 2019-12-03 08:11:14 +01:00
Gwendal Roué 9efd5965ea Cleanup 2019-12-02 20:56:06 +01:00
Gwendal Roué 2b4a920732 Cleanup 2019-12-02 20:39:55 +01:00
Gwendal Roué 16025356bf Adapt lock prevention to the journal mode 2019-12-02 20:27:39 +01:00
Gwendal Roué 7015b66636 Update TODO.md 2019-12-02 09:50:57 +01:00
Gwendal Roué f604005b4c Improve interrupt() documentation 2019-12-01 19:03:47 +01:00
Gwendal Roué 1c318892c9 Documentation 2019-12-01 18:56:06 +01:00
Gwendal Roué f66cf92bba CHANGELOG 2019-12-01 18:54:21 +01:00
Gwendal Roué 559aae0263 CHANGELOG 2019-12-01 18:54:01 +01:00
Gwendal Roué 74bb9c11d7 Documentatioon 2019-12-01 18:52:51 +01:00
Gwendal Roué 98dc5df039 Avoid race condition in assertExclusiveLockPrevention 2019-12-01 18:44:23 +01:00
Gwendal Roué d85a7883bb Database.assertExclusiveLockPrevention mirrors assertNotInsideAbortedTransactionBlock 2019-12-01 18:34:51 +01:00
Gwendal Roué d1db8406f4 SQLITE_ABORT_EXCLUSIVE had no real purpose. 2019-12-01 18:26:52 +01:00
Gwendal Roué c8bb6873be Add SQLITE_CREATE_VTABLE to authorizer codes that invalidate schema cache 2019-12-01 17:59:49 +01:00
Gwendal Roué b54a8f7fe8 DatabaseWriter.startPreventingExclusiveLock() 2019-12-01 17:59:49 +01:00
Gwendal Roué 9cdebc45c0 Better assertNotInsideAbortedTransactionBlock 2019-12-01 17:59:49 +01:00
Gwendal Roué f8b6c1a285 More aborted transaction tests 2019-12-01 17:59:49 +01:00
Gwendal Roué 1fb12a2fdf Merge pull request #659 from groue/dev/interrupt
Database interruption
2019-12-01 11:54:04 +01:00
Gwendal Roué e3d25bda61 CHANGELOG 2019-12-01 05:23:19 +01:00
Gwendal Roué eb05c9b87d Documentation 2019-12-01 05:19:56 +01:00
Gwendal Roué 8145915d19 Fix aborted transaction tests for iOS 10.3.1 2019-12-01 04:01:03 +01:00
Gwendal Roué 62ef81c5fb Remove useless code 2019-11-30 21:16:48 +01:00
Gwendal Roué d4fa4c9d5e CHANGELOG 2019-11-30 21:14:06 +01:00
Gwendal Roué 64cb3091cf white space 2019-11-30 21:12:53 +01:00
Gwendal Roué b5ff80e858 Documentation 2019-11-30 21:12:47 +01:00
Gwendal Roué cae66fd5e0 Documentation 2019-11-30 20:51:24 +01:00
Gwendal Roué 79871e2d00 Documentation 2019-11-30 20:26:18 +01:00
Gwendal Roué fa1abdff2b Fix Swiftlint warnings 2019-11-30 19:56:26 +01:00
Gwendal Roué af00fd0f30 Less TODO 2019-11-30 19:53:04 +01:00
Gwendal Roué f90a408630 Tests for aborted transactions 2019-11-30 19:52:25 +01:00
Gwendal Roué f3e9c29f82 Monitor aborted transactions 2019-11-30 19:51:55 +01:00
Gwendal Roué 3ed7174838 DatabaseReader.interrupt() tests 2019-11-30 15:35:29 +01:00
Gwendal Roué 0a83848cfc DatabaseReader.interrupt() 2019-11-30 15:35:11 +01:00
Gwendal Roué 047ada75c7 Thank @MaxDesiatov 2019-11-29 09:02:04 +01:00
Gwendal Roué 129d2fae06 Fix documentation typo 2019-11-29 09:00:45 +01:00
Gwendal Roué 15a97f2b2b Merge pull request #658 from MaxDesiatov/patch-1
Fix typo in README.md
2019-11-27 17:01:52 +01:00
Max Desiatov 975d15733f Fix typo in README.md
> One want to build
2019-11-27 15:57:27 +00:00
Gwendal Roué 62f091a40b Fix typo 2019-11-23 11:45:21 +01:00
Max Desiatov 078f259061 Fix typo in README.md
> `concurrenRead`
2019-11-22 18:25:36 +01:00
Gwendal Roué a67070dd9a Merge branch 'development' 2019-11-20 18:51:03 +01:00
Gwendal Roué f257fb7a4e v4.6.2 2019-11-20 18:47:28 +01:00
Gwendal Roué 3f79892fdb Merge pull request #653 from signalapp/mkirk/empty-migrations
Fix: `appliedMigrations` throws error on new install
2019-11-20 09:04:35 +01:00
Michael Kirk cd6d46e349 move fix to private 2019-11-18 11:33:35 -07:00
Michael Kirk 9ea160b116 Fix: appliedMigrations throws error on new install
Before setup, the grdb_migrations table doesn't exist, so calling
`appliedMigrations` would throw an error.

To avoid this, if the table to track migrations doesn't exist yet, we can be
sure no migrations have been run, and we retun the empty set.

FIXES https://github.com/groue/GRDB.swift/issues/652
2019-11-18 09:09:46 -07:00
Gwendal Roué 8f03b5c8f3 Improve Configuration.targetQueue documentation - #651 2019-11-17 17:41:55 +01:00
Gwendal Roué 3ce3f2fa71 Xcode 11.3 in the Makefile 2019-11-17 17:31:42 +01:00
Gwendal Roué d9c26a40b4 Fix Swiftlint warning 2019-11-14 08:21:50 +01:00
Gwendal Roué 09e271de77 TODO 2019-11-13 19:25:09 +01:00
Gwendal Roué 205dea122f Upgrade performance tests 2019-11-13 04:37:08 +01:00
Gwendal Roué 2eb10aa19a Upgrade performance tests 2019-11-13 04:37:08 +01:00
Gwendal Roué 63fc59fd7c Merge pull request #649 from AnthonyEgerton/patch-1
Fix typo in Release Notes
2019-11-13 04:34:57 +01:00
Anthony Egerton bf6ee31491 Fix typo 2019-11-13 10:44:05 +11:00
Gwendal Roué 146151ffd7 Merge branch 'development' 2019-11-10 17:07:35 +01:00
Gwendal Roué 5b24f598a5 v4.6.1 2019-11-10 17:07:12 +01:00
Gwendal Roué 51a1c418a6 Merge pull request #647 from groue/dev/batch-update-policy
Honor conflict resolution for batch updates
2019-11-10 16:58:32 +01:00
Gwendal Roué e1ff862ffc CHANGELOG 2019-11-10 13:12:42 +01:00
Gwendal Roué 630a2c358a Document conflict resolution for batch updates 2019-11-10 13:05:33 +01:00
Gwendal Roué e0ea30041f Batch update: customization of conflict resolution 2019-11-10 13:00:19 +01:00
Gwendal Roué 58263e9b60 Fix failing test for batch update policy 2019-11-10 12:42:01 +01:00
Gwendal Roué 1e80aecfbd Failing test for batch update policy 2019-11-10 12:34:33 +01:00
Gwendal Roué d5c6dde3d9 Merge branch 'development' 2019-11-10 08:24:32 +01:00
Gwendal Roué 7819c9026a v4.6.0 2019-11-09 17:44:26 +01:00
Gwendal Roué e6617c8e12 Fix typo 2019-11-09 17:24:25 +01:00
Gwendal Roué d03a01a84a Fix typo 2019-11-09 16:23:51 +01:00
Gwendal Roué 90735fb3a7 CHANGELOG 2019-11-09 16:22:42 +01:00
Gwendal Roué 264906221e New Ordered vs. Unordered Associations chapter 2019-11-09 15:51:12 +01:00
Gwendal Roué be21704633 More usage tests for ordered to-many associations: reordering 2019-11-09 15:50:14 +01:00
Gwendal Roué b68bb00033 Simplify association to property type documentation 2019-11-09 14:52:32 +01:00
Gwendal Roué 1dd5c17bc7 Simplify Refining Association Requests chapter 2019-11-09 14:48:49 +01:00
Gwendal Roué c8a2c68728 Typo fix 2019-11-09 14:46:59 +01:00
Gwendal Roué f40c6511ef Usage tests for ordered to-many associations 2019-11-09 14:01:15 +01:00
Gwendal Roué 60aa6c2bf2 Less TODO 2019-11-09 13:11:25 +01:00
Gwendal Roué fe7446431b More NSDecimalNumber tests 2019-11-09 13:07:47 +01:00
Gwendal Roué abe2a62d47 Less TODO 2019-11-09 12:37:00 +01:00
Gwendal Roué 65d0f1edcc Merge pull request #646 from groue/dev/batch-update
Batch updates
2019-11-09 08:49:30 +01:00
Gwendal Roué c09615bab0 Fix bad tests 2019-11-08 20:32:54 +01:00
Gwendal Roué 218afa72c3 Test that order without limit is unused and harmless with updateAll() and deleteAll() 2019-11-08 18:09:11 +01:00
Gwendal Roué cb77fe2ed3 Don't check for ENABLE_UPDATE_DELETE_LIMIT: let SQLite emit syntax errors 2019-11-08 18:08:27 +01:00
Gwendal Roué 7345c5f2dd Fix Swiftlint warnings 2019-11-08 09:04:34 +01:00
Gwendal Roué efdebf59d3 CHANGELOG 2019-11-08 09:04:34 +01:00
Gwendal Roué 35d7490092 Fix SQLCipher tests (it misses ENABLE_UPDATE_DELETE_LIMIT) 2019-11-08 09:04:34 +01:00
Gwendal Roué dd4a2c5d9c Better error message when ENABLE_UPDATE_DELETE_LIMIT is missing 2019-11-08 09:04:34 +01:00
Gwendal Roué eae70f426e URIs don't change: people change them. 2019-11-08 09:04:34 +01:00
Gwendal Roué c7a6ca964c Doc cleanup 2019-11-08 09:04:34 +01:00
Gwendal Roué acb0004cea Move Full-Text documentation in its own file 2019-11-08 09:04:34 +01:00
Gwendal Roué 995d1b851a Rename setter to assignment 2019-11-08 09:04:34 +01:00
Gwendal Roué beab493dd5 Batch update documentation 2019-11-08 09:04:34 +01:00
Gwendal Roué 1c76eb7e9f Test encapsulation of batch update 2019-11-08 09:04:34 +01:00
Gwendal Roué 205398b65a Batch update 2019-11-08 09:04:34 +01:00
Gwendal Roué 61a6c5785f More request.deleteAll() tests 2019-11-08 09:04:34 +01:00
Gwendal Roué d983c6407c Update the list of extended result codes 2019-11-08 09:03:55 +01:00
Gwendal Roué 7cb78a4c86 Makefile: support for Xcode 11.2.1 GM seed 2019-11-08 09:03:47 +01:00
Gwendal Roué 733f6883d0 More TODO 2019-11-07 12:01:07 +01:00
Gwendal Roué 594874656a TODO 2019-11-06 08:24:22 +01:00
Gwendal Roué 6142020c50 Test association aggregate + inner join 2019-11-06 08:24:16 +01:00
Gwendal Roué 6f5b18854d TODO: enhance SQLRequest documentation - #617 2019-11-05 19:05:54 +01:00
Gwendal Roué b39c678a3d Remove dead code 2019-11-05 08:55:30 +01:00
Gwendal Roué a8a85d9a1f Disable some Travis tests
WTF? Travis has removed some simulators in the Xcode 11 setup?

https://travis-ci.org/groue/GRDB.swift/jobs/604303972
https://travis-ci.org/groue/GRDB.swift/jobs/604303975
2019-10-30 08:20:35 +01:00
Gwendal Roué 182b92f010 Opt in for more Swiftlint rules 2019-10-27 19:27:53 +01:00
Gwendal Roué a78f3699eb Help compiling GRDB with SWIFT_VERSION 5.0 and all opt-in APIs 2019-10-27 19:20:21 +01:00
Gwendal Roué 89bc509170 Merge branch 'development' 2019-10-15 18:55:25 +02:00
Gwendal Roué cfa615444e v4.5.0 2019-10-15 08:27:56 +02:00
Gwendal Roué 35389ed978 Fix demo app paths 2019-10-15 07:45:05 +02:00
Gwendal Roué caacecfd83 Remove obsolete GRDBPlus.podspec 2019-10-14 08:07:19 +02:00
Gwendal Roué 924b460c7a Move playgrounds to the Documentation folder 2019-10-14 08:05:50 +02:00
Gwendal Roué 60a9cf4942 Move the demo app to the Documentation folder 2019-10-14 08:03:54 +02:00
Gwendal Roué f9f3080819 Merge pull request #635 from groue/dev/sunsetFetchedRecordsController
Sunset FetchedRecordsController
2019-10-13 19:41:19 +02:00
Gwendal Roué 02c024e819 CocoaPods test apps don't rely on demo app, which requires Swift 5.1 2019-10-13 12:53:09 +02:00
Gwendal Roué 10249675ff CHANGELOG 2019-10-12 15:19:50 +02:00
Gwendal Roué b6553c0b59 Demo app: replace FetchedRecordsController with ValueObservation 2019-10-12 14:49:18 +02:00
Gwendal Roué dfd3e50b9c Sunset FetchedRecordsController 2019-10-12 14:10:56 +02:00
Gwendal Roué 79b8f7ed1d Merge pull request #633 from groue/dev/CocoaPodsOptions
SQLITE_ENABLE_PREUPDATE_HOOK support with CocoaPods
2019-10-12 13:00:22 +02:00
Gwendal Roué f184c626e0 SQLITE_ENABLE_PREUPDATE_HOOK documentation 2019-10-12 12:56:39 +02:00
Gwendal Roué 24ba40a77e GRDB_SQLITE_ENABLE_PREUPDATE_HOOK exposes missing SQLITE_ENABLE_PREUPDATE_HOOK declarations 2019-10-10 20:16:15 +02:00
Gwendal Roué 66326d79a2 Minor doc fix 2019-10-10 19:50:30 +02:00
Gwendal Roué fcd6c100ee Fix Xcode 11.1 tvOS destination in Makefile 2019-10-10 18:33:53 +02:00
Gwendal Roué 95b7879e33 CHANGELOG 2019-10-10 18:33:17 +02:00
Gwendal Roué 404532f6f0 Add LockedBox to GRDBCustom 2019-10-10 13:52:33 +02:00
Gwendal Roué 751262cdb3 Better DatabaseReader tests 2019-10-10 13:51:44 +02:00
Gwendal Roué 0ac0d31796 Better snapshot tests 2019-10-10 13:51:33 +02:00
Gwendal Roué 9d5d7f0216 Database.withSchemaCache 2019-10-10 13:51:00 +02:00
Gwendal Roué b59521e247 ReadWriteBox(value:) initializer 2019-10-10 13:50:42 +02:00
Gwendal Roué 7dd90c4af3 Don’t return Void 2019-10-10 13:49:55 +02:00
Gwendal Roué b06e4ad298 Make DatabaseSnapshot.reentrantRead actually reentrant 2019-10-10 13:49:39 +02:00
Gwendal Roué ff21f86341 DatabasePool setup: handle #102 in a savepoint 2019-10-10 13:49:12 +02:00
Gwendal Roué c89d41adbb Rename readerConfig to readerConfiguration 2019-10-10 13:48:20 +02:00
Gwendal Roué b3e1bf6f05 Database.checkpoint 2019-10-10 13:45:01 +02:00
Gwendal Roué fc57a69672 Rename beginSnapshotTransaction to beginSnapshotTransaction 2019-10-10 13:43:10 +02:00
Gwendal Roué fdbc0c8ec8 LockedBox: for when one does not need single writer/multiple readers 2019-10-10 13:41:58 +02:00
Gwendal Roué e3edf6daec Snapshot documentation improvements 2019-10-10 13:38:43 +02:00
Gwendal Roué 1b8f7b95f4 CHANGELOG and thank you notice 2019-10-10 08:20:32 +02:00
Gwendal Roué f756f39772 Merge pull request #632 from runhum/bugfix/readme-typos
Fix Accout -> Account
2019-10-09 17:28:45 +02:00
Runar Hummelsund 836f34297d Fix Accout -> Account 2019-10-09 17:19:44 +02:00
Gwendal Roué cd6d2579a5 Merge pull request #631 from groue/dev/issue630
Fix custom SQLite builds
2019-10-07 06:31:00 +02:00
Gwendal Roué 2892424006 CHANGELOG 2019-10-06 13:51:03 +02:00
Gwendal Roué 856792d688 Travis: test custom SQLite installation 2019-10-06 13:03:43 +02:00
Gwendal Roué 00115ba60c More explicit documentation for the Pre-action script 2019-10-06 12:57:03 +02:00
Gwendal Roué 1cdddd35c8 Fix Xcode warnings 2019-10-06 12:55:35 +02:00
Gwendal Roué ccaf4c942f Test installation procedure for custom SQLite 2019-10-06 12:55:21 +02:00
Gwendal Roué 9f9fcb1a8e Address #630 2019-10-06 12:21:49 +02:00
Gwendal Roué b6955377c9 CHANGELOG 2019-10-06 11:49:45 +02:00
Gwendal Roué 5f085f2df8 Merge pull request #627 from groue/dev/SPM
Swift Package Manager: define SQLite as a system library target
2019-10-04 19:01:49 +02:00
Gwendal Roué 3cc5bb7c98 Test SPM integration from Xcode 2019-10-02 18:27:40 +02:00
Gwendal Roué 3dc4567233 SPM: Replace groue/CSQLite with a systemLibrary target 2019-10-02 18:02:49 +02:00
Gwendal Roué 37477adada Merge pull request #622 from groue/dev/620
Allow observation of FTS4 virtual tables
2019-09-27 06:04:03 +02:00
Gwendal Roué a44afd79e0 Makefile: support for Xcode 11.1 2019-09-26 13:15:32 +02:00
Gwendal Roué 61088ee2e7 Makefile: use iPhone 11 simulator with Xcode 11.0 2019-09-26 13:07:47 +02:00
Gwendal Roué a721917d95 CHANGELOG 2019-09-26 09:03:10 +02:00
Gwendal Roué a08b078c3e Fix a swiftlint warning 2019-09-26 08:49:57 +02:00
Gwendal Roué aa1cfb9020 Fix testSynchronizedFTS4Observation 2019-09-26 08:49:44 +02:00
Gwendal Roué 0d961ce48e Simplify DatabaseRegion.iisModified(by:)
There is no "fast path" any longer. Performance impact should be minimal since most observers call `stopObservingDatabaseChangesUntilNextTransaction` on first impactful change anyway.
2019-09-26 06:55:54 +02:00
Gwendal Roué 1b753802dd Address #620, but a failing test remains 2019-09-25 20:03:00 +02:00
Gwendal Roué 3f3bdde10c #620 explorations 2019-09-25 17:08:02 +02:00
Gwendal Roué b2ea9e51d2 Help debugging authorization issues like #620 2019-09-25 17:04:26 +02:00
Gwendal Roué 27a05028db SQLRequest+SQLLiteral: added literal initialization tests 2019-09-17 08:54:34 +02:00
Gwendal Roué 725e16390b Fix failing test for eraseDatabaseOnSchemaChange 2019-09-17 08:22:36 +02:00
Gwendal Roué 6b83ba3585 Failing test for eraseDatabaseOnSchemaChange 2019-09-17 08:18:45 +02:00
Gwendal Roué 62e50b1a73 Simplify eraseDatabaseOnSchemaChange implementation 2019-09-17 08:10:28 +02:00
Gwendal Roué bf7192cef1 Siimplify Row: Swift has better ARC optimizations now 2019-09-13 19:39:45 +02:00
Gwendal Roué 18d634b171 Update performance tests for Xcode 11 2019-09-13 19:11:21 +02:00
Gwendal Roué a5b5bccc61 Update TODO.md 2019-09-13 14:04:43 +02:00
Gwendal Roué 988852a438 Makefile/Travis: min tvOS 10.2 on Xcode 10.3 2019-09-13 04:59:51 +02:00
Gwendal Roué 2313713603 Makefile/Travis: min iOS 10.3.1 on Xcode 10.3 2019-09-13 04:56:32 +02:00
Gwendal Roué 6a5ce71c12 Makefile/Travis: Don't code sign 2019-09-12 07:09:27 +02:00
Gwendal Roué 9872e945ba Makefile/Travis: Xcode 11 use iPhone Xs + iOS 13.0 2019-09-11 19:48:50 +02:00
Gwendal Roué b3341cc552 Makefile/Travis: Xcode 11 min iOS is 10.3.1 2019-09-11 19:42:41 +02:00
Gwendal Roué 0a1e3afa82 Makefile/Travis: Xcode 11 2019-09-11 08:52:18 +02:00
Gwendal Roué 483728bfbf Fix typo 2019-09-09 08:43:29 +02:00
Gwendal Roué b459536b66 TODO 2019-09-07 15:55:07 +02:00
Gwendal Roué d990b47814 Fix compiler warnings 2019-09-07 12:51:46 +02:00
Gwendal Roué aa157a77d2 Merge branch 'development' 2019-09-06 08:07:49 +02:00
Gwendal Roué 254f3760b4 v4.4.0 2019-09-06 08:06:15 +02:00
Gwendal Roué 896ec284e1 Merge pull request #602 from groue/dev/passphrase-refactoring
Don't keep the sqlCipher passphrase in memory longer than necessary
2019-09-06 07:59:35 +02:00
Gwendal Roué 036178a55a CHANGELOG 2019-09-06 07:52:18 +02:00
Gwendal Roué 3ff94c7607 CHANGELOG 2019-09-06 07:44:15 +02:00
Gwendal Roué 5c125fae8b Add a "Managing the lifetime of the passphrase string" security consideration 2019-09-05 13:28:19 +02:00
Gwendal Roué 642089f41a Suggest using Data Protection 2019-09-04 19:16:14 +02:00
Gwendal Roué 6285a59926 Fix sample code 2019-09-04 19:09:32 +02:00
Gwendal Roué 4ba199f0aa Organization 2019-09-04 18:53:11 +02:00
Gwendal Roué 75f3540b8f Typo 2019-09-04 18:50:16 +02:00
Gwendal Roué bfa1689d7d Typo 2019-09-04 18:49:47 +02:00
Gwendal Roué a1c96f9093 Another suggestion by @michaelkirk-signal 2019-09-04 18:46:44 +02:00
Gwendal Roué 32842c22f0 Wording 2019-09-04 18:38:37 +02:00
Gwendal Roué 8e764aadd2 Fix typo 2019-09-04 18:36:53 +02:00
Gwendal Roué ad9b32f9a2 Fix ambiguous wording 2019-09-04 18:35:52 +02:00
Gwendal Roué cb9323480c Fix typo 2019-09-04 18:31:32 +02:00
Gwendal Roué cc7d19d925 Apply wording by @michaelkirk-signal 2019-09-04 18:24:25 +02:00
Gwendal Roué c2e68d95fe Passphrase documentation 2019-09-04 08:54:22 +02:00
Gwendal Roué 7b3275ce45 Make lastErrorCode and lastErrorMessage public 2019-09-04 08:54:06 +02:00
Gwendal Roué 9a69dbd8a1 Remove testDatabaseQueueWithPassphraseToDatabaseQueueWithWrongPassphraseAndRetry 2019-09-03 13:26:16 +02:00
Gwendal Roué f2198f5af7 Passphrase documentation (WIP) 2019-09-03 09:11:52 +02:00
Gwendal Roué 8150dda951 Passphrase documentation (WIP) 2019-09-03 09:10:02 +02:00
Gwendal Roué d4928eff99 Test that prepareDatabase errors are rethrown 2019-09-03 09:07:14 +02:00
Gwendal Roué 1f48405b5c Rewrite passphrase documentation (WIP) 2019-09-03 08:56:41 +02:00
Gwendal Roué 55d4a9c029 Test for attempting several passphrases 2019-09-03 08:56:16 +02:00
Gwendal Roué e6bc1c40fe CHANGELOG 2019-09-03 08:55:57 +02:00
Gwendal Roué b9e2f35728 Deprecate change(passphrase:), and provide an alternative solution 2019-09-02 09:05:37 +02:00
Gwendal Roué 6fc7794e64 Restore testDeprecatedPassphrase 2019-09-02 08:38:15 +02:00
Gwendal Roué 1d71b9f311 Update testPrepareDatabase for snapshots 2019-09-02 08:38:15 +02:00
Gwendal Roué 9f26777cc3 prepareDatabase did not need to be deprecated, after all 2019-09-02 08:38:15 +02:00
Gwendal Roué 0b9fe9ae92 Documentation 2019-09-02 08:38:15 +02:00
Gwendal Roué 1ba4e8c771 Fix failing test for change(passphrase:) 2019-09-02 08:38:15 +02:00
Gwendal Roué aded6d206d Failing test for change(passphrase:) 2019-09-02 08:38:15 +02:00
Gwendal Roué d644f01557 Deprecate Configuration.passphrase, introduce Database.usePassphrase(_:) 2019-09-02 08:38:15 +02:00
Gwendal Roué eb112c912c Fix Xcode 11 warnings in SQLCipher test projects 2019-09-02 08:37:28 +02:00
Gwendal Roué d8b0b95842 DatabaseConfiguration.onConnect 2019-09-02 08:37:28 +02:00
Gwendal Roué 8f66114042 Deprecate Configuration.prepareDatabase 2019-09-02 08:37:28 +02:00
Gwendal Roué 943eca10a6 TODO 2019-09-02 08:37:28 +02:00
Gwendal Roué 82f56ee596 Merge pull request #603 from groue/dev/pool-barrier
DatabasePool write barrier
2019-09-02 08:36:01 +02:00
Gwendal Roué 00e2c2a626 Fix testBarrierIsLockedByOneUnfinishedRead for Swift 4.2 2019-09-02 05:39:38 +02:00
Gwendal Roué c7e4492846 Fix DatabasePool.change(passphrase:) 2019-09-01 19:33:03 +02:00
Gwendal Roué 04a6e969a5 DatabasePool.barrierWriteWithoutTransaction documentation 2019-09-01 17:30:01 +02:00
Gwendal Roué 5b4a225dc3 DatabasePool.barrierWriteWithoutTransaction tests 2019-09-01 17:19:12 +02:00
Gwendal Roué e3efcc0d87 CHANGELOG 2019-09-01 17:03:22 +02:00
Gwendal Roué 8580023eda DatabasePool.barrierWriteWithoutTransaction 2019-09-01 16:46:17 +02:00
Gwendal Roué 473f6ff0d8 Tests for Pool.barrier 2019-09-01 16:32:39 +02:00
Gwendal Roué e495df0114 Pool.barrier 2019-09-01 16:32:18 +02:00
Gwendal Roué 06d6c3866b ReadWriteBox Cleanup 2019-09-01 16:28:16 +02:00
631 changed files with 49406 additions and 28944 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
github: [groue]
+2 -1
View File
@@ -106,7 +106,8 @@ Podfile.lock
# SPM
.build
Package.resolved
GRDB.xcworkspace/xcshareddata/swiftpm
#Package.resolved
Tests/SPM/Packages
# Ruby
-9
View File
@@ -1,12 +1,3 @@
[submodule "Tests/Performance/fmdb"]
path = Tests/Performance/fmdb
url = https://github.com/ccgus/fmdb.git
[submodule "Tests/Performance/SQLite.swift"]
path = Tests/Performance/SQLite.swift
url = https://github.com/stephencelis/SQLite.swift.git
[submodule "Tests/Performance/Realm"]
path = Tests/Performance/Realm
url = https://github.com/realm/realm-cocoa.git
[submodule "SQLiteCustom/src"]
path = SQLiteCustom/src
url = https://github.com/swiftlyfalling/SQLiteLib.git
+9 -2
View File
@@ -2,7 +2,9 @@ included:
- GRDB
disabled_rules:
- comment_spacing
- cyclomatic_complexity
- duplicate_enum_cases
- file_length
- force_cast
- force_try
@@ -24,20 +26,26 @@ disabled_rules:
opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- closure_spacing
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- convenience_type
- empty_collection_literal
- empty_count
- empty_string
- explicit_init
- fatal_error_message
- first_where
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_random
- lower_acl_than_parent
- modifier_order
- no_extension_access_modifier
- overridden_super_call
@@ -49,7 +57,6 @@ opt_in_rules:
- toggle_bool
- unused_declaration
- unused_import
- unused_private_declaration
- yoda_condition
vertical_whitespace:
+74 -312
View File
@@ -1,6 +1,11 @@
# The OS X Build Environment
# https://docs.travis-ci.com/user/reference/osx/#xcode-version
branches:
only:
- master
- development
language: objective-c
xcode_project: GRDB.xcodeproj
@@ -23,377 +28,134 @@ jobs:
include:
###########################################
## Test GRDB Xcode 10.2
## Test GRDB Xcode 12.2
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBOSX - Swift 5.3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBOSX (Swift 5, macOS)
osx_image: xcode12.2
script: make test_framework_GRDBOSX_maxSwift
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBOSX - Swift 5.2"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBOSX (Swift 4.2, macOS)
osx_image: xcode12.2
script: make test_framework_GRDBOSX_minSwift
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBWatchOS"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBWatchOS (watchOS)
osx_image: xcode12.2
script: make test_framework_GRDBWatchOS
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 5, iOS <MAX>)
osx_image: xcode12.2
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 4.2, iOS <MAX>)
script: make test_framework_GRDBiOS_maxTarget_minSwift
- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 5, iOS <MIN>)
osx_image: xcode12.2
script: make test_framework_GRDBiOS_minTarget
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - GRDBtvOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 5, tvOS <MAX>)
osx_image: xcode12.2
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12 - GRDBtvOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_minSwift
- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 5, tvOS <MIN>)
osx_image: xcode12.2
script: make test_framework_GRDBtvOS_minTarget
- stage: Test GRDB Xcode 10.2
- name: "Test GRDB Xcode 12.2 - SPM"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDB [SPM] (macOS)
osx_image: xcode12.2
script: make test_SPM
###########################################
## Test GRDBCustom Xcode 10.2
## Test GRDBCustom Xcode 12.2
- stage: Test GRDBCustom Xcode 10.2
- name: "Test GRDBCustom Xcode 12.2 - GRDBOSX"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBOSX (Swift 5, macOS)
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteOSX
- stage: Test GRDBCustom Xcode 10.2
- name: "Test GRDBCustom Xcode 12.2 - GRDBiOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 5, iOS <MAX>)
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
- stage: Test GRDBCustom Xcode 10.2
- name: "Test GRDBCustom Xcode 12.2 - GRDBiOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 4.2, iOS <MAX>)
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_minSwift
- stage: Test GRDBCustom Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBiOS (Swift 5, iOS <MIN>)
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test SQLCipher Xcode 10.2
## Test SQLCipher Xcode 12.2
- stage: Test SQLCipher Xcode 10.2
- name: "Test SQLCipher Xcode 12.2 - SQLCipher 3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=SQLCipher 3
osx_image: xcode12.2
script: make test_framework_SQLCipher3
- stage: Test SQLCipher Xcode 10.2
- name: "Test SQLCipher Xcode 12.2 - SQLCipher 4"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=SQLCipher 4
osx_image: xcode12.2
script: make test_framework_SQLCipher4
###########################################
## Test Installation Xcode 10.2
## Test Installation Xcode 12.2
# Manual Install
- stage: Test Installation Xcode 10.2
- name: "Test Installation Xcode 12.2 - Manual Install"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=Manual Install
osx_image: xcode12.2
script: make test_install_manual
# CocoaPods Lint
- stage: Test Installation Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=CocoaPods Lint
script: make test_CocoaPodsLint_GRDB
# CocoaPods Install GRDB
- stage: Test Installation Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=CocoaPods GRDB (framework)
script: make test_install_GRDB_CocoaPods_framework
# CocoaPods Install GRDB
- stage: Test Installation Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=CocoaPods GRDB (static)
script: make test_install_GRDB_CocoaPods_static
# SPM Install
- stage: Test Installation Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=SPM
script: make test_install_SPM
###########################################
## Test GRDB Xcode 10.1
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBOSX (Swift 4.2, macOS)
script: make test_framework_GRDBOSX_maxSwift
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBWatchOS (watchOS)
script: make test_framework_GRDBWatchOS
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBiOS (Swift 4.2, iOS <MAX>)
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBiOS (Swift 4.2, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MIN>)
script: make test_framework_GRDBtvOS_minTarget
- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDB [SPM] (macOS)
script: make test_SPM
# ###########################################
# ## Test GRDBCustom Xcode 10.1
#
# - stage: Test GRDBCustom Xcode 10.1
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10.1
# env:
# - TID=GRDBOSX (Swift 4.2, macOS)
# script: make test_framework_GRDBCustomSQLiteOSX
#
# - stage: Test GRDBCustom Xcode 10.1
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10.1
# env:
# - TID=GRDBiOS (Swift 4.2, iOS <MAX>)
# script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
#
# - stage: Test GRDBCustom Xcode 10.1
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10.1
# env:
# - TID=GRDBiOS (Swift 4.2, iOS <MIN>)
# script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test GRDB Xcode 10
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBOSX (Swift 4.2, macOS)
script: make test_framework_GRDBOSX_maxSwift
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBWatchOS (watchOS)
script: make test_framework_GRDBWatchOS
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBiOS (Swift 4.2, iOS <MAX>)
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBiOS (Swift 4.2, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MIN>)
script: make test_framework_GRDBtvOS_minTarget
- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDB [SPM] (macOS)
script: make test_SPM
# ###########################################
# ## Test GRDBCustom Xcode 10
#
# - stage: Test GRDBCustom Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=GRDBOSX (Swift 4.2, macOS)
# script: make test_framework_GRDBCustomSQLiteOSX
#
# - stage: Test GRDBCustom Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=GRDBiOS (Swift 4.2, iOS <MAX>)
# script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
#
# - stage: Test GRDBCustom Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=GRDBiOS (Swift 4.2, iOS <MIN>)
# script: make test_framework_GRDBCustomSQLiteiOS_minTarget
#
# ###########################################
# ## Test SQLCipher Xcode 10
#
# - stage: Test SQLCipher Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=SQLCipher 3
# script: make test_framework_SQLCipher3
#
# - stage: Test SQLCipher Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=SQLCipher 4
# script: make test_framework_SQLCipher4
###########################################
## Test Installation Xcode 10
# # Manual Install
# - stage: Test Installation Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=Manual Install
# script: make test_install_manual
#
# Travis is much too slow, and always fail this job
# # CocoaPods Lint
# - stage: Test Installation Xcode 10
# - name: "Test Installation Xcode 12.2 - CocoaPods Lint"
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=CocoaPods Lint
# osx_image: xcode12.2
# script: make test_CocoaPodsLint_GRDB
# CocoaPods Install GRDB
- stage: Test Installation Xcode 10
- name: "Test Installation Xcode 12.2 - CocoaPods Framework"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=CocoaPods GRDB (framework)
osx_image: xcode12.2
script: make test_install_GRDB_CocoaPods_framework
# CocoaPods Install GRDB
- stage: Test Installation Xcode 10
- name: "Test Installation Xcode 12.2 - CocoaPods Static"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=CocoaPods GRDB (static)
osx_image: xcode12.2
script: make test_install_GRDB_CocoaPods_static
# # SPM Install
# - stage: Test Installation Xcode 10
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode10
# env:
# - TID=SPM
# script: make test_install_SPM
# SPM Install
- name: "Test Installation Xcode 12.2 - SPM Package"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_SPM_Package
# SPM Install
- name: "Test Installation Xcode 12.2 - SPM Package in Xcode Project"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_SPM_Project
# Custom SQLite Install
- name: "Test Installation Xcode 12.2 - Custom SQLite"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_customSQLite
###########################################
## Test GRDB Xcode 11.4
- name: "Test GRDB Xcode 11.4 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11.4
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 11.4 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11.4
script: make test_framework_GRDBiOS_minTarget
+135
View File
@@ -0,0 +1,135 @@
# Brag Document
Here is a list of people who were happy to meet GRDB :-)
---
https://twitter.com/peres/status/1352219836508729346
> Just the occasional reminder that GRDB and its documentation is the gold standard. That's it.
---
https://twitter.com/steipete/status/1275305583718129664
> This is the future of Core Data
---
https://twitter.com/_maxheld/status/1266509824994553860
> I tried out GRDB since I saw you mention it a few days ago and absolutely love it. It’s so nice and testing the database logic is so much nicer than CoreData
---
https://twitter.com/stephencelis/status/1263518304980918274
> GRDB.swift is great! (I say this as the person that started SQLite.swift long ago.) And @groue’s very helpful and friendly.
---
https://twitter.com/peres/status/1262682199482142720
> GRDB in already in my top3 when it comes to documentation. Clearly and pragmatically explained.
---
https://twitter.com/layoutsubviews/status/1249940744929816582
> Mixing SQLite / GRDB with Combine is my whole world right now, and it is delightful.
---
https://twitter.com/steipete/status/1231105339954802694
> It [Core Data] gets the job done, but folks made some really amazing Swift native sqlite wrappers.
---
https://twitter.com/BelleBCooper/status/1223148814980091904
> I LOVE GRDB and highly recommend it. If you don’t need it now, do keep it in mind for future because it’s great and the documentation and support are top notch.
---
https://twitter.com/layoutSubviews/status/1202092984822648832
> GRDB is quickly becoming the best package I have ever dealt with.
> What an exceptional piece of work: the philosophy, the documentation, the API, the abstractions, the Swiftiness👌
---
https://twitter.com/fpillet/status/1193608995405209607
> GRDB keeps being the best-in-class interface to your database, and if you're not using it you're missing out. As always, amazing work from @groue !
---
https://twitter.com/lordmooch/status/1193537540583755776
> Best SQLite/Swift integration 😀👍🏻
---
https://twitter.com/BelleBCooper/status/1192195655743111168
> I’ve been working on a side project recently that uses SwiftUI (+UIKit for parent controllers and nav), Combine, GRDB, and GRDBCombine for automatic updating based on DB changes. I’m really liking this setup.
---
https://twitter.com/BelleBCooper/status/1186034269577048064
> Working on a new project today and using GRDB by @groue for the backend. This is my go-to for new Swift projects. Highly recommend it!
---
https://twitter.com/krzyzanowskim/status/1156568071303290882
> I think GRDB.swift is a godsend. So far sooooo good. (change my mind?)
---
https://twitter.com/iOSDevWeekly/status/1133780078398021637
> How had I never heard of GRDB before this week? Was I the only one missing out, or is this wonderful database library from @groue news to you all too? https://buff.ly/2X8yHGf #iosdev
----
https://twitter.com/micpringle/status/1132264501812891648
> Spent the last few weeks integrating it and it’s amazing! And this release brings a whole load more features—especially excited about eager loading of hasMany relationships.
>
> Quite possibly one of the best documented open source libs I’ve come across as well👌🏼
---
https://twitter.com/danielemargutti/status/1132217792902647808
> It’s a great successor for FMDB with tons of great stuff. Worth a look, we have choose it in our new project even if, actually, I preferred not using some of the ‘ORM’ like features.
---
https://twitter.com/lordmooch/status/1131664588494254086
> Woohoo! Absolutely superb Swift library for SQLite - I love it 😀
---
https://twitter.com/JadenGeller/status/1115483150564487168
> Wow, there are some *really* good looking SQLite frameworks in Swift.
---
https://twitter.com/strawb3rryx7/status/1073620070784516096
> If you looking for a SQLite wrapper in Swift, just take a look the GRDB library! 👇🏼 https://github.com/groue/GRDB.swift Well-maintained and documented! ✊🏼
---
https://twitter.com/BelleBCooper/status/1047017928112128000
> http://blog.bellebcooper.com/2018-10-02-16-39.html
>
> I love the way issues are handled in GRDB (SQLite for Swift). Groue is so friendly, and always goes above-and-beyond in helping to solve problems or explore new features for the library. It makes me happy to be a GRDB user.
+649 -10
View File
@@ -3,16 +3,29 @@ Release Notes
All notable changes to this project will be documented in this file.
GRDB adheres to [Semantic Versioning](https://semver.org/), with one expection: APIs flagged [**:fire: EXPERIMENTAL**](README.md#what-are-experimental-features). Those are unstable, and may break between any two minor releases of the library.
GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: APIs flagged [**:fire: EXPERIMENTAL**](README.md#what-are-experimental-features). Those are unstable, and may break between any two minor releases of the library.
#### 5.x Releases
<!--
[Next Release](#next-release)
-->
- `5.3.x` Releases - [5.3.0](#530)
- `5.2.x` Releases - [5.2.0](#520)
- `5.1.x` Releases - [5.1.0](#510)
- `5.0.x` Releases - [5.0.0](#500) | [5.0.1](#501) | [5.0.2](#502) | [5.0.3](#503)
- `5.0.0` Betas - [5.0.0-beta](#500-beta) | [5.0.0-beta.2](#500-beta2) | [5.0.0-beta.3](#500-beta3) | [5.0.0-beta.4](#500-beta4) | [5.0.0-beta.5](#500-beta5) | [5.0.0-beta.6](#500-beta6) | [5.0.0-beta.7](#500-beta7) | [5.0.0-beta.8](#500-beta8) | [5.0.0-beta.9](#500-beta9) | [5.0.0-beta.10](#500-beta10) | [5.0.0-beta.11](#500-beta11)
#### 4.x Releases
- `4.14.x` Releases - [4.14.0](#4140)
- `4.13.x` Releases - [4.13.0](#4130)
- `4.12.x` Releases - [4.12.0](#4120) | [4.12.1](#4121) | [4.12.2](#4122)
- `4.11.x` Releases - [4.11.0](#4110)
- `4.10.x` Releases - [4.10.0](#4100)
- `4.9.x` Releases - [4.9.0](#490)
- `4.8.x` Releases - [4.8.0](#480) | [4.8.1](#481)
- `4.7.x` Releases - [4.7.0](#470)
- `4.6.x` Releases - [4.6.0](#460) | [4.6.1](#461) | [4.6.2](#462)
- `4.5.x` Releases - [4.5.0](#450)
- `4.4.x` Releases - [4.4.0](#440)
- `4.3.x` Releases - [4.3.0](#430)
- `4.2.x` Releases - [4.2.0](#420) | [4.2.1](#421)
- `4.1.x` Releases - [4.1.0](#410) | [4.1.1](#411)
@@ -56,9 +69,635 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one expection:
- [0.110.0](#01100), ...
<!--
## Next Release
-->
## 5.3.0
Released January 9, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.2.0...v5.3.0)
- **New**: [#880](https://github.com/groue/GRDB.swift/pull/880): Common Table Expressions
- **New**: [#892](https://github.com/groue/GRDB.swift/pull/892) by [@eburns-vmware](https://github.com/eburns-vmware): Provide SQLCipher passphrase as Data
- **Fixed**: [#881](https://github.com/groue/GRDB.swift/pull/881) by [@felixscheinost](https://github.com/felixscheinost) and [#883](https://github.com/groue/GRDB.swift/pull/883) by [@professordeng](https://github.com/professordeng): Documentation improvements
- **Fixed**: [#885](https://github.com/groue/GRDB.swift/pull/885): Robustness of eager loading of to-many associations based on compound foreign keys
- **Fixed**: [#901](https://github.com/groue/GRDB.swift/pull/901) by [@wuyuehyang](https://github.com/wuyuehyang): Fix creation of FTS5 tokenizer with arguments
- **Fixed**: [#903](https://github.com/groue/GRDB.swift/pull/903) by [@chrisballinger](https://github.com/chrisballinger): Fix SPM installation instructions
- **Documentation update**: A new guide: [Common Table Expressions](https://github.com/groue/GRDB.swift/blob/master/Documentation/CommonTableExpressions.md)
- **Documentation update**: The [Foreign Keys](https://github.com/groue/GRDB.swift/blob/master/Documentation/AssociationsBasics.md#foreign-keys) chapter of the Associations Guide clarifies the behavior of SQLite and GRDB regarding the presence of NULL if compound foreign keys.
## 5.2.0
Released November 29, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.1.0...v5.2.0)
- **New**: [#868](https://github.com/groue/GRDB.swift/pull/868): ValueObservation optimization is opt-in.
- **New**: [#872](https://github.com/groue/GRDB.swift/pull/872): Parse time zones
- **Documentation update**: The [ValueObservation Performance](https://github.com/groue/GRDB.swift/blob/master/README.md#valueobservation-performance) chapter was extended with a tip for observations that track a constant database region.
- **Documentation update**: The [Date and DateComponents](https://github.com/groue/GRDB.swift/blob/master/README.md#date-and-datecomponents) chapter describes the support for time zones.
- **Documentation update**: A caveat ([#871](https://github.com/groue/GRDB.swift/issues/871)) with the `including(all:)` method, which may fail with a database error of code [`SQLITE_ERROR`](https://www.sqlite.org/rescode.html#error) (1) "Expression tree is too large" when you use a compound foreign key and there are a lot of parent records, is detailed in the [Joining And Prefetching Associated Records](https://github.com/groue/GRDB.swift/blob/master/Documentation/AssociationsBasics.md#joining-and-prefetching-associated-records) chapter.
## 5.1.0
Released November 1, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.3...v5.1.0)
- **New**: Clarifications on [ValueObservation that track a varying database region](https://github.com/groue/GRDB.swift/blob/master/README.md#observing-a-varying-database-region).
- **New**: FAQ [Why is ValueObservation not publishing value changes?](https://github.com/groue/GRDB.swift/blob/master/README.md#why-is-valueobservation-not-publishing-value-changes)
- **New**: [#855](https://github.com/groue/GRDB.swift/pull/855) by [@mallman](https://github.com/mallman): Support for generated columns with custom SQLite build, and upgrade custom SQLite builds to version 3.33.0
- **New**: [#864](https://github.com/groue/GRDB.swift/pull/864): Prevent filter misuse with a deprecation warning
## 5.0.3
Released October 25, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.2...v5.0.3)
- **Fixed**: [#859](https://github.com/groue/GRDB.swift/pull/859): Database.close() is idempotent
- **Fixed**: [#850](https://github.com/groue/GRDB.swift/pull/850) by [@mtancock](https://github.com/mtancock): Add buildActiveScheme to playground settings so they'll build under Xcode 12
- **Fixed**: [#849](https://github.com/groue/GRDB.swift/pull/849) by [@MarshalGeazipp](https://github.com/MarshalGeazipp): Fix grammar mistake AssociationsBasics.md
## 5.0.2
Released October 6, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.1...v5.0.2)
- **Fixed**: [#844](https://github.com/groue/GRDB.swift/issues/844): Fix a crash in the demo app
- **Fixed**: [#847](https://github.com/groue/GRDB.swift/issues/847): Remove dependency on SQLITE_ENABLE_SNAPSHOT
## 5.0.1
Released September 27, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0...v5.0.1)
- **Fixed**: [#841](https://github.com/groue/GRDB.swift/issues/841): Fix GRDB 5 regression with indexes on expressions
- The [GRDBCombineDemo](Documentation/DemoApps/GRDBCombineDemo/README.md) Combine + SwiftUI demo application was updated for the SwiftUI App lifecycle introduced in iOS 14.
## 5.0.0
Released September 20, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.11...v5.0.0)
- **Fixed**: [#838](https://github.com/groue/GRDB.swift/issues/838): Have indexed colums inherit the `ifNotExists` flag from table creation.
## 5.0.0-beta.11
Released September 7, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.10...v5.0.0-beta.11)
- **Breaking Change**: [#831](https://github.com/groue/GRDB.swift/pull/831): Improve Configuration.prepareDatabase
## 5.0.0-beta.10
Released July 30, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.9...v5.0.0-beta.10)
- **New**: DatabasePool readers don't invalidate their database schema cache until schema is actually changed.
- **Breaking Change**: [#817](https://github.com/groue/GRDB.swift/pull/817): Allow query planner to optimize some boolean tests
## 5.0.0-beta.9
Released July 23, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.8...v5.0.0-beta.9)
- **New**: [#813](https://github.com/groue/GRDB.swift/pull/813): Expose SQLite 3.31.1 APIs to iOS, macOS, tvOS, watchOS
- **Fixed**: [#814](https://github.com/groue/GRDB.swift/pull/814): Fix regression with views
## 5.0.0-beta.8
Released July 19, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.7...v5.0.0-beta.8)
- **New**: [#811](https://github.com/groue/GRDB.swift/pull/811): Introduce RenameColumnAdapter
## 5.0.0-beta.7
Released July 14, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.6...v5.0.0-beta.7)
- **New**: [#802](https://github.com/groue/GRDB.swift/pull/802) by [@GetToSet](https://github.com/GetToSet): Add tokenchars support for ascii tokenizer in FTS5
- **New**: `fetchSet` has joined `fetchCursor`, `fetchAll` and `fetchOne` in the group of universal fetching methods.
- **Breaking Change**: [#803](https://github.com/groue/GRDB.swift/pull/803): Remove FetchedRecordsController
- **Breaking Change**: Removed `TableRecord.primaryKey` and `selectPrimaryKey(as:)` introduced in 5.0.0-beta.5
- **Breaking Change**: Many types and methods that support the query builder used to be publicly exposed and flagged as experimental. They are now private, or renamed with an underscore prefix, which means they are not for public use.
- **Breaking Change**: Defining custom `FetchRequest` types is no longer supported.
- **Breaking Change**: Defining custom `RowAdapter` types is no longer supported.
- **Fixed**: Fix rare occurences of an `SQLITE_BUSY` error when opening a DatabaseSnapshot.
- **Fixed**: Work around an SQLite bug which prevents rollbacking a transaction with `sqlite3_commit_hook`.
- The [How do I filter records and only keep those that are NOT associated to another record?](README.md#how-do-i-filter-records-and-only-keep-those-that-are-not-associated-to-another-record) FAQ has been updated.
## 5.0.0-beta.6
Released June 29, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.5...v5.0.0-beta.6)
- **New**: [#798](https://github.com/groue/GRDB.swift/pull/798): Debugging operators for ValueObservation
- **New**: [#800](https://github.com/groue/GRDB.swift/pull/800): Xcode 12 support
- **New**: [#801](https://github.com/groue/GRDB.swift/pull/801): Combine support
- **New**: Faster decoding of Date and DateComponents
### Documentation Diff
- The [ValueObservation Operators](README.md#valueobservation-operators) chapter was extended with a description of the two new debugging operators `handleEvents` and `print`.
- A new [GRDB ❤️ Combine](Documentation/Combine.md) guide describes the various Combine publishers that read, write, and observe the database.
- [GRDBCombineDemo](Documentation/DemoApps/GRDBCombineDemo/README.md) is a new Combine + SwiftUI demo application.
## 5.0.0-beta.5
Released June 15, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.4...v5.0.0-beta.5)
- **Breaking Change** [#795](https://github.com/groue/GRDB.swift/pull/795): Enhanced support for WAL Checkpoints
- **New**: `Database.maximumStatementArgumentCount` returns the maximum number of arguments accepted by an SQLite statement.
- **New**: Optimize DatabasePool handling of ValueObservation when SQLite is compiled with the SQLITE_ENABLE_SNAPSHOT option. We are now able to avoid fetching the observed value when we can prove that the database wasn't changed between the initial fetch and the beginning of transaction tracking. This optimization avoids duplicate notifications.
- **New**: The query interface now exposes the primary key through `TableRecord.primaryKey`, as well as the `selectPrimaryKey(as:)` method.
### Documentation Diff
- The [Demo Application](Documentation/DemoApps/GRDBDemoiOS) was updated for better conformance with the [Good Practices for Designing Record Types](Documentation/GoodPracticesForDesigningRecordTypes.md) Guide.
- A new [FAQ: Associations](README.md#faq-associations) addresses three frequent questions:
- [How do I filter records and only keep those that are associated to another record?](README.md#how-do-i-filter-records-and-only-keep-those-that-are-associated-to-another-record)
- [How do I filter records and only keep those that are NOT associated to another record?](README.md#how-do-i-filter-records-and-only-keep-those-that-are-not-associated-to-another-record)
- [How do I select only one column of an associated record?](README.md#how-do-i-select-only-one-column-of-an-associated-record)
- The guide for [Custom SQLite builds](Documentation/CustomSQLiteBuilds.md) now recommends enabling the `SQLITE_ENABLE_SNAPSHOT` option.
## 5.0.0-beta.4
Released June 6, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.3...v5.0.0-beta.4)
### Documentation Diff
- [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md) was updated for RxGRDB and GRDBCombine 1.0 beta 2, which haved change their way to configure how ValueObservation schedules fresh database values.
- The [SQL Functions](README.md#sql-functions) chapter was updated for the new `julianDay` and `dateTime` functions.
### New
- [#794](https://github.com/groue/GRDB.swift/pull/794): Name of Database Connections
- Add the `julianDay` and `dateTime` functions
## 5.0.0-beta.3
Released June 1, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.2...v5.0.0-beta.3)
### Documentation Diff
- Updated FAQ: [How do I print a request as SQL?](README.md#how-do-i-print-a-request-as-sql)
- New FAQ: [How do I monitor the duration of database statements execution?](README.md#how-do-i-monitor-the-duration-of-database-statements-execution)
### Fixed
- [#784](https://github.com/groue/GRDB.swift/pull/784): Fix observation of eager-loaded to-many associations
### Breaking Changes
- [#790](https://github.com/groue/GRDB.swift/pull/790): Bump required iOS version to 10.0
- [#791](https://github.com/groue/GRDB.swift/pull/791): Extend tracing of statement execution
## 5.0.0-beta.2
Released May 11, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta...v5.0.0-beta.2)
### Documentation Diff
- [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md) describes the sunsetting of custom `FetchRequest` types.
- The [Sharing a Database](Documentation/SharingADatabase.md) guide has an updated recommendation for opening writer connections to a shared database.
### New
- [#772](https://github.com/groue/GRDB.swift/pull/772): Update the Database Sharing Guide with mention of the persistent WAL mode
- [#775](https://github.com/groue/GRDB.swift/pull/775): DatabaseMigrator can check if it has been superseded
### Breaking Changes
- [#774](https://github.com/groue/GRDB.swift/pull/774): All requests are usable as SQL expressions and collections
### Fixed
- [#773](https://github.com/groue/GRDB.swift/pull/773): Allow subqueries to refer to outer tables
## 5.0.0-beta
Released May 2, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.14.0...v5.0.0-beta)
GRDB 5 is a release focused on **Swift 5.2**, and **removing technical debt**.
There are breaking changes, though as few as possible. They open the door for future library improvements. And they have GRDB, [GRDBCombine](http://github.com/groue/GRDBCombine), and [RxGRDB](http://github.com/RxSwiftCommunity/RxGRDB) offer a common behavior.
New features include support for SQL subqueries, and a simplified handling of database errors. The most demanding users will also find it easier to switch between the system SQLite, SQLCipher, and custom SQLite builds.
<details>
<summary>A glimpse on the new features</summary>
All requests can now be used as subqueries:
```swift
// Define a request with the query interface or raw SQL
let maximumScore = Player.select(max(Column("score")))
let maximumScore: SQLRequest<Int> = "SELECT MAX(score) FROM player"
// Use the request as a subquery in the query interface
let request = Player.filter(Column("score") == maximumScore)
let bestPlayers = try request.fetchAll(db)
// Use the request as a subquery in SQL requests
let request: SQLRequest<Player> = "SELECT * FROM player WHERE score = (\(maximumScore))"
let bestPlayers = try request.fetchAll(db)
```
Catch specific SQLite error codes in a simplified fashion:
```swift
do {
try ...
} catch DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY {
// foreign key constraint error
} catch DatabaseError.SQLITE_CONSTRAINT {
// any other constraint error
} catch {
// any other database error
}
```
Reuse the same code for system SQLite, SQLCipher, and custom SQLite builds:
```swift
// Supported in all GRDB flavors
import GRDB
let sqliteVersion = String(cString: sqlite3_libversion())
```
</details>
### Documentation Diff
- **[Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)**: how to upgrade your apps, and deal with breaking changes.
- [ValueObservation](README.md#valueobservation): this chapter describes the new ValueObservation behaviors.
- [DatabaseError](README.md#databaseerror): learn how to catch and match DatabaseError on their codes, in a fashion similar to `CocoaError`.
- [Batch Updates](README.md#update-requests): this chapter is updated for the new `set(to:)` method.
- [SQL Operators](README.md#sql-operators): introduces support for SQL and query interface subqueries.
- [How do I print a request as SQL?](README.md#how-do-i-print-a-request-as-sql) This FAQ was updated for GRDB 5.
- [SQL Interpolation](Documentation/SQLInterpolation.md): this guide now describes how to embed subqueries and record columns in your SQL literals.
- [Joined Queries Support](README.md#joined-queries-support): describes the GRDB 5 way of dealing with complex and hand-crafted SQL queries.
- [Raw SQLite Pointers](README.md#raw-sqlite-pointers) and [Custom SQLite builds](Documentation/CustomSQLiteBuilds.md): `import GRDB` now provides access to the full [C SQLite API](https://www.sqlite.org/capi3ref.html), and custom SQLite builds.
### New
- [#749](https://github.com/groue/GRDB.swift/pull/749): Drop submodules used by performance tests
- [#754](https://github.com/groue/GRDB.swift/pull/754): Match DatabaseError on ResultCode
- [#756](https://github.com/groue/GRDB.swift/pull/756): Export the underlying SQLite library
### Breaking Changes
- [#719](https://github.com/groue/GRDB.swift/pull/719): Bump required Swift version to 5.2
- [#720](https://github.com/groue/GRDB.swift/pull/720): Turn deprecated APIs into unavailable ones
- [#722](https://github.com/groue/GRDB.swift/pull/722): SE-0253: Callable values of user-defined nominal types
- [#728](https://github.com/groue/GRDB.swift/pull/728): Make ValueObservation error handling mandatory
- [#729](https://github.com/groue/GRDB.swift/pull/729): ValueObservation always emits an initial value
- [#731](https://github.com/groue/GRDB.swift/pull/731): Hide ValueObservation implementation details
- [#732](https://github.com/groue/GRDB.swift/pull/732): Remove ValueObservation.compactMap
- [#736](https://github.com/groue/GRDB.swift/pull/736): Relax ValueObservation Guarantees
- [#737](https://github.com/groue/GRDB.swift/pull/737): Force implicit database region for ValueObservation
- [#738](https://github.com/groue/GRDB.swift/pull/738): Remove all observationForCount/All/First methods
- [#742](https://github.com/groue/GRDB.swift/pull/742): ValueObservation scheduling is no longer an attribute of the observation
- [#745](https://github.com/groue/GRDB.swift/pull/745): Explicit ValueObservation cancellation
- [#747](https://github.com/groue/GRDB.swift/pull/747): Rename GRDBCustomSQLite to GRDB
- [#750](https://github.com/groue/GRDB.swift/pull/750): Batch updates do not need any operator
- [#752](https://github.com/groue/GRDB.swift/pull/752): Remove ValueObservation.combine
- [#770](https://github.com/groue/GRDB.swift/pull/770): Subqueries
### Fixed
- [#601](https://github.com/groue/GRDB.swift/pull/601): ValueObservation won't start until concurrent write transaction has ended
- [#697](https://github.com/groue/GRDB.swift/pull/697): `SQLInterpolation` could not work with `QueryInterfaceRequest`
- [#743](https://github.com/groue/GRDB.swift/pull/743): Rename GRDBCustomSQLite to GRDB for compatibility with dependents?
## 4.14.0
Released April 23, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.13.0...v4.14.0)
**New**
- [#766](https://github.com/groue/GRDB.swift/pull/766) by [@mtancock](https://github.com/mtancock): Add Codable support to DatabaseDateComponents
## 4.13.0
Released April 15, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.12.2...v4.13.0)
**Fixed**
- Restored support for Xcode 10.0 and Xcode 10.1, broken in 4.12.2
- [#759](https://github.com/groue/GRDB.swift/pull/759): Fix batch updates of complex requests
**New**
- [#761](https://github.com/groue/GRDB.swift/pull/761): Deprecate the batch update `<-` operator
## 4.12.2
Released April 13, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.12.1...v4.12.2)
**Fixed**
- [#757](https://github.com/groue/GRDB.swift/pull/757): Don't load association inflections unless necessary
## 4.12.1
Released March 29, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.12.0...v4.12.1)
**Fixed**
- [#744](https://github.com/groue/GRDB.swift/pull/744): Fix DatabaseMigrator deadlock with serial target queues
## 4.12.0
Released March 21, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.11.0...v4.12.0)
**New**
- Batch updates now accept nil assignments:
```swift
// UPDATE player SET score = NULL
try Player.updateAll(db, scoreColumn <- nil)
```
- DatabaseMigrator can now recreate the database if a migration has been removed, or renamed (addresses [#725](https://github.com/groue/GRDB.swift/issues/725)).
- DatabaseMigrator querying methods have been enhanced:
```swift
// New
dbQueue.read(migrator.hasCompletedMigrations)
dbQueue.read(migrator.completedMigrations).contains("v2")
dbQueue.read(migrator.completedMigrations).last == "v2"
dbQueue.read(migrator.appliedMigrations)
// Deprecated
migrator.hasCompletedMigrations(in: dbQueue)
migrator.hasCompletedMigrations(in: dbQueue, through: "v2")
migrator.lastCompletedMigration(in: dbQueue) == "v2"
migrator.appliedMigrations(in: dbQueue)
```
## 4.11.0
Released March 2, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.10.0...v4.11.0)
### New
- [#706](https://github.com/groue/GRDB.swift/pull/706): Enhance SQLLiteral and SQL interpolation again
- [#710](https://github.com/groue/GRDB.swift/pull/710): Check if all migrations have been applied
- [#712](https://github.com/groue/GRDB.swift/pull/712) by [@pakko972](https://github.com/pakko972): Automatic iOS memory management
- [#713](https://github.com/groue/GRDB.swift/pull/713): Enhance DatabaseMigrator isolation
### Breaking Change
- [#709](https://github.com/groue/GRDB.swift/pull/709): Simplify DatabaseMigrator API
Database migrations have a new behavior which is a breaking change. However, it is very unlikely to impact your application.
In previous versions of GRDB, a foreign key violation would immediately prevent a migration from successfully complete. Now, foreign key checks are deferred until the end of each migration. This means that some migrations will change their behavior:
```swift
// Used to fail, now succeeds
migrator.registerMigration(...) { db in
try violateForeignKeyConstraint(db)
try fixForeignKeyConstraint(db)
}
// The catch clause is no longer called
migrator.registerMigration(...) { db in
do {
try performChanges(db)
} catch let error as DatabaseError where error.resultCode == .SQL_CONSTRAINT {
// Handle foreign key error
}
}
```
If your application happens to define migrations that are impacted by this change, please open an issue so that we find a way to restore the previous behavior.
## 4.10.0
Released February 23, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.9.0...v4.10.0)
**New**
- [#689](https://github.com/groue/GRDB.swift/pull/689) by [@gjeck](https://github.com/gjeck): Add support for renaming columns within a table
- [#690](https://github.com/groue/GRDB.swift/pull/690): Enhance SQLLiteral and SQL interpolation
## 4.9.0
Released January 17, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.8.1...v4.9.0)
**New**
- [#683](https://github.com/groue/GRDB.swift/pull/683): String concatenation
- [#685](https://github.com/groue/GRDB.swift/pull/685) by [@gjeck](https://github.com/gjeck): Add cache for TableRecord.defaultDatabaseTableName
## 4.8.1
Released January 12, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.8.0...v4.8.1)
**Fixed**
- [#677](https://github.com/groue/GRDB.swift/pull/677): Fix associations altered by another association
## 4.8.0
Released January 8, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.7.0...v4.8.0)
**New**
- [#676](https://github.com/groue/GRDB.swift/pull/676): More batch delete and update
## 4.7.0
Released December 18, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.6.2...v4.7.0)
**New**
- [#656](https://github.com/groue/GRDB.swift/pull/656): Type inference of selected columns
- [#659](https://github.com/groue/GRDB.swift/pull/659): Database interruption
- [#660](https://github.com/groue/GRDB.swift/pull/660): Database Lock Prevention
- [#662](https://github.com/groue/GRDB.swift/pull/662): Upgrade custom SQLite builds to version 3.30.1 (thanks to [@swiftlyfalling](https://github.com/swiftlyfalling/SQLiteLib))
- [#668](https://github.com/groue/GRDB.swift/pull/668): Database Suspension
### Breaking Changes
[Custom SQLite builds](Documentation/CustomSQLiteBuilds.md) now disable by default the support for the [Double-quoted String Literals misfeature](https://sqlite.org/quirks.html#dblquote). This is a technically a breaking change, but it fixes an SQLite bug. You can restore the previous behavior if your application relies on it:
```swift
// Enable support for the Double-quoted String Literals misfeature
var configuration = Configuration()
configuration.acceptsDoubleQuotedStringLiterals = true
let dbQueue = try DatabaseQueue(path: ..., configuration: configuration)
```
### Documentation Diff
The new [Interrupt a Database](README.md#interrupt-a-database) chapter documents the new `interrupt()` method.
The new [Sharing a Datatase in an App Group Container](Documentation/AppGroupContainers.md) guide explains how to setup GRDB when you share a database in an iOS App Group container.
### API Diff
```diff
struct Configuration {
+ var observesSuspensionNotifications: Bool // Experimental
+ var acceptsDoubleQuotedStringLiterals: Bool
}
class Database {
+ static let suspendNotification: Notification.Name // Experimental
+ static let resumeNotification: Notification.Name // Experimental
}
extension DatabaseError {
+ var isInterruptionError: Bool { get }
}
protocol DatabaseReader {
+ func interrupt()
}
extension SQLSpecificExpressible {
+ #if GRDBCUSTOMSQLITE
+ var ascNullsLast: SQLOrderingTerm { get }
+ var descNullsFirst: SQLOrderingTerm { get }
+ #endif
}
```
## 4.6.2
Released November 20, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.6.1...v4.6.2)
**Fixed**
- [#653](https://github.com/groue/GRDB.swift/pull/653) by [@michaelkirk-signal](https://github.com/michaelkirk-signal): Fix DatabaseMigrator.appliedMigrations() error on empty database
## 4.6.1
Released November 10, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.6.0...v4.6.1)
**Fixed**
- [#647](https://github.com/groue/GRDB.swift/pull/647): Honor conflict resolution for batch updates
## 4.6.0
Released November 9, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.5.0...v4.6.0)
**New**
- [#646](https://github.com/groue/GRDB.swift/pull/646): Batch updates
### Documentation Diff
The [Update Requests](README.md#update-requests) chapter documents the new support for batch updates introduced in the [query interface](README.md#the-query-interface).
The [Associations Guide](Documentation/AssociationsBasics.md) has gained a new [Ordered Associations](Documentation/AssociationsBasics.md#ordered-associations) chapter which explains how to define ordered HasMany and HasManyThrough associations.
## 4.5.0
Released October 15, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.4.0...v4.5.0)
**Fixed**
- The `DatabaseMigrator.eraseDatabaseOnSchemaChange` option no longer fails when migrations depend on database configuration.
- Fixed `DatabasePool.reentrantRead` which was not actually reentrant.
- [#631](https://github.com/groue/GRDB.swift/pull/631): Fix custom SQLite builds
- [#632](https://github.com/groue/GRDB.swift/pull/632) by [@runhum](https://github.com/runhum): Fix documentation typo
**New**
- [#622](https://github.com/groue/GRDB.swift/pull/622): Allow observation of FTS4 virtual tables
- [#627](https://github.com/groue/GRDB.swift/pull/627): Swift Package Manager: define SQLite as a system library target
- [#633](https://github.com/groue/GRDB.swift/pull/633): SQLITE_ENABLE_PREUPDATE_HOOK support with CocoaPods
- [#635](https://github.com/groue/GRDB.swift/pull/635): Sunset FetchedRecordsController
### Documentation Diff
The [Support for SQLite Pre-Update Hooks](README.md#support-for-sqlite-pre-update-hooks) chapter has been updated with a way to enable extra GRDB APIs for the SQLITE_ENABLE_PREUPDATE_HOOK option with CocoaPods.
The [Demo Application](Documentation/DemoApps/GRDBDemoiOS) no longer uses [FetchedRecordsController](Documentation/FetchedRecordsController.md), which has been sunsetted. Instead, it tracks database changes with [ValueObservation](README.md#valueobservation), and animates its table view with the Swift built-in [difference(from:)](https://developer.apple.com/documentation/swift/bidirectionalcollection/3200721-difference) method.
## 4.4.0
Released September 6, 2019 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v4.3.0...v4.4.0)
### New
- [#602](https://github.com/groue/GRDB.swift/pull/602): Don't keep the sqlCipher passphrase in memory longer than necessary
- [#603](https://github.com/groue/GRDB.swift/pull/603): DatabasePool write barrier
### Documentation Diff
SQLCipher passphrase management has been refactored: you will get deprecation warnings. Check out the rewritten [Encryption](README.md#encryption) chapter in order to migrate your code and remove those warnings.
The [Advanced DatabasePool](README.md#advanced-databasepool) chapter has been extended for the new `barrierWriteWithoutTransaction` method.
### API Diff
**Deprecations**
```diff
class DatabaseQueue {
+ @available(*, deprecated)
func change(passphrase: String) throws
}
class DatabasePool {
+ @available(*, deprecated)
func change(passphrase: String) throws
}
struct Configuration {
+ @available(*, deprecated)
var passphrase: String?
}
```
**New Methods**
```diff
class DatabasePool {
+ func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
+ func invalidateReadOnlyConnections()
}
class Database {
+ func usePassphrase(_ passphrase: String) throws
+ func changePassphrase(_ passphrase: String) throws
+ var lastErrorCode: ResultCode
+ var lastErrorMessage: String?
}
```
## 4.3.0
@@ -1175,7 +1814,7 @@ Released September 23, 2018 &bull; [diff](https://github.com/groue/GRDB.swift/co
### Documentation Diff
- Enhanced visibility of the [Demo Application](DemoApps/GRDBDemoiOS)
- Enhanced visibility of the [Demo Application](Documentation/DemoApps/GRDBDemoiOS)
## 3.3.0
@@ -1881,7 +2520,7 @@ Released September 17, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/co
**Fixed**: restored support for Swift Package Manager
## 2.0
## 2.0.0
Released September 16, 2017 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v1.3.0...v2.0)
-62
View File
@@ -78,14 +78,10 @@ The ideas, in alphabetical order:
- [Date and Time Functions]
- [Decode NSDecimalNumber from Text Columns]
- [Documentation]
- [FetchedRecordsController Diffing Algorithm]
- [FetchedRecordsController Support for Any Request]
- [FetchedRecordsController Support for Sections]
- [Full Text Search Demo Application]
- [JSON]
- [Linux]
- [More SQL Generation]
- [Reactive Database Observation]
- [SQL Console in the Debugger]
- [SQLCipher in a Shared App Container]
- [Typed Expressions]
@@ -205,50 +201,6 @@ Inline documentation, the one which is embedded right into the source code and i
If you are a good writer, your help will be very warmly welcomed.
### FetchedRecordsController Diffing Algorithm
:muscle: Hard
[FetchedRecordsController] uses a Levenshtein-based diffing algorithm which has a terrible algorithmic complexity. This makes this very useful class unable to deal with more than hundreds of elements.
There exists much more efficient O(n) diffing algorithms that would lift this limitation.
Starting points:
- [RxSwiftCommunity/RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources)
- [ra1028/DifferenceKit](https://github.com/ra1028/DifferenceKit)
- [tonyarnold/Differ](https://github.com/tonyarnold/Differ)
- [onmyway133/DeepDiff](https://github.com/onmyway133/DeepDiff)
- [mcudich/HeckelDiff](https://github.com/mcudich/HeckelDiff)
### FetchedRecordsController Support for Any Request
:muscle: Hard
[FetchedRecordsController] is able to deal with records, but not with raw rows or values:
```swift
// Supported by FetchedRecordsController
let recordRequest = Player.all()
// Not supported by FetchedRecordsController
let stringRequest = Player.select(Column("name"), as: String.self)
let rowRequest = SQLRequest<Row>("SELECT ...")
```
This limitation does not apply to [ValueObservation] and [RxGRDB]. It would be nice if FetchedRecordsController would become just as versatile.
### FetchedRecordsController Support for Sections
:muscle: Hard
[FetchedRecordsController] mimics the API of Core Data's [NSFetchedResultsController](https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller), but does not yet support table and collection view sections.
This improvement most certainly depends on a refreshing of the [FetchedRecordsController Diffing Algorithm].
### Full Text Search Demo Application
:baby: Starter Task :pencil: Documentation
@@ -294,15 +246,6 @@ There are several SQLite features that GRDB could natively support:
See [issue #575](https://github.com/groue/GRDB.swift/issues/575) for more information and guidance about the implementation of extra table alterations.
### Reactive Database Observation
:baby: Starter Task
We already have the [GRDBCombine](http://github.com/groue/GRDBCombine) and [RxGRDB] companion libraries.
More choices of reactive engines would help more developers enjoy GRDB.
### SQL Console in the Debugger
:question: Unknown Difficulty :hammer: Tooling
@@ -360,17 +303,12 @@ Features that blur this focus are non-goals:
[Date and Time Functions]: #date-and-time-functions
[Decode NSDecimalNumber from Text Columns]: #decode-nsdecimalnumber-from-text-columns
[Documentation]: #documentation
[FetchedRecordsController]: README.md#fetchedrecordscontroller
[FetchedRecordsController Diffing Algorithm]: #fetchedrecordscontroller-diffing-algorithm
[FetchedRecordsController Support for Any Request]: #fetchedrecordscontroller-support-for-any-request
[FetchedRecordsController Support for Sections]: #fetchedrecordscontroller-support-for-sections
[Full Text Search Demo Application]: #full-text-search-demo-application
[How is the Library Organized?]: Documentation/LibraryOrganization.md
[How is the Repository Organized?]: Documentation/RepositoryOrganization.md
[JSON]: #json
[Linux]: #linux
[More SQL Generation]: #more-sql-generation
[Reactive Database Observation]: #reactive-database-observation
[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
@@ -1,56 +0,0 @@
import GRDB
/// A type responsible for initializing the application database.
///
/// See AppDelegate.setupDatabase()
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/blob/master/README.md#database-connections
let dbQueue = try DatabaseQueue(path: path)
// Define the database schema
try migrator.migrate(dbQueue)
return dbQueue
}
/// The DatabaseMigrator that defines the database schema.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#migrations
static var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
migrator.registerMigration("createPlayer") { db in
// Create a table
// See https://github.com/groue/GRDB.swift#create-tables
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
// Sort player names in a localized case insensitive fashion by default
// See https://github.com/groue/GRDB.swift/blob/master/README.md#unicode
t.column("name", .text).notNull().collate(.localizedCaseInsensitiveCompare)
t.column("score", .integer).notNull()
}
}
migrator.registerMigration("fixtures") { db in
// Populate the players table with random data
for _ in 0..<8 {
var player = Player(id: nil, name: Player.randomName(), score: Player.randomScore())
try player.insert(db)
}
}
// // Migrations for future application versions will be inserted here:
// migrator.registerMigration(...) { db in
// ...
// }
return migrator
}
}
@@ -1,26 +0,0 @@
import UIKit
import GRDB
// The shared database queue
var dbQueue: DatabaseQueue!
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
try! setupDatabase(application)
return true
}
private func setupDatabase(_ application: UIApplication) throws {
let databaseURL = try FileManager.default
.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("db.sqlite")
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/blob/master/README.md#memory-management
dbQueue.setupMemoryManagement(in: application)
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
@@ -1,63 +0,0 @@
import GRDB
// A plain Player struct
struct Player {
// Prefer Int64 for auto-incremented database ids
var id: Int64?
var name: String
var score: Int
}
// 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 {
// Define database columns from CodingKeys
private enum Columns {
static let id = Column(CodingKeys.id)
static let name = Column(CodingKeys.name)
static let score = Column(CodingKeys.score)
}
// 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 {
static func orderedByName() -> QueryInterfaceRequest<Player> {
return Player.order(Columns.name)
}
static func orderedByScore() -> QueryInterfaceRequest<Player> {
return Player.order(Columns.score.desc, Columns.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.randomElement()!
}
static func randomScore() -> Int {
return 10 * Int.random(in: 0...100)
}
}
@@ -1,265 +0,0 @@
import UIKit
import GRDB
/// PlayersViewController displays the list of players.
class PlayersViewController: UITableViewController {
private enum PlayerOrdering {
case byName
case 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(playersRequest)
configureOrderingBarButtonItem()
}
}
private var playersRequest: QueryInterfaceRequest<Player> {
switch playerOrdering {
case .byName:
return Player.orderedByName()
case .byScore:
return Player.orderedByScore()
}
}
override func viewDidLoad() {
super.viewDidLoad()
configureToolbar()
configureNavigationItem()
configureTableView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isToolbarHidden = false
}
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))
}
}
private func configureTitle() {
// Track changes in the number of players
let observation = ValueObservation.tracking { db in
try Player.fetchCount(db)
}
playerCountObserver = observation.start(
in: dbQueue,
onError: { error in
fatalError("Unexpected error: \(error)")
},
onChange: { [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"
}
})
}
private func configureTableView() {
// 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()
},
onChange: { [unowned self] (controller, record, change) in
switch change {
case .insertion(let indexPath):
self.tableView.insertRows(at: [indexPath], with: .fade)
case .deletion(let indexPath):
self.tableView.deleteRows(at: [indexPath], with: .fade)
case .update(let indexPath, _):
if let cell = self.tableView.cellForRow(at: indexPath) {
self.configure(cell, at: indexPath)
}
case .move(let indexPath, let newIndexPath, _):
// Actually move cells around for more demo effect :-)
let cell = self.tableView.cellForRow(at: indexPath)
self.tableView.moveRow(at: indexPath, to: newIndexPath)
if let cell = cell {
self.configure(cell, at: newIndexPath)
}
// A quieter animation:
// self.tableView.deleteRows(at: [indexPath], with: .fade)
// self.tableView.insertRows(at: [newIndexPath], with: .fade)
}
},
didChange: { [unowned self] _ in
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
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return playersController.sections[section].numberOfRecords
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Player", for: indexPath)
configure(cell, at: indexPath)
return cell
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
// Delete the player
let player = playersController.record(at: indexPath)
try! dbQueue.write { db in
_ = try player.delete(db)
}
}
private func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
let player = playersController.record(at: indexPath)
if player.name.isEmpty {
cell.textLabel?.text = "-"
} else {
cell.textLabel?.text = player.name
}
cell.detailTextLabel?.text = abs(player.score) > 1 ? "\(player.score) points" : "0 point"
}
}
// MARK: - Actions
extension PlayersViewController {
@IBAction func sortByName() {
setEditing(false, animated: true)
playerOrdering = .byName
}
@IBAction func sortByScore() {
setEditing(false, animated: true)
playerOrdering = .byScore
}
@IBAction func deletePlayers() {
setEditing(false, animated: true)
try! dbQueue.write { db in
_ = try Player.deleteAll(db)
}
}
@IBAction func refresh() {
setEditing(false, animated: true)
refreshPlayers()
}
@IBAction func stressTest() {
setEditing(false, animated: true)
for _ in 0..<50 {
DispatchQueue.global().async {
self.refreshPlayers()
}
}
}
private func refreshPlayers() {
try! dbQueue.write { db in
if try Player.fetchCount(db) == 0 {
// Insert new random players
for _ in 0..<8 {
var player = Player(id: nil, name: Player.randomName(), score: Player.randomScore())
try player.insert(db)
}
} else {
// Insert a player
if Bool.random() {
var player = Player(id: nil, name: Player.randomName(), score: Player.randomScore())
try player.insert(db)
}
// Delete a random player
if Bool.random() {
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
}
// Update some players
for var player in try Player.fetchAll(db) where Bool.random() {
player.score = Player.randomScore()
try player.update(db)
}
}
}
}
}
-32
View File
@@ -1,32 +0,0 @@
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.
+4
View File
@@ -0,0 +1,4 @@
Sharing a Database in an App Group Container
============================================
This guide [has moved](SharingADatabase.md).
+249 -142
View File
@@ -11,6 +11,7 @@ GRDB Associations
- [HasOneThrough]
- [Choosing Between BelongsTo and HasOne]
- [Self Joins]
- [Associations to Common Table Expressions]
- [Associations and the Database Schema]
- [Convention for Database Table Names]
- [Convention for the BelongsTo Association]
@@ -23,6 +24,7 @@ GRDB Associations
- [Combining Associations]
- [Filtering Associations]
- [Sorting Associations]
- [Ordered Associations]
- [Columns Selected by an Association]
- [Table Aliases]
- [Refining Association Requests]
@@ -38,7 +40,14 @@ GRDB Associations
- [Aggregate Operations]
- [Isolation of Multiple Aggregates]
- [DerivableRequest Protocol]
- [Known Issues]
**[FAQ]**
- [How do I filter records and only keep those that are associated to another record?](../README.md#how-do-i-filter-records-and-only-keep-those-that-are-associated-to-another-record)
- [How do I filter records and only keep those that are NOT associated to another record?](../README.md#how-do-i-filter-records-and-only-keep-those-that-are-not-associated-to-another-record)
- [How do I select only one column of an associated record?](../README.md#how-do-i-select-only-one-column-of-an-associated-record)
**[Known Issues]**
## Associations Benefits
@@ -90,14 +99,14 @@ With GRDB associations, we can streamline these operations (and others), by decl
extension Author {
static let books = hasMany(Book.self)
var books: QueryInterfaceRequest<Book> {
return request(for: Author.books)
request(for: Author.books)
}
}
extension Book {
static let author = belongsTo(Author.self)
var author: QueryInterfaceRequest<Author> {
return request(for: Book.author)
request(for: Book.author)
}
}
```
@@ -108,7 +117,7 @@ Loading all books from an existing author is now easier:
let books = try author.books.fetchAll(db)
```
As for loading all pairs of books and authors, it is not only easier, but also *far much efficient*:
As for loading all pairs of books and authors, it is not only easier, but also *much more efficient*:
```swift
struct BookInfo: FetchableRecord, Decodable {
@@ -164,7 +173,7 @@ Generally speaking, associations use the [TableRecord], [FetchableRecord], and [
extension Book: EncodableRecord {
// The request for the author of a book.
var author: QueryInterfaceRequest<Author> {
return request(for: Book.author)
request(for: Book.author)
}
}
@@ -183,17 +192,20 @@ Generally speaking, associations use the [TableRecord], [FetchableRecord], and [
The Types of Associations
=========================
GRDB handles five types of associations:
GRDB handles several types of associations:
- **BelongsTo**
- **HasMany**
- **HasOne**
- **HasManyThrough**
- **HasOneThrough**
- **Associations to common table expressions**
An association declares a link from a record type to another, as in "one book **belongs to** its author". It instructs GRDB to use the foreign keys declared in the database as support for Swift methods.
An association generally declares a link from a record type to another, as in "one book **belongs to** its author". It instructs GRDB to use the foreign keys declared in the database as support for Swift methods.
Each one of the three types of associations is appropriate for a particular database situation.
Each one of these associations is appropriate for a particular database situation.
Associations to [common table expressions] are specific enough and are documented in [Associations to Common Table Expressions].
- [BelongsTo]
- [HasMany]
@@ -282,7 +294,7 @@ See [Convention for the HasOne Association] for some sample code that defines th
The **HasManyThrough** association is often used to set up a many-to-many connection with another record. This association indicates that the declaring record can be matched with zero or more instances of another record by proceeding through a third record. For example, consider the practice of passport delivery. The relevant association declarations could look like this:
```swift
struct Country: TableRecord, EncodableRecord {
struct Country: TableRecord {
static let passports = hasMany(Passport.self)
static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
...
@@ -293,7 +305,7 @@ struct Passport: TableRecord {
static let citizen = belongsTo(Citizen.self)
}
struct Citizen: TableRecord, EncodableRecord {
struct Citizen: TableRecord {
static let passports = hasMany(Passport.self)
static let countries = hasMany(Country.self, through: passports, using: Passport.country)
...
@@ -326,7 +338,7 @@ As in the examples above, **HasManyThrough** association is always built from tw
```swift
struct Document: TableRecord {
static let paragraphs = hasMany(
Paragraph.self,
Paragraph.self,
through: Document.hasMany(Section.self),
using: Section.hasMany(Paragraph.self))
...
@@ -341,9 +353,9 @@ See [Building Requests from Associations] in order to learn how to use the HasMa
A **HasOneThrough** association sets up a one-to-one connection with another record. This association indicates that the declaring record can be matched with one instance of another record by proceeding through a third record. For example, if each book belongs to a library, and each library has one address, then one knows where the book should be returned to:
```swift
struct Book: TableRecord, EncodableRecord {
struct Book: TableRecord {
static let library = belongsTo(Library.self)
static let returnAddress = hasOne(Address.self, through: library, using: library.address)
static let returnAddress = hasOne(Address.self, through: library, using: Library.address)
...
}
@@ -685,7 +697,7 @@ See [Foreign Keys] for more information.
**Associations can automatically infer the foreign keys that define how two database tables are linked together.**
In the example below, the `book.authorId` column is automatically used to link a book to its author:
In the example below, the `book.authorId` column is automatically used to link a book to its author, because the database schema defines a foreign key between the book and author database tables (see [Convention for the BelongsTo Association]).
![BelongsToSchema](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/Associations2/BelongsToSchema.svg)
@@ -699,7 +711,9 @@ struct Author: TableRecord {
}
```
But this requires the database schema to define a foreign key between the book and author database tables (see [Convention for the BelongsTo Association]).
> :point_up: **Note**: Generally speaking, all foreign keys are supported, including composite keys that span several columns.
>
> :warning: **Warning**: SQLite voids foreign key constraints when one or more of a foreign key column is NULL (see [SQLite Foreign Key Support](https://www.sqlite.org/foreignkeys.html)). GRDB does not match foreign keys that involve a NULL value either.
Sometimes the database schema does not define any foreign key. And sometimes, there are *several* foreign keys from a table to another.
@@ -765,6 +779,7 @@ Fetch requests do not visit the database until you fetch values from them. This
- [Combining Associations]
- [Filtering Associations]
- [Sorting Associations]
- [Ordered Associations]
- [Columns Selected by an Association]
- [Table Aliases]
- [Refining Association Requests]
@@ -783,7 +798,7 @@ struct Book: TableRecord, EncodableRecord {
/// The request for the author of a book
var author: QueryInterfaceRequest<Author> {
return request(for: Book.author)
request(for: Book.author)
}
}
```
@@ -804,7 +819,7 @@ struct Author: TableRecord, EncodableRecord {
/// The request for the books of an author
var books: QueryInterfaceRequest<Book> {
return request(for: Author.books)
request(for: Author.books)
}
}
@@ -1109,6 +1124,104 @@ let request = Book
Those extra sorting options require **[Table Aliases]**, introduced below.
## Ordered Associations
By default, **[HasMany]** or **[HasManyThrough]** associations are unordered: the order of associated records is undefined unless [explicitly specified](#sorting-associations) on each request.
But you can build an ordering right into the definition of an association, so that it becomes the default ordering for this association. For example, let's model soccer teams and players, ordered by the number printed on their shirt.
Let's start with a **HasMany** association. Each player knows its position in its team:
```swift
struct Team: FetchableRecord, TableRecord {
var id: Int64
var name: String
}
struct Player: FetchableRecord, TableRecord {
var id: Int64
var teamId: Int64
var name: String
var position: Int
}
```
The `Team.players` association is ordered by position, so that all team players are loaded well-sorted by default:
```swift
extension Team {
static let players = hasMany(Player.self).order(Column("position"))
var players: QueryInterfaceRequest<Player> {
request(for: Team.players)
}
}
```
Things are very similar for **HasManyThrough** associations. Now each player knows its position in the teams it belongs to:
```swift
struct Team: FetchableRecord, TableRecord {
var id: Int64
var name: String
}
struct PlayerRole: FetchableRecord, TableRecord {
var teamId: Int64
var playerId: Int64
var position: Int
}
struct Player: FetchableRecord, TableRecord {
var id: Int64
var name: String
}
```
Again, the `Team.players` association is ordered by position, so that all team players are loaded well-sorted by default:
```swift
extension Team {
static let playerRoles = hasMany(PlayerRole.self).order(Column("position"))
static let players = hasMany(Player.self, through: playerRoles, using: PlayerRole.player)
var players: QueryInterfaceRequest<Player> {
request(for: Team.players)
}
}
extension PlayerRole {
static let player = belongsTo(Player.self)
}
```
In both cases, you can escape the default ordering when you need it:
```swift
struct TeamInfo: Decodable, FetchableRecord {
var team: Team
var players: [Player]
}
// Default ordering by position
let team: Team = ...
let players = try team.players.fetchAll(db)
let teamInfos = try Team
.including(all: Team.players)
.asRequest(of: TeamInfo.self)
.fetchAll(db)
// Custom ordering
let team: Team = ...
let players = try team.players.order(Column("name")).fetchAll(db)
let teamInfos = try Team
.including(all: Team.players.order(Column("name")))
.asRequest(of: TeamInfo.self)
.fetchAll(db)
```
## Columns Selected by an Association
By default, associated records include all their columns:
@@ -1227,63 +1340,6 @@ 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`:
@@ -1331,6 +1387,60 @@ When you join or include an association several times, with the same **[associat
.including(optional: association.select(selection2))
```
**Those rules exist so that you can design fluent interfaces that build complex requests out of simple building blocks.**
For example, we can start by defining base requests as extensions to the [DerivableRequest Protocol]:
```swift
// Author requests
extension DerivableRequest where RowDecoder == Author {
/// Filters authors by country
func filter(country: String) -> Self {
filter(Column("country") == country)
}
}
// Book requests
extension DerivableRequest where RowDecoder == Book {
/// Filters books by author country
func filter(authorCountry: String) -> Self {
joining(required: Book.author.filter(country: country))
}
/// Order books by author name and then book title
func orderedByAuthorNameAndYear() -> Self {
let authorAlias = TableAlias()
return self
.joining(optional: Book.author.aliased(authorAlias))
.order(
authorAlias[Column("name")].collating(.localizedCaseInsensitiveCompare),
Column("year"))
}
}
```
And then compose those in a fluent style:
```swift
struct BookInfo: FetchableRecord, Decodable {
var book: Book
var author: Author
}
// SELECT book.*, author.*
// FROM book
// JOIN author ON author.id = book.authorId AND author.country = 'FR'
// ORDER BY author.name COLLATE ..., book.year
let bookInfos = try Book.all()
.filter(authorCountry: "FR")
.orderedByAuthorNameAndYear()
.including(required: Book.author)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
Remember that those refinement rules only apply when an association is joined or included several times, with the same **[association key](#the-structure-of-a-joined-request)**. Changing this key stops merging associations together. See [Isolation of Multiple Aggregates] for a longer discussion.
Fetching Values from Associations
=================================
@@ -1343,31 +1453,14 @@ Often, you'll also make it adopt the standard Decodable protocol, because the co
Each association included in the request can feed a property of the decoded record:
- `including(all:)` feeds an Array or Set property:
```swift
// All authors with their books
let request = Author.including(all: Author.books)
struct AuthorInfo: FetchableRecord, Decodable {
var author: Author
var books: [Book] // all associated books
}
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
- `including(optional:)` feeds an optional property:
```swift
// All employees with their manager and subordinate
let request = Employee
.including(optional: Employee.manager)
.including(all: Employee.subordinates)
let request = Employee.including(optional: Employee.manager)
struct EmployeeInfo: FetchableRecord, Decodable {
var employee: Employee
var manager: Employee? // the optional manager
var subordinates: Set<Employee>
var manager: Employee? // the optional associated manager
}
let employeeInfos: [EmployeeInfo] = try EmployeeInfo.fetchAll(db, request)
```
@@ -1375,22 +1468,28 @@ Each association included in the request can feed a property of the decoded reco
- `including(required:)` feeds an non-optional property:
```swift
// All books with information about their author, country, and cover image:
let request = Book
.including(required: Book.author
.including(optional: Author.country))
.including(optional: Book.coverImage)
let request = Book.including(required: Book.author)
struct BookInfo: FetchableRecord, Decodable {
var book: Book
var author: Author // the required author
var country: Country?
var coverImage: CoverImage?
var author: Author // the required associated author
}
let bookInfos: [BookInfo] = try BookInfo.fetchAll(db, request)
```
- `including(all:)` feeds an Array or Set property:
```swift
let request = Author.including(all: Author.books)
struct AuthorInfo: FetchableRecord, Decodable {
var author: Author
var books: [Book] // all associated books
}
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
- [The Structure of a Joined Request]
- [Decoding a Joined Request with a Decodable Record]
- [Decoding a Joined Request with FetchableRecord]
@@ -1524,8 +1623,7 @@ And who is the most able to know those coding keys? BookInfo itself, thanks to i
```swift
extension BookInfo {
static func all() -> QueryInterfaceRequest<BookInfo> {
return Book
.including(optional: Book.coverImage)
Book.including(optional: Book.coverImage)
.including(required: Book.author
.forKey(CodingKeys.authorInfo) // (1)
.including(optional: Person.country))
@@ -1545,7 +1643,7 @@ let bookInfos = try BookInfo.all().fetchAll(db, request) // [BookInfo]
## Decoding a Joined Request with FetchableRecord
When [Dedocable](#decoding-a-joined-request-with-a-decodable-record) records provides convenient decoding of joined rows, you may want a little more control over row decoding.
When [Decodable](#decoding-a-joined-request-with-a-decodable-record) records provides convenient decoding of joined rows, you may want a little more control over row decoding.
The `init(row:)` initializer of the [FetchableRecord] protocol is what you look after:
@@ -1672,7 +1770,7 @@ When you need to compute aggregates **from a single record**, you use [regular a
struct Author: TableRecord, EncodableRecord {
static let books = hasMany(Book.self)
var books: QueryInterfaceRequest<Book> {
return request(for: Author.books)
request(for: Author.books)
}
}
@@ -1745,7 +1843,7 @@ struct AuthorInfo: Decodable, FetchableRecord {
}
// SELECT author.*,
// COUNT(DISTINCT book.rowid) AS bookCount,
// COUNT(DISTINCT book.id) AS bookCount,
// MAX(book.year) AS maxBookYear,
// FROM author
// LEFT JOIN book ON book.authorId = author.id
@@ -1838,7 +1936,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) = 0
HAVING COUNT(DISTINCT book.id) = 0
```
</details>
@@ -1857,7 +1955,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) > 0
HAVING COUNT(DISTINCT book.id) > 0
```
</details>
@@ -1876,7 +1974,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
FROM author
LEFT JOIN book ON book.authorId = author.id
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) >= 2
HAVING COUNT(DISTINCT book.id) >= 2
```
</details>
@@ -1914,7 +2012,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
FROM author
LEFT JOIN book ON book.authorId = author.id AND book.kind = 'novel'
GROUP BY author.id
HAVING COUNT(DISTINCT book.rowid) > 0
HAVING COUNT(DISTINCT book.id) > 0
```
</details>
@@ -1935,7 +2033,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
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)
HAVING COUNT(DISTINCT book.id) > COUNT(DISTINCT painting.id)
```
</details>
@@ -1955,7 +2053,7 @@ The `having(_:)` method filters a request according to an aggregated value. You
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))
HAVING ((COUNT(DISTINCT book.id) = 0) AND (COUNT(DISTINCT painting.id) > 0))
```
</details>
@@ -1980,7 +2078,7 @@ Aggregates can be modified and combined with Swift operators:
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))
HAVING ((COUNT(DISTINCT book.id) = 0) AND (COUNT(DISTINCT painting.id) = 0))
```
</details>
@@ -2016,8 +2114,8 @@ Aggregates can be modified and combined with Swift operators:
```sql
SELECT author.*,
(COUNT(DISTINCT book.rowid) +
COUNT(DISTINCT painting.rowid)) AS workCount
(COUNT(DISTINCT book.id) +
COUNT(DISTINCT painting.id)) AS workCount
FROM author
LEFT JOIN book ON book.authorId = author.id
LEFT JOIN painting ON painting.authorId = author.id
@@ -2098,7 +2196,7 @@ In this other example, the `Author.books` and `Author.paintings` have the distin
```sql
SELECT author.*,
(COUNT(DISTINCT book.rowid) + COUNT(DISTINCT painting.rowid)) AS workCount
(COUNT(DISTINCT book.id) + COUNT(DISTINCT painting.id)) AS workCount
FROM author
LEFT JOIN book ON book.authorId = author.id
LEFT JOIN painting ON painting.authorId = author.id
@@ -2133,8 +2231,8 @@ But in the following example, we use the same association `Author.books` twice,
```sql
SELECT author.*,
COUNT(DISTINCT book1.rowid) AS novelCount,
COUNT(DISTINCT book2.rowid) AS theatrePlayCount
COUNT(DISTINCT book1.id) AS novelCount,
COUNT(DISTINCT book2.id) 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'
@@ -2173,8 +2271,8 @@ But in the following example, we use the same association `Author.books` twice,
```sql
SELECT author.*,
COUNT(DISTINCT book.rowid) AS novelCount,
COUNT(DISTINCT book.rowid) AS theatrePlayCount
COUNT(DISTINCT book.id) AS novelCount,
COUNT(DISTINCT book.id) AS theatrePlayCount
FROM author
LEFT JOIN book ON book.authorId = author.id
AND (book.kind = 'novel' AND book.kind = 'theatrePlay')
@@ -2202,35 +2300,40 @@ But in the following example, we use the same association `Author.books` twice,
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.
For example:
For example, we may want to define `orderedByName()` and `filter(country:)` request methods that make our requests easier to read:
```swift
// Authors sorted by name
let request = Author.all().orderedByName()
// French authors ordered by name
let request = Author.all().filter(country: "FR").orderedByName()
// Spanish books
let request = Book.all().filter(country: "ES")
```
Those methods are defined on extensions to the `DerivableRequest` protocol:
```swift
extension DerivableRequest where RowDecoder == Author {
func filter(country: String) -> Self {
return filter(Column("country") == country)
filter(Column("country") == country)
}
func orderByFullName() -> Self {
return order(
Column("lastName").collating(.localizedCaseInsensitiveCompare),
Column("firstName").collating(.localizedCaseInsensitiveCompare))
func orderedByName() -> Self {
order(Column("name").collating(.localizedCaseInsensitiveCompare))
}
}
extension DerivableRequest where RowDecoder == Book {
func filter(country: String) -> Self {
joining(required: Book.author.filter(country: country))
}
}
```
Thanks to DerivableRequest, both the `filter(country:)` and `orderByFullName()` methods are now available for both Author-based requests and associations:
```swift
// French authors sorted by full name:
let request = Author.all()
.filter(country: "FR")
.orderByFullName()
// French books, sorted by full name of author:
let request = Book.joining(required: Book.author
.filter(country: "FR")
.orderByFullName())
```
See [Good Practices for Designing Record Types] for more information.
## Known Issues
@@ -2276,7 +2379,7 @@ let request = Book.joining(required: Book.author
.including(all: Country.passports
.including(required: Passport.citizen))
```
Come [discuss](http://twitter.com/groue) for more information, or if you wish to help turning those missing features into reality.
---
@@ -2289,7 +2392,7 @@ This documentation owns a lot to the [Active Record Associations](http://guides.
**GRDB**
Copyright (C) 2019 Gwendal Roué
Copyright (C) 2015-2020 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:
@@ -2329,9 +2432,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[HasOneThrough]: #hasonethrough
[Choosing Between BelongsTo and HasOne]: #choosing-between-belongsto-and-hasone
[Self Joins]: #self-joins
[Ordered Associations]: #ordered-associations
[The Types of Associations]: #the-types-of-associations
[FetchableRecord]: ../README.md#fetchablerecord-protocols
[migration]: ../README.md#migrations
[migration]: Migrations.md
[Record]: ../README.md#records
[Foreign Key Actions]: https://sqlite.org/foreignkeys.html#fk_actions
[Associations and the Database Schema]: #associations-and-the-database-schema
@@ -2377,3 +2481,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[persistence methods]: ../README.md#persistence-methods
[database observation tools]: ../README.md#database-changes-observation
[ValueObservation]: ../README.md#valueobservation
[FAQ]: ../README.md#faq-associations
[common table expressions]: CommonTableExpressions.md
[Associations to Common Table Expressions]: CommonTableExpressions.md#associations-to-common-table-expressions
+328
View File
@@ -0,0 +1,328 @@
GRDB ❤️ Combine
===============
**On systems supporting the Combine framework, GRDB offers the ability to publish database values and events using Combine's publishers.**
- [Usage]
- [Demo Application]
- [Asynchronous Database Access]
- [Database Observation]
## Usage
To connect to the database, please refer to [Database Connections].
<details>
<summary><strong>Asynchronously read from the database</strong></summary>
This publisher reads a single value and delivers it.
```swift
// DatabasePublishers.Read<[Player]>
let players = dbQueue.readPublisher { db in
try Player.fetchAll(db)
}
```
</details>
<details>
<summary><strong>Asynchronously write in the database</strong></summary>
This publisher updates the database and delivers a single value.
```swift
// DatabasePublishers.Write<Void>
let write = dbQueue.writePublisher { db in
try Player(...).insert(db)
}
// DatabasePublishers.Write<Int>
let newPlayerCount = dbQueue.writePublisher { db -> Int in
try Player(...).insert(db)
return try Player.fetchCount(db)
}
```
</details>
<details>
<summary><strong>Observe changes in database values</strong></summary>
This publisher delivers fresh values whenever the database changes:
```swift
// A publisher with output [Player] and failure Error
let publisher = ValueObservation
.tracking { db in try Player.fetchAll(db) }
.publisher(in: dbQueue)
// A publisher with output Int? and failure Error
let publisher = ValueObservation
.tracking { db in try Int.fetchOne(db, sql: "SELECT MAX(score) FROM player") }
.publisher(in: dbQueue)
```
</details>
<details>
<summary><strong>Observe database transactions</strong></summary>
This publisher delivers database connections whenever a database transaction has impacted an observed region:
```swift
// A publisher with output Database and failure Error
let publisher = DatabaseRegionObservation
.tracking(Player.all())
.publisher(in: dbQueue)
let cancellable = publisher.sink(
receiveCompletion: { completion in ... },
receiveValue: { (db: Database) in
print("Exclusive write access to the database after players have been impacted")
})
// A publisher with output Database and failure Error
let publisher = DatabaseRegionObservation
.tracking(SQLRequest<Int>(sql: "SELECT MAX(score) FROM player"))
.publisher(in: dbQueue)
let cancellable = publisher.sink(
receiveCompletion: { completion in ... },
receiveValue: { (db: Database) in
print("Exclusive write access to the database after maximum score has been impacted")
})
```
</details>
# Asynchronous Database Access
GRDB provide publishers that perform asynchronous database accesses.
- [`readPublisher(receiveOn:value:)`]
- [`writePublisher(receiveOn:updates:)`]
- [`writePublisher(receiveOn:updates:thenRead:)`]
#### `DatabaseReader.readPublisher(receiveOn:value:)`
This methods returns a publisher that completes after database values have been asynchronously fetched.
```swift
// DatabasePublishers.Read<[Player]>
let players = dbQueue.readPublisher { db in
try Player.fetchAll(db)
}
```
Any attempt at modifying the database completes subscriptions with an error.
When you use a [database queue] or a [database snapshot], the read has to wait for any eventual concurrent database access performed by this queue or snapshot to complete.
When you use a [database pool], reads are generally non-blocking, unless the maximum number of concurrent reads has been reached. In this case, a read has to wait for another read to complete. That maximum number can be [configured].
This publisher can be subscribed from any thread. A new database access starts on every subscription.
The fetched value is published on the main queue, unless you provide a specific scheduler to the `receiveOn` argument.
#### `DatabaseWriter.writePublisher(receiveOn:updates:)`
This method returns a publisher that completes after database updates have been successfully executed inside a database transaction.
```swift
// DatabasePublishers.Write<Void>
let write = dbQueue.writePublisher { db in
try Player(...).insert(db)
}
// DatabasePublishers.Write<Int>
let newPlayerCount = dbQueue.writePublisher { db -> Int in
try Player(...).insert(db)
return try Player.fetchCount(db)
}
```
This publisher can be subscribed from any thread. A new database access starts on every subscription.
It completes on the main queue, unless you provide a specific [scheduler] to the `receiveOn` argument.
When you use a [database pool], and your app executes some database updates followed by some slow fetches, you may profit from optimized scheduling with [`writePublisher(receiveOn:updates:thenRead:)`]. See below.
#### `DatabaseWriter.writePublisher(receiveOn:updates:thenRead:)`
This method returns a publisher that completes after database updates have been successfully executed inside a database transaction, and values have been subsequently fetched:
```swift
// DatabasePublishers.Write<Int>
let newPlayerCount = dbQueue.writePublisher(
updates: { db in try Player(...).insert(db) }
thenRead: { db, _ in try Player.fetchCount(db) })
}
```
It publishes exactly the same values as [`writePublisher(receiveOn:updates:)`]:
```swift
// DatabasePublishers.Write<Int>
let newPlayerCount = dbQueue.writePublisher { db -> Int in
try Player(...).insert(db)
return try Player.fetchCount(db)
}
```
The difference is that the last fetches are performed in the `thenRead` function. This function accepts two arguments: a readonly database connection, and the result of the `updates` function. This allows you to pass information from a function to the other (it is ignored in the sample code above).
When you use a [database pool], this method applies a scheduling optimization: the `thenRead` function sees the database in the state left by the `updates` function, and yet does not block any concurrent writes. This can reduce database write contention. See [Advanced DatabasePool](../README.md#advanced-databasepool) for more information.
When you use a [database queue], the results are guaranteed to be identical, but no scheduling optimization is applied.
This publisher can be subscribed from any thread. A new database access starts on every subscription.
It completes on the main queue, unless you provide a specific [scheduler] to the `receiveOn` argument.
# Database Observation
Database Observation publishers are based on [ValueObservation] and [DatabaseRegionObservation]. Please refer to their documentation for more information. If your application needs change notifications that are not built as Combine publishers, check the general [Database Changes Observation] chapter.
- [`ValueObservation.publisher(in:scheduling:)`]
- [`DatabaseRegionObservation.publisher(in:)`]
#### `ValueObservation.publisher(in:scheduling:)`
[ValueObservation] tracks changes in database values. You can turn it into a Combine publisher:
```swift
let observation = ValueObservation.tracking { db in
try Player.fetchAll(db)
}
// A publisher with output [Player] and failure Error
let publisher = observation.publisher(in: dbQueue)
```
This publisher has the same behavior as ValueObservation:
- It notifies an initial value before the eventual changes.
- It may coalesce subsequent changes into a single notification.
- It may notify consecutive identical values. You can filter out the undesired duplicates with the `removeDuplicates()` Combine operator, but we suggest you have a look at the [removeDuplicates()](../README.md#valueobservationremoveduplicates) GRDB operator also.
- It stops emitting any value after the database connection is closed. But it never completes.
- By default, it notifies the initial value, as well as eventual changes and errors, on the main thread, asynchronously.
This can be configured with the `scheduling` argument. It does not accept a Combine scheduler, but a [ValueObservation scheduler](../README.md#valueobservation-scheduling).
For example, the `.immediate` scheduler makes sure the initial value is notified immediately when the publisher is subscribed. It can help your application update the user interface without having to wait for any asynchronous notifications:
```swift
// Immediate notification of the initial value
let cancellable = observation
.publisher(
in: dbQueue,
scheduling: .immediate) // <-
.sink(
receiveCompletion: { completion in ... },
receiveValue: { (players: [Player]) in print("Fresh players: \(players)") })
// <- here "fresh players" is already printed.
```
Note that the `.immediate` scheduler requires that the publisher is subscribed from the main thread. It raises a fatal error otherwise.
See [ValueObservation Scheduling](../README.md#valueobservation-scheduling) for more information.
:warning: **ValueObservation and Data Consistency**
When you compose ValueObservation publishers together with the [combineLatest](https://developer.apple.com/documentation/combine/publisher/3333677-combinelatest) operator, you lose all guarantees of [data consistency](https://en.wikipedia.org/wiki/Consistency_(database_systems)).
Instead, compose requests together into **one single** ValueObservation, as below:
```swift
struct HallOfFame {
var totalPlayerCount: Int
var bestPlayers: [Player]
}
// DATA CONSISTENCY GUARANTEED
let hallOfFamePublisher = ValueObservation
.tracking { db -> HallOfFame in
let totalPlayerCount = try Player.fetchCount(db)
let bestPlayers = try Player
.order(Column("score").desc)
.limit(10)
.fetchAll(db)
return HallOfFame(
totalPlayerCount: totalPlayerCount,
bestPlayers: bestPlayers)
}
.publisher(in: dbQueue)
```
See [ValueObservation] for more information.
#### `DatabaseRegionObservation.publisher(in:)`
[DatabaseRegionObservation] notifies all transactions that impact a tracked database region. You can turn it into a Combine publisher:
```swift
let request = Player.all()
let observation = DatabaseRegionObservation.tracking(request)
// A publisher with output Database and failure Error
let publisher = observation.publisher(in: dbQueue)
```
This publisher can be created and subscribed from any thread. It delivers database connections in a "protected dispatch queue", serialized with all database updates. It only completes when a database error happens.
```swift
let request = Player.all()
let cancellable = DatabaseRegionObservation
.tracking(request)
.publisher(in: dbQueue)
.sink(
receiveCompletion: { completion in ... },
receiveValue: { (db: Database) in
print("Players have changed.")
})
try dbQueue.write { db in
try Player(name: "Arthur").insert(db)
try Player(name: "Barbara").insert(db)
}
// Prints "Players have changed."
try dbQueue.write { db in
try Player.deleteAll(db)
}
// Prints "Players have changed."
```
See [DatabaseRegionObservation] for more information.
[Database Connections]: ../README.md#database-connections
[Usage]: #usage
[Asynchronous Database Access]: #asynchronous-database-access
[Combine]: https://developer.apple.com/documentation/combine
[Database Changes Observation]: ../README.md#database-changes-observation
[Database Observation]: #database-observation
[DatabaseRegionObservation]: ../README.md#databaseregionobservation
[Demo Application]: DemoApps/GRDBCombineDemo/README.md
[SQLite]: http://sqlite.org
[ValueObservation]: ../README.md#valueobservation
[`DatabaseRegionObservation.publisher(in:)`]: #databaseregionobservationpublisherin
[`ValueObservation.publisher(in:scheduling:)`]: #valueobservationpublisherinscheduling
[`readPublisher(receiveOn:value:)`]: #databasereaderreadpublisherreceiveonvalue
[`writePublisher(receiveOn:updates:)`]: #databasewriterwritepublisherreceiveonupdates
[`writePublisher(receiveOn:updates:thenRead:)`]: #databasewriterwritepublisherreceiveonupdatesthenread
[configured]: ../README.md#databasepool-configuration
[database pool]: ../README.md#database-pools
[database queue]: ../README.md#database-queues
[database snapshot]: ../README.md#database-snapshots
[scheduler]: https://developer.apple.com/documentation/combine/scheduler
+423
View File
@@ -0,0 +1,423 @@
Common Table Expressions
========================
[**:fire: EXPERIMENTAL**](../README.md#what-are-experimental-features)
---
**Common table expressions** (CTEs) can generally be seen as *SQL views that you define on the fly*.
A certain level of familiarity with SQL databases is helpful before you dive into this guide. The starting point is obviously the [SQLite documentation](https://sqlite.org/lang_with.html). Many CTE tutorials exist online as well, including [this good one](https://blog.expensify.com/2015/09/25/the-simplest-sqlite-common-table-expression-tutorial/).
In this guide, you will learn how to:
- [Define Common Table Expressions]
- [Embed Common Table Expressions in Requests]
- [Fetch Values From Common Table Expressions]
- Join CTEs with [Associations to Common Table Expressions]
> :point_up: **Note**: most code examples will be trivial, and not very "useful". This is because the goal of this guide is to stay focused on the GRDB support for CTEs. Rich setup would just be distracting. So bring your own good ideas with you!
## Define Common Table Expressions
You will create a `CommonTableExpression` definition first. Choose a **name**, and a **request** that provides the content of the common table expression.
The CTE name is like a regular table name: pick one that does not conflict with the names of existing tables.
The CTE request can be provided as a [query interface request]:
```swift
// WITH playerName AS (SELECT name FROM player) ...
let playerNameCTE = CommonTableExpression<Void>(
named: "playerName",
request: Player.select(Column("name")))
```
You can feed a CTE with raw SQL as well (second and third examples use [SQL Interpolation]):
```swift
let name = "O'Brien"
// WITH playerName AS (SELECT 'O''Brien') ...
let playerNameCTE = CommonTableExpression<Void>(
named: "playerName",
sql: "SELECT ?", arguments: [name])
// WITH playerName AS (SELECT 'O''Brien') ...
let playerNameCTE = CommonTableExpression<Void>(
named: "playerName",
literal: "SELECT \(name)")
// WITH playerName AS (SELECT 'O''Brien') ...
let request: SQLRequest<String> = "SELECT \(name)"
let playerNameCTE = CommonTableExpression<Void>(
named: "playerName",
request: requests)
```
All CTEs can be provided with explicit column names:
```swift
// WITH pair(a, b) AS (SELECT 1, 2) ...
let pairCTE = CommonTableExpression<Void>(
named: "pair",
columns: ["a", "b"],
sql: "SELECT 1, 2")
```
Recursive CTEs need the `recursive` flag. The example below selects all integers between 1 and 1000:
```swift
// WITH RECURSIVE counter(x) AS
// (VALUES(1) UNION ALL SELECT x+1 FROM counter WHERE x<1000)
let counterCTE = CommonTableExpression<Int>(
recursive: true,
named: "counter",
columns: ["x"],
sql: """
VALUES(1)
UNION ALL
SELECT x+1 FROM counter WHERE x<1000
""")
```
> :point_up: **Note**: many recursive CTEs use the `UNION ALL` SQL operator. The query interface does not provide any Swift support for it, so you'll generally have to write SQL in your definitions of recursive CTEs.
As you can see in all above examples, `CommonTableExpression` is a generic type: `CommonTableExpression<Void>`, `CommonTableExpression<Int>`. The generic argument (`Void`, `Int`) turns useful when you [join common table expressions](#associations-to-common-table-expressions), or when you [fetch values directly from a common table expression](#fetch-values-from-common-table-expressions). Otherwise, you can just use `Void`.
## Embed Common Table Expressions in Requests
A typical SQLite query that uses a common table expression first *defines* the CTE and then *uses* the CTE by mentioning its table name. We'll see below Swift apis that match those two steps.
We will use the (simple) query below as a target. It is the query we'll want to generate in this chapter. It defines a CTE, and uses it in a subquery:
```sql
WITH playerName AS (SELECT 'O''Brien')
SELECT * FROM player
WHERE name = (SELECT * FROM playerName)
```
We first build a `CommonTableExpression`:
```swift
let name = "O'Brien"
let playerNameCTE = CommonTableExpression<Void>(
named: "playerName",
literal: "SELECT \(name)")
```
We can then embed the definition of the CTE in a [query interface request] by calling the `with(_:)` method:
```swift
// WITH playerName AS (SELECT 'O''Brien')
// SELECT * FROM player ...
let request = Player
.with(playerNameCTE)...
```
And we can then filter the `player` table with a subquery:
```swift
// WITH playerName AS (SELECT 'O''Brien')
// SELECT * FROM player
// WHERE name = (SELECT * FROM playerName)
let request = Player
.with(playerNameCTE)
.filter(Column("name") == playerNameCTE.all())
```
> :point_up: **Note**: the `with(_:)` method can be called as many times as a there are common table expressions in your request.
>
> :point_up: **Note**: the `with(_:)` method can be called at any time, as all request methods: `Player.with(...).filter(...).with(...)`.
>
> :point_up: **Note**: the `with(_:)` method replaces any previously embedded CTE that has the same table name. This allows you to embed the same CTE several times if you feel like it.
>
> :point_up: **Note**: the `CommonTableExpression.all()` method builds a regular [query interface request] for the content of the CTE (like `SELECT * FROM <cte name>`, not to be mismatched with the request that was used to define the CTE). You can filter this request, sort it, etc, like all query interface requests:
>
> ```swift
> cte.all().select(...).filter(...).group(...).order(...)
> ```
Common table expressions can also be embedded in [SQLRequest] with [SQL Interpolation]:
```swift
// WITH playerName AS (SELECT 'O''Brien')
// SELECT * FROM player
// WHERE name = (SELECT * FROM playerName)
let request: SQLRequest<Player> = """
WITH \(definitionFor: playerNameCTE)
SELECT * FROM player
WHERE name = (SELECT * FROM \(playerNameCTE))
"""
// WITH playerName AS (SELECT 'O''Brien')
// SELECT * FROM player
// WHERE name = (SELECT * FROM playerName)
let request: SQLRequest<Player> = """
WITH \(definitionFor: playerNameCTE)
SELECT * FROM player
WHERE name = (\(playerNameCTE.all()))
"""
```
Common table expressions can also be used as subqueries, when you update or delete rows in the database:
```swift
// WITH playerName AS (SELECT 'O''Brien')
// UPDATE player SET name = (SELECT * FROM playerName)
try Player
.with(playerNameCTE)
.updateAll(db, Column("name").set(to: playerNameCTE.all()))
// WITH playerName AS (SELECT 'O''Brien')
// DELETE FROM player WHERE name = (SELECT * FROM playerName)
try Player
.with(playerNameCTE)
.filter(Column("name") == playerNameCTE.all())
.deleteAll(db)
```
## Fetch Values From Common Table Expressions
In the previous chapter, a common table expression was embedded as a subquery, with the `CommonTableExpression.all()` method.
`all()` builds a regular [query interface request] that you can filter, sort, etc, like all query interface requests. You can also fetch from it, but only as long as it is provided with the definition of the CTE.
This will generally give requests of the form `cte.all().with(cte)`. In SQL, this would give: `WITH cte AS (...) SELECT * FROM cte`.
The generic type of `CommonTableExpression<...>` now turns out useful, so that you can fetch the desired outcome (database [rows](../README.md#row-queries), simple [values](../README.md#value-queries), or custom [records](../README.md#records)).
For example, let's fetch a range of integer:
```swift
func counterRequest(range: ClosedRange<Int>) -> QueryInterfaceRequest<Int> {
// WITH RECURSIVE counter(x) AS
// (VALUES(...) UNION ALL SELECT x+1 FROM counter WHERE x<...)
// SELECT * FROM counter
let counter = CommonTableExpression<Int>(
recursive: true,
named: "counter",
columns: ["x"],
literal: """
VALUES(\(range.lowerBound)) \
UNION ALL \
SELECT x+1 FROM counter WHERE x < \(range.upperBound)
""")
return counter.all().with(counter)
}
let values = try dbQueue.read { db in
try counterRequest(range: 3...7).fetchAll(db)
}
print(values) // prints "[3, 4, 5, 6, 7]"
```
When you have to fetch from a `CommonTableExpression` which does not have the desired generic type, you can still use the `asRequest(of:)` method:
```swift
let cte: CommonTableExpression<Void> = ...
let rows: [Row] = try dbQueue.read { db in
try cte.all().with(cte)
.asRequest(of: Row.self)
.fetchAll(db)
}
```
## Associations to Common Table Expressions
GRDB [associations] define "to-one" and "to-many" relationships between two database tables. Here we will define associations between regular tables and common table expressions.
We recommend familiarity with the "joining methods", described in [Joining And Prefetching Associated Records]:
```swift
// SELECT parent.* FROM parent LEFT JOIN child ON ...
Parent.joining(optional: childAssociation)
// SELECT parent.* FROM parent JOIN child ON ...
Parent.joining(required: childAssociation)
// SELECT parent.*, child.* FROM parent LEFT JOIN child ON ...
Parent.including(optional: childAssociation)
// SELECT parent.*, child.* FROM parent JOIN child ON ...
Parent.including(required: childAssociation)
```
> :point_up: **Note**: common table expressions currently only define "to-one" associations, so the `including(all:)` joining method is unavailable.
CTE associations are generally built with the `association(to:on:)` method, which needs:
- The two sides of the association: a `CommonTableExpression` instance, and another CTE or a type that conforms to the [TableRecord] protocol.
- A function that returns the condition that joins the two sides of the association.
The condition function plays the same role as the **foreign key** that defines regular table [associations] such as **BelongsTo** or **HasMany**. It accepts two [TableAlias], from which you can build a joining expression:
For example:
```swift
// An association from LeftRecord to rightCTE
let rightCTE = ...
let association = LeftRecord.association(
to: rightCTE,
on: { left, right in
left[Column("x")] = right[Column("y")]
})
```
Now this association can be used with a joining method:
```swift
// WITH rightCTE AS (...)
// SELECT leftRecord.*, rightCTE.*
// FROM leftRecord
// JOIN rightCTE ON leftRecord.x = rightCTE.y
LeftRecord
.with(rightCTE)
.including(required: association)
```
### CTE Association Example: a Chat App
As an example, let's build the classical main screen of a chat application: a list of all latest messages from all conversations.
The database schema of the chat app contains a `chat` and a `message` table. The application defines the following records:
```swift
struct Chat: Codable, FetchableRecord, PersistableRecord {
var id: Int64
...
}
struct Message: Codable, FetchableRecord, PersistableRecord {
var chatID: Int64
var date: Date
...
}
```
To feed the main app screen, we want to fetch a list of `ChatInfo` records:
```swift
struct ChatInfo: Decodable, FetchableRecord {
/// The chat
var chat: Chat
/// The latest chat message, if any
var latestMessage: Message?
}
```
The SQL request that we want to run is below. It uses an SQLite-specific [special processing](https://sqlite.org/lang_select.html) of `MAX()` that helps the selection of latest messages from all chats:
```sql
WITH latestMessage AS
(SELECT *, MAX(date) FROM message GROUP BY chatID)
SELECT chat.*, latestMessage.*
FROM chat
LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
ORDER BY latestMessage.date DESC
```
We start by defining the CTE request, which loads the latest messages of all chats:
```swift
// SELECT *, MAX(date) FROM message GROUP BY chatID
let latestMessageRequest = Message
.annotated(with: max(Column("date")))
.group(Column("chatID"))
```
We can now define the CTE for the latest messages:
```swift
// WITH latestMessage AS
// (SELECT *, MAX(date) FROM message GROUP BY chatID)
let latestMessageCTE = CommonTableExpression<Void>(
named: "latestMessage",
request: latestMessageRequest)
```
The association from a chat to its latest message follows:
```swift
// ... JOIN latestMessage ON chat.id = latestMessage.chatID
let latestMessage = Chat.association(
to: latestMessageCTE,
on: { chat, latestMessage in
chat[Column("id")] == latestMessage[Column("chatID")]
})
.order(Column("date").desc)
```
The final request can now be defined:
```swift
// WITH latestMessage AS
// (SELECT *, MAX(date) FROM message GROUP BY chatID)
// SELECT chat.*, latestMessage.*
// FROM chat
// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
// ORDER BY latestMessage.date DESC
let request = Chat
.with(latestMessageCTE)
.including(optional: latestMessage)
.asRequest(of: ChatInfo.self)
```
And we can fetch the data that feeds our application screen:
```swift
let chatInfos: [ChatInfos] = try dbQueue.read(request.fetchAll)
```
> :bulb: **Tip**: the joining methods are generally type-safe: they won't allow you to join apples to oranges. This works when associations have a *precise* type. In this context, our go-to `CommonTableExpression<Void>` CTEs can work against type safety. So when you want to define associations between several CTEs, and make sure the compiler will notice wrong uses of those associations, tag your `CommonTableExpression` with a type instead of `Void`.
>
> You can use an existing record type, or an ad-hoc enum. For example:
>
> ```swift
> enum CTE1 { }
> let cte1 = CommonTableExpression<CTE1>(...)
>
> enum CTE2 { }
> let cte2 = CommonTableExpression<CTE2>(...)
>
> let assoc1 = BaseRecord.association(to: cte1, on: ...)
> let assoc2 = cte1.association(to: cte2, on: ...)
> let assoc3 = cte2.association(to: FarRecord.self, on: ...)
>
> // WITH ...
> // SELECT base.* FROM base
> // JOIN cte1 ON ...
> // JOIN cte2 ON ...
> // JOIN far ON ...
> let request = BaseRecord
> .with(cte1).with(cte2)
> .joining(required: assoc1
> .joining(required: assoc2
> .joining(required: assoc3)))
>
> // Compiler error
> let request = BaseRecord.joining(required: assoc2)
> ```
[query interface request]: ../README.md#requests
[query interface requests]: ../README.md#requests
[SQLRequest]: ../README.md#custom-requests
[SQLiteral]: SQLInterpolation.md
[SQL Interpolation]: SQLInterpolation.md
[associations]: AssociationsBasics.md
[Joining And Prefetching Associated Records]: AssociationsBasics.md#joining-and-prefetching-associated-records
[Define Common Table Expressions]: #define-common-table-expressions
[Embed Common Table Expressions in Requests]: #embed-common-table-expressions-in-requests
[Fetch Values From Common Table Expressions]: #fetch-values-from-common-table-expressions
[Associations to Common Table Expressions]: #associations-to-common-table-expressions
[TableRecord]: ../README.md#tablerecord-protocol
[TableAlias]: AssociationsBasics.md#table-aliases
+14 -10
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.28.0](https://www.sqlite.org/changes.html).**
**You can build GRDB with a custom build of [SQLite 3.33.0](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).
@@ -11,15 +11,17 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
**To install GRDB with a custom SQLite build:**
1. Clone the GRDB git repository, checkout the latest tagged version, and download SQLite sources:
1. Clone the GRDB git repository, checkout the latest tagged version:
```sh
cd [GRDB directory]
git checkout v4.3.0
git checkout [latest tag]
git submodule update --init SQLiteCustom/src
````
```
2. Choose your [extra compilation options](https://www.sqlite.org/compile.html). For example, `SQLITE_ENABLE_FTS5` and `SQLITE_ENABLE_PREUPDATE_HOOK`.
2. Choose your [extra compilation options](https://www.sqlite.org/compile.html). For example, `SQLITE_ENABLE_FTS5`, `SQLITE_ENABLE_PREUPDATE_HOOK`.
It is recommended that you enable the `SQLITE_ENABLE_SNAPSHOT` option. It allows GRDB to optimize [ValueObservation](../README.md#valueobservation) when you use a [Database Pool](../README.md#database-pools).
3. Create a folder named `GRDBCustomSQLite` somewhere in your project directory.
@@ -30,7 +32,7 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
```xcconfig
// As many -D options as there are custom SQLite compilation options
// Note: there is no space between -D and the option name.
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_PREUPDATE_HOOK
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_FTS5
```
- `GRDBCustomSQLite-USER.xcconfig`: this file lets GRDB know about extra compilation flags, and enables extra GRDB APIs.
@@ -38,15 +40,15 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
```xcconfig
// As many -D options as there are custom SQLite compilation options
// Note: there is one space between -D and the option name.
CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_FTS5 -D SQLITE_ENABLE_PREUPDATE_HOOK
CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_SNAPSHOT -D SQLITE_ENABLE_FTS5
```
- `GRDBCustomSQLite-USER.h`: this file lets your application know about extra compilation flags.
```c
// As many #define as there are custom SQLite compilation options
#define SQLITE_ENABLE_SNAPSHOT
#define SQLITE_ENABLE_FTS5
#define SQLITE_ENABLE_PREUPDATE_HOOK
```
- `GRDBCustomSQLite-INSTALL.sh`: this file installs the three other files.
@@ -111,7 +113,7 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
6. Add the `GRDBCustomSQLiteOSX` or `GRDBCustomSQLiteiOS` target in the **Target Dependencies** section of the **Build Phases** tab of your **application target**.
7. Add the `GRDBCustomSQLite.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your **application target**.
7. Add the `GRDBCustomSQLite.framework` from the targeted platform to the **Embedded Binaries** section of the **General** tab of your **application target**.
8. Add a Run Script phase for your target in the **Pre-actions** section of the **Build** tab of your **application scheme**:
@@ -120,13 +122,15 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
```
The path should be the path to your `GRDBCustomSQLite-INSTALL.sh` file.
Select your application target in the "Provide build settings from" menu.
9. Check the "Shared" checkbox of your application scheme (this lets you commit the pre-action in your Version Control System).
Now you can use GRDB with your custom SQLite build:
```swift
import GRDBCustomSQLite
import GRDB
let dbQueue = try DatabaseQueue(...)
```
@@ -0,0 +1,732 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
56026CAC25B8A7EF00D1DF3F /* PlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56026CAA25B8A7EF00D1DF3F /* PlayerTests.swift */; };
56026CAD25B8A7EF00D1DF3F /* AppDatabaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56026CAB25B8A7EF00D1DF3F /* AppDatabaseTests.swift */; };
567C3E1A2520B6DE0011F6E9 /* GRDBCombineDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E192520B6DE0011F6E9 /* GRDBCombineDemoApp.swift */; };
567C3E1E2520B6DF0011F6E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 567C3E1D2520B6DF0011F6E9 /* Assets.xcassets */; };
567C3E212520B6DF0011F6E9 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 567C3E202520B6DF0011F6E9 /* Preview Assets.xcassets */; };
567C3E4E2520B70E0011F6E9 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 567C3E3B2520B7000011F6E9 /* GRDB.framework */; };
567C3E4F2520B70E0011F6E9 /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 567C3E3B2520B7000011F6E9 /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
567C3E5D2520B75C0011F6E9 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E532520B75C0011F6E9 /* Player.swift */; };
567C3E5E2520B75C0011F6E9 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E542520B75C0011F6E9 /* Persistence.swift */; };
567C3E5F2520B75C0011F6E9 /* PlayerListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E562520B75C0011F6E9 /* PlayerListViewModel.swift */; };
567C3E602520B75C0011F6E9 /* PlayerFormViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E572520B75C0011F6E9 /* PlayerFormViewModel.swift */; };
567C3E612520B75D0011F6E9 /* PlayerForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E592520B75C0011F6E9 /* PlayerForm.swift */; };
567C3E622520B75D0011F6E9 /* PlayerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5A2520B75C0011F6E9 /* PlayerList.swift */; };
567C3E632520B75D0011F6E9 /* PlayerCreationSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5B2520B75C0011F6E9 /* PlayerCreationSheet.swift */; };
567C3E642520B75D0011F6E9 /* PlayerEditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5C2520B75C0011F6E9 /* PlayerEditionView.swift */; };
567C3E662520B7880011F6E9 /* AppDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E652520B7880011F6E9 /* AppDatabase.swift */; };
567C3E792520BB650011F6E9 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 567C3E752520BB650011F6E9 /* Localizable.stringsdict */; };
567C3E7A2520BB650011F6E9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 567C3E772520BB650011F6E9 /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
56026C9D25B8A7D000D1DF3F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E0E2520B6DE0011F6E9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 567C3E152520B6DE0011F6E9;
remoteInfo = GRDBCombineDemo;
};
567C3E342520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = DC3773F319C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
567C3E362520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7F91B4D422D00430942;
remoteInfo = GRDBOSXTests;
};
567C3E382520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56553C181C3E906C00522B5C;
remoteInfo = GRDBOSXCrashTests;
};
567C3E3A2520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7CA1B4D3FED00430942;
remoteInfo = GRDBiOS;
};
567C3E3C2520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7D31B4D3FEE00430942;
remoteInfo = GRDBiOSTests;
};
567C3E3E2520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 565490A01D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
567C3E402520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = AAA4DCFE230F1E0600C74B15;
remoteInfo = GRDBtvOS;
};
567C3E422520B7000011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = AAA4DDD4230F262000C74B15;
remoteInfo = GRDBtvOSTests;
};
567C3E512520B71C0011F6E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
567C3E502520B70E0011F6E9 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
567C3E4F2520B70E0011F6E9 /* GRDB.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
56026C9825B8A7D000D1DF3F /* GRDBCombineDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCombineDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56026C9C25B8A7D000D1DF3F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
56026CAA25B8A7EF00D1DF3F /* PlayerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerTests.swift; sourceTree = "<group>"; };
56026CAB25B8A7EF00D1DF3F /* AppDatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDatabaseTests.swift; sourceTree = "<group>"; };
567C3E162520B6DE0011F6E9 /* GRDBCombineDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBCombineDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
567C3E192520B6DE0011F6E9 /* GRDBCombineDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRDBCombineDemoApp.swift; sourceTree = "<group>"; };
567C3E1D2520B6DF0011F6E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
567C3E202520B6DF0011F6E9 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
567C3E222520B6DF0011F6E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
567C3E292520B7000011F6E9 /* GRDB.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GRDB.xcodeproj; path = ../../../GRDB.xcodeproj; sourceTree = "<group>"; };
567C3E532520B75C0011F6E9 /* Player.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
567C3E542520B75C0011F6E9 /* Persistence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = "<group>"; };
567C3E562520B75C0011F6E9 /* PlayerListViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerListViewModel.swift; sourceTree = "<group>"; };
567C3E572520B75C0011F6E9 /* PlayerFormViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerFormViewModel.swift; sourceTree = "<group>"; };
567C3E592520B75C0011F6E9 /* PlayerForm.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerForm.swift; sourceTree = "<group>"; };
567C3E5A2520B75C0011F6E9 /* PlayerList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerList.swift; sourceTree = "<group>"; };
567C3E5B2520B75C0011F6E9 /* PlayerCreationSheet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerCreationSheet.swift; sourceTree = "<group>"; };
567C3E5C2520B75C0011F6E9 /* PlayerEditionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerEditionView.swift; sourceTree = "<group>"; };
567C3E652520B7880011F6E9 /* AppDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDatabase.swift; sourceTree = "<group>"; };
567C3E762520BB650011F6E9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
567C3E782520BB650011F6E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
56026C9525B8A7D000D1DF3F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
567C3E132520B6DE0011F6E9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
567C3E4E2520B70E0011F6E9 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
56026C9925B8A7D000D1DF3F /* GRDBCombineDemoTests */ = {
isa = PBXGroup;
children = (
56026C9C25B8A7D000D1DF3F /* Info.plist */,
56026CAB25B8A7EF00D1DF3F /* AppDatabaseTests.swift */,
56026CAA25B8A7EF00D1DF3F /* PlayerTests.swift */,
);
path = GRDBCombineDemoTests;
sourceTree = "<group>";
};
56185BC125B8047D00B9C30F /* Resources */ = {
isa = PBXGroup;
children = (
567C3E1D2520B6DF0011F6E9 /* Assets.xcassets */,
567C3E772520BB650011F6E9 /* LaunchScreen.storyboard */,
567C3E752520BB650011F6E9 /* Localizable.stringsdict */,
);
path = Resources;
sourceTree = "<group>";
};
56185BC225B8048B00B9C30F /* Support */ = {
isa = PBXGroup;
children = (
567C3E222520B6DF0011F6E9 /* Info.plist */,
);
name = Support;
sourceTree = "<group>";
};
567C3E0D2520B6DE0011F6E9 = {
isa = PBXGroup;
children = (
567C3E292520B7000011F6E9 /* GRDB.xcodeproj */,
567C3E182520B6DE0011F6E9 /* GRDBCombineDemo */,
56026C9925B8A7D000D1DF3F /* GRDBCombineDemoTests */,
567C3E172520B6DE0011F6E9 /* Products */,
567C3E4D2520B70E0011F6E9 /* Frameworks */,
);
sourceTree = "<group>";
};
567C3E172520B6DE0011F6E9 /* Products */ = {
isa = PBXGroup;
children = (
567C3E162520B6DE0011F6E9 /* GRDBCombineDemo.app */,
56026C9825B8A7D000D1DF3F /* GRDBCombineDemoTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
567C3E182520B6DE0011F6E9 /* GRDBCombineDemo */ = {
isa = PBXGroup;
children = (
567C3E652520B7880011F6E9 /* AppDatabase.swift */,
567C3E192520B6DE0011F6E9 /* GRDBCombineDemoApp.swift */,
567C3E542520B75C0011F6E9 /* Persistence.swift */,
567C3E532520B75C0011F6E9 /* Player.swift */,
567C3E1F2520B6DF0011F6E9 /* Preview Content */,
56185BC125B8047D00B9C30F /* Resources */,
56185BC225B8048B00B9C30F /* Support */,
567C3E552520B75C0011F6E9 /* ViewModels */,
567C3E582520B75C0011F6E9 /* Views */,
);
path = GRDBCombineDemo;
sourceTree = "<group>";
};
567C3E1F2520B6DF0011F6E9 /* Preview Content */ = {
isa = PBXGroup;
children = (
567C3E202520B6DF0011F6E9 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
567C3E2A2520B7000011F6E9 /* Products */ = {
isa = PBXGroup;
children = (
567C3E352520B7000011F6E9 /* GRDB.framework */,
567C3E372520B7000011F6E9 /* GRDBOSXTests.xctest */,
567C3E392520B7000011F6E9 /* GRDBOSXCrashTests.xctest */,
567C3E3B2520B7000011F6E9 /* GRDB.framework */,
567C3E3D2520B7000011F6E9 /* GRDBiOSTests.xctest */,
567C3E3F2520B7000011F6E9 /* GRDB.framework */,
567C3E412520B7000011F6E9 /* GRDB.framework */,
567C3E432520B7000011F6E9 /* GRDBtvOSTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
567C3E4D2520B70E0011F6E9 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
567C3E552520B75C0011F6E9 /* ViewModels */ = {
isa = PBXGroup;
children = (
567C3E562520B75C0011F6E9 /* PlayerListViewModel.swift */,
567C3E572520B75C0011F6E9 /* PlayerFormViewModel.swift */,
);
path = ViewModels;
sourceTree = "<group>";
};
567C3E582520B75C0011F6E9 /* Views */ = {
isa = PBXGroup;
children = (
567C3E592520B75C0011F6E9 /* PlayerForm.swift */,
567C3E5A2520B75C0011F6E9 /* PlayerList.swift */,
567C3E5B2520B75C0011F6E9 /* PlayerCreationSheet.swift */,
567C3E5C2520B75C0011F6E9 /* PlayerEditionView.swift */,
);
path = Views;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
56026C9725B8A7D000D1DF3F /* GRDBCombineDemoTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56026CA825B8A7D000D1DF3F /* Build configuration list for PBXNativeTarget "GRDBCombineDemoTests" */;
buildPhases = (
56026C9425B8A7D000D1DF3F /* Sources */,
56026C9525B8A7D000D1DF3F /* Frameworks */,
56026C9625B8A7D000D1DF3F /* Resources */,
);
buildRules = (
);
dependencies = (
56026C9E25B8A7D000D1DF3F /* PBXTargetDependency */,
);
name = GRDBCombineDemoTests;
productName = GRDBCombineDemoTests;
productReference = 56026C9825B8A7D000D1DF3F /* GRDBCombineDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 567C3E252520B6DF0011F6E9 /* Build configuration list for PBXNativeTarget "GRDBCombineDemo" */;
buildPhases = (
567C3E122520B6DE0011F6E9 /* Sources */,
567C3E132520B6DE0011F6E9 /* Frameworks */,
567C3E142520B6DE0011F6E9 /* Resources */,
567C3E502520B70E0011F6E9 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
567C3E522520B71C0011F6E9 /* PBXTargetDependency */,
);
name = GRDBCombineDemo;
productName = GRBCombineDemo;
productReference = 567C3E162520B6DE0011F6E9 /* GRDBCombineDemo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
567C3E0E2520B6DE0011F6E9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1230;
LastUpgradeCheck = 1200;
TargetAttributes = {
56026C9725B8A7D000D1DF3F = {
CreatedOnToolsVersion = 12.3;
TestTargetID = 567C3E152520B6DE0011F6E9;
};
567C3E152520B6DE0011F6E9 = {
CreatedOnToolsVersion = 12.0;
};
};
};
buildConfigurationList = 567C3E112520B6DE0011F6E9 /* Build configuration list for PBXProject "GRDBCombineDemo" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 567C3E0D2520B6DE0011F6E9;
productRefGroup = 567C3E172520B6DE0011F6E9 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 567C3E2A2520B7000011F6E9 /* Products */;
ProjectRef = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
},
);
projectRoot = "";
targets = (
567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */,
56026C9725B8A7D000D1DF3F /* GRDBCombineDemoTests */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
567C3E352520B7000011F6E9 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 567C3E342520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E372520B7000011F6E9 /* GRDBOSXTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXTests.xctest;
remoteRef = 567C3E362520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E392520B7000011F6E9 /* GRDBOSXCrashTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXCrashTests.xctest;
remoteRef = 567C3E382520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E3B2520B7000011F6E9 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 567C3E3A2520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E3D2520B7000011F6E9 /* GRDBiOSTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBiOSTests.xctest;
remoteRef = 567C3E3C2520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E3F2520B7000011F6E9 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 567C3E3E2520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E412520B7000011F6E9 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 567C3E402520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
567C3E432520B7000011F6E9 /* GRDBtvOSTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBtvOSTests.xctest;
remoteRef = 567C3E422520B7000011F6E9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
56026C9625B8A7D000D1DF3F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
567C3E142520B6DE0011F6E9 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
567C3E212520B6DF0011F6E9 /* Preview Assets.xcassets in Resources */,
567C3E7A2520BB650011F6E9 /* LaunchScreen.storyboard in Resources */,
567C3E1E2520B6DF0011F6E9 /* Assets.xcassets in Resources */,
567C3E792520BB650011F6E9 /* Localizable.stringsdict in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
56026C9425B8A7D000D1DF3F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56026CAC25B8A7EF00D1DF3F /* PlayerTests.swift in Sources */,
56026CAD25B8A7EF00D1DF3F /* AppDatabaseTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
567C3E122520B6DE0011F6E9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
567C3E5E2520B75C0011F6E9 /* Persistence.swift in Sources */,
567C3E5D2520B75C0011F6E9 /* Player.swift in Sources */,
567C3E612520B75D0011F6E9 /* PlayerForm.swift in Sources */,
567C3E632520B75D0011F6E9 /* PlayerCreationSheet.swift in Sources */,
567C3E662520B7880011F6E9 /* AppDatabase.swift in Sources */,
567C3E622520B75D0011F6E9 /* PlayerList.swift in Sources */,
567C3E642520B75D0011F6E9 /* PlayerEditionView.swift in Sources */,
567C3E1A2520B6DE0011F6E9 /* GRDBCombineDemoApp.swift in Sources */,
567C3E5F2520B75C0011F6E9 /* PlayerListViewModel.swift in Sources */,
567C3E602520B75C0011F6E9 /* PlayerFormViewModel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
56026C9E25B8A7D000D1DF3F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */;
targetProxy = 56026C9D25B8A7D000D1DF3F /* PBXContainerItemProxy */;
};
567C3E522520B71C0011F6E9 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBiOS;
targetProxy = 567C3E512520B71C0011F6E9 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
567C3E752520BB650011F6E9 /* Localizable.stringsdict */ = {
isa = PBXVariantGroup;
children = (
567C3E762520BB650011F6E9 /* en */,
);
name = Localizable.stringsdict;
sourceTree = "<group>";
};
567C3E772520BB650011F6E9 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
567C3E782520BB650011F6E9 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
56026C9F25B8A7D000D1DF3F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = GRDBCombineDemoTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCombineDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBCombineDemo.app/GRDBCombineDemo";
};
name = Debug;
};
56026CA025B8A7D000D1DF3F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = GRDBCombineDemoTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCombineDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBCombineDemo.app/GRDBCombineDemo";
};
name = Release;
};
567C3E232520B6DF0011F6E9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
567C3E242520B6DF0011F6E9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
567C3E262520B6DF0011F6E9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"GRDBCombineDemo/Preview Content\"";
DEVELOPMENT_TEAM = AMD8W895CT;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBCombineDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCombineDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
567C3E272520B6DF0011F6E9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"GRDBCombineDemo/Preview Content\"";
DEVELOPMENT_TEAM = AMD8W895CT;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBCombineDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCombineDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56026CA825B8A7D000D1DF3F /* Build configuration list for PBXNativeTarget "GRDBCombineDemoTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56026C9F25B8A7D000D1DF3F /* Debug */,
56026CA025B8A7D000D1DF3F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
567C3E112520B6DE0011F6E9 /* Build configuration list for PBXProject "GRDBCombineDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
567C3E232520B6DF0011F6E9 /* Debug */,
567C3E242520B6DF0011F6E9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
567C3E252520B6DF0011F6E9 /* Build configuration list for PBXNativeTarget "GRDBCombineDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
567C3E262520B6DF0011F6E9 /* Debug */,
567C3E272520B6DF0011F6E9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 567C3E0E2520B6DE0011F6E9 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/groue/Documents/git/groue/GRDB.swift/Documentation/DemoApps/GRBCombineDemo/GRDBCombineDemo.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "567C3E152520B6DE0011F6E9"
BuildableName = "GRDBCombineDemo.app"
BlueprintName = "GRDBCombineDemo"
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56026C9725B8A7D000D1DF3F"
BuildableName = "GRDBCombineDemoTests.xctest"
BlueprintName = "GRDBCombineDemoTests"
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "567C3E152520B6DE0011F6E9"
BuildableName = "GRDBCombineDemo.app"
BlueprintName = "GRDBCombineDemo"
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "567C3E152520B6DE0011F6E9"
BuildableName = "GRDBCombineDemo.app"
BlueprintName = "GRDBCombineDemo"
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,143 @@
import Combine
import GRDB
/// AppDatabase lets the application access the database.
///
/// It applies the pratices recommended at
/// https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
struct AppDatabase {
/// Creates an `AppDatabase`, and make sure the database schema is ready.
init(_ dbWriter: DatabaseWriter) throws {
self.dbWriter = dbWriter
try migrator.migrate(dbWriter)
}
/// Provides access to the database.
///
/// Application can use a `DatabasePool`, while SwiftUI previews and tests
/// can use a fast in-memory `DatabaseQueue`.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
private let dbWriter: DatabaseWriter
/// The DatabaseMigrator that defines the database schema.
///
/// See https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md
private var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
#if DEBUG
// Speed up development by nuking the database when migrations change
// See https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md#the-erasedatabaseonschemachange-option
migrator.eraseDatabaseOnSchemaChange = true
#endif
migrator.registerMigration("createPlayer") { db in
// Create a table
// See https://github.com/groue/GRDB.swift#create-tables
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
}
}
// Migrations for future application versions will be inserted here:
// migrator.registerMigration(...) { db in
// ...
// }
return migrator
}
}
// MARK: - Database Access: Writes
extension AppDatabase {
/// Saves (inserts or updates) a player. When the method returns, the
/// player is present in the database, and its id is not nil.
func savePlayer(_ player: inout Player) throws {
try dbWriter.write { db in
try player.save(db)
}
}
/// Delete the specified players
func deletePlayers(ids: [Int64]) throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db, keys: ids)
}
}
/// Delete all players
func deleteAllPlayers() throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db)
}
}
/// Refresh all players (by performing some random changes, for demo purpose).
func refreshPlayers() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
// When database is empty, insert new random players
try createRandomPlayers(db)
} else {
// Insert a player
if Bool.random() {
var player = Player.newRandom()
try player.insert(db)
}
// Delete a random player
if Bool.random() {
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
}
// Update some players
for var player in try Player.fetchAll(db) where Bool.random() {
try player.updateChanges(db) {
$0.score = Player.randomScore()
}
}
}
}
}
/// Create random players if the database is empty.
func createRandomPlayersIfEmpty() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
try createRandomPlayers(db)
}
}
}
/// Support for `createRandomPlayersIfEmpty()` and `refreshPlayers()`.
private func createRandomPlayers(_ db: Database) throws {
for _ in 0..<8 {
var player = Player.newRandom()
try player.insert(db)
}
}
}
// MARK: - Database Access: Reads
extension AppDatabase {
/// Returns a publisher that tracks changes in players ordered by name
func playersOrderedByNamePublisher() -> AnyPublisher<[Player], Error> {
ValueObservation
.tracking(Player.all().orderedByName().fetchAll)
.publisher(in: dbWriter, scheduling: .immediate)
.eraseToAnyPublisher()
}
/// Returns a publisher that tracks changes in players ordered by score
func playersOrderedByScorePublisher() -> AnyPublisher<[Player], Error> {
ValueObservation
.tracking(Player.all().orderedByScore().fetchAll)
.publisher(in: dbWriter, scheduling: .immediate)
.eraseToAnyPublisher()
}
}
@@ -0,0 +1,12 @@
import SwiftUI
@main
struct GRDBCombineDemoApp: App {
let appDatabase = AppDatabase.shared
var body: some Scene {
WindowGroup {
PlayerList(viewModel: PlayerListViewModel(database: appDatabase))
}
}
}
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchScreen</key>
<dict/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -0,0 +1,58 @@
import GRDB
extension AppDatabase {
/// The database for the application
static let shared = makeShared()
private static func makeShared() -> AppDatabase {
do {
// Create a folder for storing the SQLite database, as well as
// the various temporary files created during normal database
// operations (https://sqlite.org/tempfiles.html).
let fileManager = FileManager()
let folderURL = try fileManager
.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("database", isDirectory: true)
try fileManager.createDirectory(at: folderURL, withIntermediateDirectories: true)
// Connect to a database on disk
// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
let dbURL = folderURL.appendingPathComponent("db.sqlite")
let dbPool = try DatabasePool(path: dbURL.path)
// Create the AppDatabase
let appDatabase = try AppDatabase(dbPool)
// Populate the database if it is empty, for better demo purpose.
try appDatabase.createRandomPlayersIfEmpty()
return appDatabase
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate.
//
// Typical reasons for an error here include:
// * The parent directory cannot be created, or disallows writing.
// * The database is not accessible, due to permissions or data protection when the device is locked.
// * The device is out of space.
// * The database could not be migrated to its latest schema version.
// Check the error message to determine what the actual problem was.
fatalError("Unresolved error \(error)")
}
}
/// Creates an empty database for SwiftUI previews
static func empty() -> AppDatabase {
// Connect to an in-memory database
// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
let dbQueue = DatabaseQueue()
return try! AppDatabase(dbQueue)
}
/// Creates a database full of random players for SwiftUI previews
static func random() -> AppDatabase {
let appDatabase = empty()
try! appDatabase.createRandomPlayersIfEmpty()
return appDatabase
}
}
@@ -0,0 +1,105 @@
import GRDB
/// The Player struct.
///
/// Identifiable conformance supports SwiftUI list animations.
/// Equatable conformance supports tests.
struct Player: Identifiable, Equatable {
/// The player id.
///
/// Int64 is the recommended type for auto-incremented database ids.
/// Use nil for players that are not inserted yet in the database.
var id: Int64?
var name: String
var score: Int
}
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é"]
/// Creates a new player with empty name and zero score
static func new() -> Player {
Player(id: nil, name: "", score: 0)
}
/// Creates a new player with random name and random score
static func newRandom() -> Player {
Player(id: nil, name: randomName(), score: randomScore())
}
/// Returns a random name
static func randomName() -> String {
names.randomElement()!
}
/// Returns a random score
static func randomScore() -> Int {
10 * Int.random(in: 0...100)
}
}
// MARK: - Persistence
/// Make Player a Codable Record.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#records
extension Player: Codable, FetchableRecord, MutablePersistableRecord {
// Define database columns from CodingKeys
fileprivate enum Columns {
static let name = Column(CodingKeys.name)
static let score = Column(CodingKeys.score)
}
/// Updates a player id after it has been inserted in the database.
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
// MARK: - Player Database Requests
/// Define some player requests used by the application.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#requests
/// See https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
extension DerivableRequest where RowDecoder == Player {
/// A request of players ordered by name.
///
/// For example:
///
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByName().fetchAll(db)
/// }
func orderedByName() -> Self {
// Sort by name in a localized case insensitive fashion
// See https://github.com/groue/GRDB.swift/blob/master/README.md#string-comparison
order(Player.Columns.name.collating(.localizedCaseInsensitiveCompare))
}
/// A request of players ordered by score.
///
/// For example:
///
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByScore().fetchAll(db)
/// }
/// let bestPlayer: Player? = try dbWriter.read { db in
/// try Player.all().orderedByScore().fetchOne(db)
/// }
func orderedByScore() -> Self {
// Sort by descending score, and then by name, in a
// localized case insensitive fashion
// See https://github.com/groue/GRDB.swift/blob/master/README.md#string-comparison
order(
Player.Columns.score.desc,
Player.Columns.name.collating(.localizedCaseInsensitiveCompare))
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -1,71 +1,112 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"size" : "29x29",
"filename" : "icon_20pt@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"size" : "29x29",
"filename" : "icon_20pt@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"size" : "40x40",
"filename" : "icon_29pt@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "icon_29pt@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon_40pt@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon_40pt@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"filename" : "icon_60pt@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"filename" : "icon_60pt@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "icon_20pt.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "icon_20pt@2x-1.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon_29pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon_29pt@2x-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon_40pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon_40pt@2x-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon_76pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon_76pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "icon_83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon.png",
"scale" : "1x"
}
],
"info" : {
Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "LaunchIcon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchIcon" translatesAutoresizingMaskIntoConstraints="NO" id="Sgi-te-PKu">
<rect key="frame" x="123.5" y="334.5" width="167" height="237"/>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Sgi-te-PKu" firstAttribute="centerY" secondItem="6Tk-OE-BBY" secondAttribute="centerY" id="KT7-xd-gV4"/>
<constraint firstItem="Sgi-te-PKu" firstAttribute="centerX" secondItem="6Tk-OE-BBY" secondAttribute="centerX" id="feL-Vs-SeN"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="LaunchIcon" width="167" height="237"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>%lld Players</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@VARIABLE@</string>
<key>VARIABLE</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>No Player</string>
<key>one</key>
<string>1 Player</string>
<key>other</key>
<string>%lld Players</string>
</dict>
</dict>
<key>%lld points</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@VARIABLE@</string>
<key>VARIABLE</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>0 point</string>
<key>one</key>
<string>1 point</string>
<key>other</key>
<string>%lld points</string>
</dict>
</dict>
</dict>
</plist>
@@ -0,0 +1,67 @@
import Combine
import Foundation
/// The view model that validates and saves an edited player into the database.
///
/// It feeds `PlayerForm`, `PlayerCreationSheet` and `PlayerEditionView`.
final class PlayerFormViewModel: ObservableObject {
/// A validation error that prevents the player from being saved into
/// the database.
enum ValidationError: LocalizedError {
case missingName
var errorDescription: String? {
switch self {
case .missingName:
return "Please give a name to this player."
}
}
}
@Published var name: String = ""
@Published var score: String = ""
private let database: AppDatabase
private var player: Player
init(database: AppDatabase, player: Player) {
self.database = database
self.player = player
updateViewFromPlayer()
}
// MARK: - Manage the Player Form
/// Validates and saves the player into the database.
func savePlayer() throws {
if name.isEmpty {
throw ValidationError.missingName
}
player.name = name
player.score = Int(score) ?? 0
try database.savePlayer(&player)
}
/// Resets form values to the original player values.
func reset() {
updateViewFromPlayer()
}
/// Edits a new player
func editNewPlayer() {
player = .new()
updateViewFromPlayer()
}
// MARK: - Private
private func updateViewFromPlayer() {
self.name = player.name
if player.score == 0 && player.id == nil {
// Avoid displaying "0" for a new player: it does not look good.
self.score = ""
} else {
self.score = "\(player.score)"
}
}
}
@@ -0,0 +1,118 @@
import Combine
import Foundation
/// The view model that feeds `PlayerList`, and performs list modifications
/// in the database.
final class PlayerListViewModel: ObservableObject {
enum Ordering {
case byScore
case byName
}
struct PlayerList {
var players: [Player]
var animatedChanges: Bool
}
/// The list ordering
@Published var ordering: Ordering = .byScore
/// The players in the list
@Published var playerList = PlayerList(players: [], animatedChanges: false)
/// The view model that edits a new player
let newPlayerViewModel: PlayerFormViewModel
private let database: AppDatabase
private var playersCancellable: AnyCancellable?
init(database: AppDatabase) {
self.database = database
newPlayerViewModel = PlayerFormViewModel(database: database, player: .new())
playersCancellable = playersPublisher(in: database)
.scan(nil) { (previousList: PlayerList?, players: [Player]) in
if previousList == nil {
// Do not animate first view update
return PlayerList(players: players, animatedChanges: false)
} else {
return PlayerList(players: players, animatedChanges: true)
}
}
.compactMap { $0 }
.sink { [weak self] playerList in
self?.playerList = playerList
}
}
// MARK: - Players List Management
/// Deletes all players
func deleteAllPlayers() {
// Eventual error presentation is left as an exercise for the reader.
try! database.deleteAllPlayers()
}
func deletePlayers(atOffsets offsets: IndexSet) {
// Eventual error presentation is left as an exercise for the reader.
let playerIDs = offsets.compactMap { playerList.players[$0].id }
try! database.deletePlayers(ids: playerIDs)
}
/// Refreshes the list of players
func refreshPlayers() {
// Eventual error presentation is left as an exercise for the reader.
try! database.refreshPlayers()
}
/// Spawns many concurrent database updates, for demo purpose
func stressTest() {
for _ in 0..<50 {
DispatchQueue.global().async {
self.refreshPlayers()
}
}
}
// MARK: - Change Player Ordering
/// Toggles between the available orderings
func toggleOrdering() {
switch ordering {
case .byName:
ordering = .byScore
case .byScore:
ordering = .byName
}
}
// MARK: - Player Edition
/// Returns a view model suitable for editing a player.
func formViewModel(for player: Player) -> PlayerFormViewModel {
PlayerFormViewModel(database: database, player: player)
}
// MARK: - Private
/// Returns a publisher of the players in the list
private func playersPublisher(in database: AppDatabase) -> AnyPublisher<[Player], Never> {
// Players depend on the current ordering
$ordering.map { ordering -> AnyPublisher<[Player], Error> in
switch ordering {
case .byScore:
return database.playersOrderedByScorePublisher()
case .byName:
return database.playersOrderedByNamePublisher()
}
}
.map { playersPublisher in
// Turn database errors into an empty players list.
// Eventual error presentation is left as an exercise for the reader.
playersPublisher.catch { error in
Just<[Player]>([])
}
}
.switchToLatest()
.eraseToAnyPublisher()
}
}
@@ -0,0 +1,52 @@
import SwiftUI
/// The Player creation sheet
struct PlayerCreationSheet: View {
/// Manages the player form
let viewModel: PlayerFormViewModel
/// Executed when user cancels or saves the new user.
let dismissAction: () -> Void
@State private var errorAlertIsPresented = false
@State private var errorAlertTitle = ""
var body: some View {
NavigationView {
PlayerForm(viewModel: viewModel)
.alert(
isPresented: $errorAlertIsPresented,
content: { Alert(title: Text(errorAlertTitle)) })
.navigationBarTitle("New Player")
.navigationBarItems(
leading: Button(
action: self.dismissAction,
label: { Text("Cancel") }),
trailing: Button(
action: self.save,
label: { Text("Save") }))
}
}
private func save() {
do {
try viewModel.savePlayer()
dismissAction()
} catch {
errorAlertTitle = (error as? LocalizedError)?.errorDescription ?? "An error occurred"
errorAlertIsPresented = true
}
}
}
struct PlayerCreationSheet_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerFormViewModel(
database: .empty(),
player: .new())
return PlayerCreationSheet(
viewModel: viewModel,
dismissAction: { })
}
}
@@ -0,0 +1,29 @@
import SwiftUI
/// The Player edition view, designed to be the destination of
/// a NavigationLink.
struct PlayerEditionView: View {
/// Manages the player form
let viewModel: PlayerFormViewModel
var body: some View {
PlayerForm(viewModel: viewModel)
.onDisappear(perform: {
// Ignore validation errors
try? self.viewModel.savePlayer()
})
}
}
struct PlayerEditionView_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerFormViewModel(
database: .empty(),
player: .newRandom())
return NavigationView {
PlayerEditionView(viewModel: viewModel)
.navigationBarTitle("Player Edition")
}
}
}
@@ -0,0 +1,39 @@
import SwiftUI
/// The Player editing form, embedded in both
/// `PlayerCreationSheet` and `PlayerEditionView`.
struct PlayerForm: View {
/// Manages the player form
@ObservedObject var viewModel: PlayerFormViewModel
var body: some View {
List {
TextField("Name", text: $viewModel.name)
TextField("Score", text: $viewModel.score)
.keyboardType(.numberPad)
}
.listStyle(GroupedListStyle())
// Make sure the form is reset, in case a previous edition ended
// with a validation error.
//
// The bug we want to prevent is the following:
//
// 1. Launch the app
// 2. Tap a player
// 3. Erase the name so that validation fails
// 4. Hit the back button
// 5. Tap the same player
// 6. Bug: the form displays an empty name.
.onAppear(perform: viewModel.reset)
}
}
struct PlayerFormView_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerFormViewModel(
database: .empty(),
player: .newRandom())
return PlayerForm(viewModel: viewModel)
}
}
@@ -0,0 +1,131 @@
import SwiftUI
/// The list of players
struct PlayerList: View {
/// Manages the list of players
@ObservedObject var viewModel: PlayerListViewModel
/// Controls the presentation of the player creation sheet.
@State private var newPlayerIsPresented = false
var body: some View {
NavigationView {
VStack {
playerList
toolbar
}
.navigationBarTitle(Text("\(viewModel.playerList.players.count) Players"))
.navigationBarItems(
leading: HStack {
EditButton()
newPlayerButton
},
trailing: toggleOrderingButton)
}
}
private var playerList: some View {
List {
ForEach(viewModel.playerList.players) { player in
NavigationLink(destination: self.editionView(for: player)) {
PlayerRow(player: player)
.animation(nil)
}
}
.onDelete(perform: { offsets in
self.viewModel.deletePlayers(atOffsets: offsets)
})
}
.listStyle(PlainListStyle())
.animation(viewModel.playerList.animatedChanges ? .default : nil)
}
private var toolbar: some View {
HStack {
Button(
action: viewModel.deleteAllPlayers,
label: { Image(systemName: "trash").imageScale(.large) })
Spacer()
Button(
action: viewModel.refreshPlayers,
label: { Image(systemName: "arrow.clockwise").imageScale(.large) })
Spacer()
Button(
action: viewModel.stressTest,
label: { Image(systemName: "tornado").imageScale(.large) })
}
.padding()
}
/// The button that toggles between name/score ordering.
private var toggleOrderingButton: some View {
switch viewModel.ordering {
case .byName:
return Button(action: viewModel.toggleOrdering, label: {
HStack {
Text("Name")
Image(systemName: "arrowtriangle.up.fill")
.imageScale(.small)
}
})
case .byScore:
return Button(action: viewModel.toggleOrdering, label: {
HStack {
Text("Score")
Image(systemName: "arrowtriangle.down.fill")
.imageScale(.small)
}
})
}
}
/// The view that edits a player in the list.
private func editionView(for player: Player) -> some View {
PlayerEditionView(
viewModel: viewModel.formViewModel(for: player))
.navigationBarTitle(player.name)
}
/// The button that presents the player creation sheet.
private var newPlayerButton: some View {
Button(
action: {
// Make sure we do not edit a previously created player.
self.viewModel.newPlayerViewModel.editNewPlayer()
self.newPlayerIsPresented = true
},
label: { Image(systemName: "plus").imageScale(.large) })
.sheet(
isPresented: $newPlayerIsPresented,
content: { self.newPlayerCreationSheet })
}
/// The player creation sheet.
private var newPlayerCreationSheet: some View {
PlayerCreationSheet(
viewModel: self.viewModel.newPlayerViewModel,
dismissAction: {
self.newPlayerIsPresented = false
})
}
}
struct PlayerRow: View {
var player: Player
var body: some View {
HStack {
Text(player.name)
Spacer()
Text("\(player.score) points").foregroundColor(.gray)
}
}
}
struct PlayerListView_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerListViewModel(database: .random())
return PlayerList(viewModel: viewModel)
}
}
@@ -0,0 +1,254 @@
import XCTest
import GRDB
@testable import GRDBCombineDemo
class AppDatabaseTests: XCTestCase {
func test_database_schema() throws {
// Given an empty database
let dbQueue = DatabaseQueue()
// When we instantiate an AppDatabase
_ = try AppDatabase(dbQueue)
// Then the player table exists, with id, name & score columns
try dbQueue.read { db in
try XCTAssert(db.tableExists("player"))
let columns = try db.columns(in: "player")
let columnNames = Set(columns.map { $0.name })
XCTAssertEqual(columnNames, ["id", "name", "score"])
}
}
func test_savePlayer_inserts() throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we save a new player
var player = Player(id: nil, name: "Arthur", score: 100)
try appDatabase.savePlayer(&player)
// Then the player exists in the database
try XCTAssertTrue(dbQueue.read(player.exists))
}
func test_savePlayer_updates() throws {
// Given a players database that contains a player
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player = Player(id: nil, name: "Arthur", score: 100)
try dbQueue.write { db in
try player.insert(db)
}
// When we modify and save the player
player.name = "Barbara"
player.score = 1000
try appDatabase.savePlayer(&player)
// Then the player has been updated in the database
let fetchedPlayer = try dbQueue.read { db in
try XCTUnwrap(Player.fetchOne(db, key: player.id))
}
XCTAssertEqual(fetchedPlayer, player)
}
func test_deletePlayers() throws {
// Given a players database that contains four players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player1 = Player(id: nil, name: "Arthur", score: 100)
var player2 = Player(id: nil, name: "Barbara", score: 200)
var player3 = Player(id: nil, name: "Craig", score: 150)
var player4 = Player(id: nil, name: "David", score: 120)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
try player3.insert(db)
try player4.insert(db)
}
// When we delete two players
try appDatabase.deletePlayers(ids: [player1.id!, player3.id!])
// Then the deleted players no longer exist
try dbQueue.read { db in
try XCTAssertFalse(player1.exists(db))
try XCTAssertFalse(player3.exists(db))
}
// Then the database still contains two players
try XCTAssertEqual(dbQueue.read(Player.fetchCount), 2)
}
func test_deleteAllPlayers() throws {
// Given a players database that contains players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player1 = Player(id: nil, name: "Arthur", score: 100)
var player2 = Player(id: nil, name: "Barbara", score: 200)
var player3 = Player(id: nil, name: "Craig", score: 150)
var player4 = Player(id: nil, name: "David", score: 120)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
try player3.insert(db)
try player4.insert(db)
}
// When we delete all players
try appDatabase.deleteAllPlayers()
// Then the database does not contain any player
try XCTAssertEqual(dbQueue.read(Player.fetchCount), 0)
}
func test_refreshPlayers_populates_an_empty_database() throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we refresh players
try appDatabase.refreshPlayers()
// Then the database is not empty
try XCTAssert(dbQueue.read(Player.fetchCount) > 0)
}
func test_createRandomPlayersIfEmpty_populates_an_empty_database() throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we create random players
try appDatabase.createRandomPlayersIfEmpty()
// Then the database is not empty
try XCTAssert(dbQueue.read(Player.fetchCount) > 0)
}
func test_createRandomPlayersIfEmpty_does_not_modify_a_non_empty_database() throws {
// Given a players database that contains one player
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player = Player(id: nil, name: "Arthur", score: 100)
try dbQueue.write { db in
try player.insert(db)
}
// When we create random players
try appDatabase.createRandomPlayersIfEmpty()
// Then the database still only contains the original player
let players = try dbQueue.read(Player.fetchAll)
XCTAssertEqual(players, [player])
}
func test_playersOrderedByNamePublisher_publishes_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player1 = Player(id: nil, name: "Arthur", score: 100)
var player2 = Player(id: nil, name: "Barbara", score: 1000)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
}
// When we observe players and wait for the first value
let exp = expectation(description: "Players")
var players: [Player]?
let cancellable = appDatabase.playersOrderedByNamePublisher().sink { completion in
if case let .failure(error) = completion {
XCTFail("Unexpected error \(error)")
}
} receiveValue: {
players = $0
exp.fulfill()
}
withExtendedLifetime(cancellable) {
waitForExpectations(timeout: 1, handler: nil)
}
// Then the players are the two players ordered by name
XCTAssertEqual(players, [player1, player2])
}
func test_playersOrderedByNamePublisher_publishes_right_on_subscripion() throws {
// Our SwiftUI views have no "waiting" state, and must be fed with
// players without any delay in order to avoid any rendering glitch.
// This test makes sure `playersOrderedByNamePublisher` publishes right
// on subscription.
// Given a players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we observe players
var players: [Player]?
_ = appDatabase.playersOrderedByNamePublisher().sink { completion in
if case let .failure(error) = completion {
XCTFail("Unexpected error \(error)")
}
} receiveValue: {
players = $0
}
// Then the players are published right on subscription
XCTAssertNotNil(players)
}
func test_playersOrderedByScorePublisher_publishes_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player1 = Player(id: nil, name: "Arthur", score: 100)
var player2 = Player(id: nil, name: "Barbara", score: 1000)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
}
// When we observe players and wait for the first value
let exp = expectation(description: "Players")
var players: [Player]?
let cancellable = appDatabase.playersOrderedByScorePublisher().sink { completion in
if case let .failure(error) = completion {
XCTFail("Unexpected error \(error)")
}
} receiveValue: {
players = $0
exp.fulfill()
}
withExtendedLifetime(cancellable) {
waitForExpectations(timeout: 1, handler: nil)
}
// Then the players are the two players ordered by score descending
XCTAssertEqual(players, [player2, player1])
}
func test_playersOrderedByScorePublisher_publishes_right_on_subscripion() throws {
// Our SwiftUI views have no "waiting" state, and must be fed with
// players without any delay in order to avoid any rendering glitch.
// This test makes sure `playersOrderedByScorePublisher` publishes right
// on subscription.
// Given a players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we observe players
var players: [Player]?
_ = appDatabase.playersOrderedByScorePublisher().sink { completion in
if case let .failure(error) = completion {
XCTFail("Unexpected error \(error)")
}
} receiveValue: {
players = $0
}
// Then the players are published right on subscription
XCTAssertNotNil(players)
}
}
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
@@ -0,0 +1,108 @@
import XCTest
import GRDB
@testable import GRDBCombineDemo
class PlayerTests: XCTestCase {
// MARK: - CRUD
// Test that our Player type properly talks to GRDB.
func testInsert() throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
_ = try AppDatabase(dbQueue)
// When we insert a player
var player = Player(id: nil, name: "Arthur", score: 100)
try dbQueue.write { db in
try player.insert(db)
}
// Then the player gets a non-nil id
XCTAssertNotNil(player.id)
}
func testRoundtrip() throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
_ = try AppDatabase(dbQueue)
// When we insert a player and fetch the player with the same id
var insertedPlayer = Player(id: nil, name: "Arthur", score: 100)
let fetchedPlayer: Player? = try dbQueue.write { db in
try insertedPlayer.insert(db)
return try Player.fetchOne(db, key: insertedPlayer.id)
}
// Then the fetched player is equal to the inserted player
XCTAssertEqual(insertedPlayer, fetchedPlayer)
}
// MARK: - Requests
// Test that requests defined on the Player type behave as expected.
func testOrderedByScore() throws {
// Given a players database that contains players with distinct scores
let dbQueue = DatabaseQueue()
_ = try AppDatabase(dbQueue)
var player1 = Player(id: 1, name: "Arthur", score: 100)
var player2 = Player(id: 2, name: "Barbara", score: 200)
var player3 = Player(id: 3, name: "Craig", score: 150)
var player4 = Player(id: 4, name: "David", score: 120)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
try player3.insert(db)
try player4.insert(db)
}
// When we fetch players ordered by score
let players = try dbQueue.read(Player.all().orderedByScore().fetchAll)
// Then fetched players are ordered by score descending
XCTAssertEqual(players, [player2, player3, player4, player1])
}
func testOrderedByScoreSortsIdenticalScoresByName() throws {
// Given a players database that contains players with common scores
let dbQueue = DatabaseQueue()
_ = try AppDatabase(dbQueue)
var player1 = Player(id: 1, name: "Arthur", score: 100)
var player2 = Player(id: 2, name: "Barbara", score: 200)
var player3 = Player(id: 3, name: "Craig", score: 200)
var player4 = Player(id: 4, name: "David", score: 200)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
try player3.insert(db)
try player4.insert(db)
}
// When we fetch players ordered by score
let players = try dbQueue.read(Player.all().orderedByScore().fetchAll)
// Then fetched players are ordered by score descending and by name
XCTAssertEqual(players, [player2, player3, player4, player1])
}
func testOrderedByName() throws {
// Given a players database that contains players with distinct names
let dbQueue = DatabaseQueue()
_ = try AppDatabase(dbQueue)
var player1 = Player(id: 1, name: "Arthur", score: 100)
var player2 = Player(id: 2, name: "Barbara", score: 200)
var player3 = Player(id: 3, name: "Craig", score: 150)
var player4 = Player(id: 4, name: "David", score: 120)
try dbQueue.write { db in
try player1.insert(db)
try player2.insert(db)
try player3.insert(db)
try player4.insert(db)
}
// When we fetch players ordered by name
let players = try dbQueue.read(Player.all().orderedByName().fetchAll)
// Then fetched players are ordered by name
XCTAssertEqual(players, [player1, player2, player3, player4])
}
}
@@ -0,0 +1,48 @@
Combine + SwiftUI Demo Application
==================================
<img align="right" src="https://github.com/groue/GRDB.swift/raw/master/Documentation/DemoApps/GRDBCombineDemo/Screenshot.png" width="50%">
**This demo application is a Combine + SwiftUI application, based on the MVVM design pattern.** For a demo application that uses UIKit, see [GRDBDemoiOS](../GRDBDemoiOS/README.md).
> :point_up: **Note**: This demo app is not a project template. Do not copy it as a starting point for your application. Instead, create a new project, choose a GRDB [installation method](../../../README.md#installation), and use the demo as an inspiration.
The topics covered in this demo are:
- 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 SwiftUI List with [ValueObservation](../../../README.md#valueobservation) Combine publishers.
- How to apply the recommendations of [Good Practices for Designing Record Types](../../GoodPracticesForDesigningRecordTypes.md).
- How to feed SwiftUI previews with a transient database.
**Files of interest:**
- [GRDBCombineDemoApp.swift](GRDBCombineDemo/GRDBCombineDemoApp.swift)
`GRDBCombineDemoApp` feeds the app views with a database.
- [AppDatabase.swift](GRDBCombineDemo/AppDatabase.swift)
`AppDatabase` is the type that grants database access. It uses [DatabaseMigrator](../../Migrations.md) in order to setup the database schema, and [ValueObservation](../../../README.md#valueobservation) in order to let the application observe database changes.
- [Persistence.swift](GRDBCombineDemo/Persistence.swift)
This file instantiates various `AppDatabase` for the various projects needs: one database on disk for the application, and in-memory databases for SwiftUI previews.
- [Player.swift](GRDBCombineDemo/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). It defines the database requests used by the application.
- [PlayerList.swift](GRDBCombineDemo/Views/PlayerList.swift) and [PlayerListViewModel.swift](GRDBCombineDemo/ViewModels/PlayerListViewModel.swift)
`PlayerList` is the SwiftUI view that displays the list of players, fed by `PlayerListViewModel`.
- [PlayerForm.swift](GRDBCombineDemo/Views/PlayerForm.swift), [PlayerEditionView.swift](GRDBCombineDemo/Views/PlayerEditionView.swift), [PlayerCreationSheet.swift](GRDBCombineDemo/Views/PlayerCreationSheet.swift) and [PlayerFormViewModel.swift](GRDBCombineDemo/ViewModels/PlayerFormViewModel.swift).
`PlayerForm` is the SwiftUI view that displays a Player editing form. It is embedded in `PlayerEditionView` and `PlayerCreationSheet`, two SwiftUI views that edit or create a player. All those views are fed by `PlayerFormViewModel`.
- [GRDBCombineDemoTests](GRDBCombineDemoTests)
- Test the database schema
- Test the `Player` record and its requests
- Test the `AppDatabase` methods that let the app access the database.
Binary file not shown.

After

Width:  |  Height:  |  Size: 799 KiB

@@ -15,6 +15,7 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
// Use this method to pause ongoing tasks, disable timers, etc.
}
@available(watchOSApplicationExtension 3.0, *)
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
// Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one.
for task in backgroundTasks {
@@ -25,7 +25,7 @@
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>com.github.groue.GRDBDemoiOS2.watchkitapp</string>
<string>com.github.groue.GRDBDemoiOS.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
@@ -1,7 +1,6 @@
import WatchKit
import Foundation
import GRDB
import SQLite3
class InterfaceController: WKInterfaceController {
@@ -26,7 +26,7 @@
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>WKCompanionAppBundleIdentifier</key>
<string>com.github.groue.GRDBDemoiOS2</string>
<string>com.github.groue.GRDBDemoiOS</string>
<key>WKWatchKitApp</key>
<true/>
</dict>
@@ -7,6 +7,13 @@
objects = {
/* Begin PBXBuildFile section */
56185BBF25B8036100B9C30F /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56185BBE25B8036100B9C30F /* Persistence.swift */; };
56185BF325B80B8900B9C30F /* AppDatabaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56185BF225B80B8900B9C30F /* AppDatabaseTests.swift */; };
56185C0725B80CEC00B9C30F /* PlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56185C0625B80CEC00B9C30F /* PlayerTests.swift */; };
56606D202355938A00185962 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56606D142355931F00185962 /* GRDB.framework */; };
56606D212355938A00185962 /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 56606D142355931F00185962 /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
56606D24235593AB00185962 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56606D182355931F00185962 /* GRDB.framework */; };
56606D25235593AB00185962 /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 56606D182355931F00185962 /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
568E5FC31E926430002582E0 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 568E5FC11E926430002582E0 /* Interface.storyboard */; };
568E5FC51E926430002582E0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 568E5FC41E926430002582E0 /* Assets.xcassets */; };
568E5FCC1E926430002582E0 /* GRDBDemoWatchOS Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 568E5FCB1E926430002582E0 /* GRDBDemoWatchOS Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -14,8 +21,6 @@
568E5FD31E926430002582E0 /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568E5FD21E926430002582E0 /* ExtensionDelegate.swift */; };
568E5FD51E926430002582E0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 568E5FD41E926430002582E0 /* Assets.xcassets */; };
568E5FD91E926430002582E0 /* GRDBDemoWatchOS.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 568E5FBF1E926430002582E0 /* GRDBDemoWatchOS.app */; };
568E5FE41E926547002582E0 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56B0365B1E8D9F79003B6DA4 /* GRDB.framework */; };
568E5FE51E926547002582E0 /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 56B0365B1E8D9F79003B6DA4 /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
56B036071E8D9EBE003B6DA4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B036061E8D9EBE003B6DA4 /* AppDelegate.swift */; };
56B0360C1E8D9EBE003B6DA4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 56B0360A1E8D9EBE003B6DA4 /* Main.storyboard */; };
56B0360E1E8D9EBE003B6DA4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 56B0360D1E8D9EBE003B6DA4 /* Assets.xcassets */; };
@@ -23,18 +28,87 @@
56B0361B1E8D9F38003B6DA4 /* AppDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B036191E8D9F38003B6DA4 /* AppDatabase.swift */; };
56B0361C1E8D9F38003B6DA4 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B0361A1E8D9F38003B6DA4 /* Player.swift */; };
56B036231E8D9F4C003B6DA4 /* PlayerEditionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B0361F1E8D9F4C003B6DA4 /* PlayerEditionViewController.swift */; };
56B036241E8D9F4C003B6DA4 /* PlayersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B036201E8D9F4C003B6DA4 /* PlayersViewController.swift */; };
56B0365E1E8D9FB1003B6DA4 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56B0364D1E8D9F79003B6DA4 /* GRDB.framework */; };
56B0365F1E8D9FB1003B6DA4 /* GRDB.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 56B0364D1E8D9F79003B6DA4 /* GRDB.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
56B036241E8D9F4C003B6DA4 /* PlayerListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B036201E8D9F4C003B6DA4 /* PlayerListViewController.swift */; };
56FE6F2624A90CE400711EDF /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FE6F2524A90CE400711EDF /* SceneDelegate.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
563BD2F01F8364C1006A5390 /* PBXContainerItemProxy */ = {
56185BF525B80B8900B9C30F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B035FB1E8D9EBE003B6DA4 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 56B036021E8D9EBE003B6DA4;
remoteInfo = GRDBDemoiOS;
};
56606D092355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56439B501F4CA1DC0066043F;
remoteInfo = GRDBOSXPerformanceComparisonTests;
remoteGlobalIDString = DC3773F319C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
56606D0B2355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7F91B4D422D00430942;
remoteInfo = GRDBOSXTests;
};
56606D112355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56553C181C3E906C00522B5C;
remoteInfo = GRDBOSXCrashTests;
};
56606D132355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7CA1B4D3FED00430942;
remoteInfo = GRDBiOS;
};
56606D152355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7D31B4D3FEE00430942;
remoteInfo = GRDBiOSTests;
};
56606D172355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 565490A01D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
56606D192355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = AAA4DCFE230F1E0600C74B15;
remoteInfo = GRDBtvOS;
};
56606D1B2355931F00185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = AAA4DDD4230F262000C74B15;
remoteInfo = GRDBtvOSTests;
};
56606D1D2355937900185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
};
56606D22235593A300185962 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5654909F1D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
568E5FCD1E926430002582E0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -50,83 +124,6 @@
remoteGlobalIDString = 568E5FBE1E926430002582E0;
remoteInfo = GRDBDemoWatchOS;
};
568E5FE21E926535002582E0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5654909F1D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
568E5FE61E926547002582E0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5654909F1D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
56B0363A1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = DC3773F319C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
56B0363C1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7F91B4D422D00430942;
remoteInfo = GRDBOSXTests;
};
56B0363E1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 560C981A1C0E22D300BF8471;
remoteInfo = GRDBOSXPerformanceTests;
};
56B036401E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56553C181C3E906C00522B5C;
remoteInfo = GRDBOSXCrashTests;
};
56B0364C1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7CA1B4D3FED00430942;
remoteInfo = GRDBiOS;
};
56B0364E1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 56E5D7D31B4D3FEE00430942;
remoteInfo = GRDBiOSTests;
};
56B0365A1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 565490A01D5A4798005622CB;
remoteInfo = GRDBWatchOS;
};
56B0365C1E8D9F8F003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
};
56B036601E8D9FB1003B6DA4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -158,7 +155,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
568E5FE51E926547002582E0 /* GRDB.framework in Embed Frameworks */,
56606D25235593AB00185962 /* GRDB.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -169,7 +166,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
56B0365F1E8D9FB1003B6DA4 /* GRDB.framework in Embed Frameworks */,
56606D212355938A00185962 /* GRDB.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -177,6 +174,11 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
56185BBE25B8036100B9C30F /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = "<group>"; };
56185BF025B80B8900B9C30F /* GRDBDemoiOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBDemoiOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56185BF225B80B8900B9C30F /* AppDatabaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDatabaseTests.swift; sourceTree = "<group>"; };
56185BF425B80B8900B9C30F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
56185C0625B80CEC00B9C30F /* PlayerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerTests.swift; sourceTree = "<group>"; };
568E5FBF1E926430002582E0 /* GRDBDemoWatchOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBDemoWatchOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
568E5FC21E926430002582E0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = "<group>"; };
568E5FC41E926430002582E0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -195,16 +197,24 @@
56B036191E8D9F38003B6DA4 /* AppDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDatabase.swift; sourceTree = "<group>"; };
56B0361A1E8D9F38003B6DA4 /* Player.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
56B0361F1E8D9F4C003B6DA4 /* PlayerEditionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerEditionViewController.swift; sourceTree = "<group>"; };
56B036201E8D9F4C003B6DA4 /* PlayersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayersViewController.swift; sourceTree = "<group>"; };
56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GRDB.xcodeproj; path = ../../GRDB.xcodeproj; sourceTree = "<group>"; };
56B036201E8D9F4C003B6DA4 /* PlayerListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerListViewController.swift; sourceTree = "<group>"; };
56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GRDB.xcodeproj; path = ../../../GRDB.xcodeproj; sourceTree = "<group>"; };
56FE6F2524A90CE400711EDF /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
56185BED25B80B8900B9C30F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
568E5FC81E926430002582E0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
568E5FE41E926547002582E0 /* GRDB.framework in Frameworks */,
56606D24235593AB00185962 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -212,13 +222,45 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
56B0365E1E8D9FB1003B6DA4 /* GRDB.framework in Frameworks */,
56606D202355938A00185962 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
56185BF125B80B8900B9C30F /* GRDBDemoiOSTests */ = {
isa = PBXGroup;
children = (
56185BF425B80B8900B9C30F /* Info.plist */,
56185BF225B80B8900B9C30F /* AppDatabaseTests.swift */,
56185C0625B80CEC00B9C30F /* PlayerTests.swift */,
);
path = GRDBDemoiOSTests;
sourceTree = "<group>";
};
56606CFD2355931F00185962 /* Products */ = {
isa = PBXGroup;
children = (
56606D0A2355931F00185962 /* GRDB.framework */,
56606D0C2355931F00185962 /* GRDBOSXTests.xctest */,
56606D122355931F00185962 /* GRDBOSXCrashTests.xctest */,
56606D142355931F00185962 /* GRDB.framework */,
56606D162355931F00185962 /* GRDBiOSTests.xctest */,
56606D182355931F00185962 /* GRDB.framework */,
56606D1A2355931F00185962 /* GRDB.framework */,
56606D1C2355931F00185962 /* GRDBtvOSTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
56606D1F2355938A00185962 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
568E5FC01E926430002582E0 /* GRDBDemoWatchOS */ = {
isa = PBXGroup;
children = (
@@ -247,7 +289,9 @@
56B036051E8D9EBE003B6DA4 /* GRDBDemoiOS */,
568E5FC01E926430002582E0 /* GRDBDemoWatchOS */,
568E5FCF1E926430002582E0 /* GRDBDemoWatchOS Extension */,
56185BF125B80B8900B9C30F /* GRDBDemoiOSTests */,
56B036041E8D9EBE003B6DA4 /* Products */,
56606D1F2355938A00185962 /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -257,6 +301,7 @@
56B036031E8D9EBE003B6DA4 /* GRDBDemoiOS.app */,
568E5FBF1E926430002582E0 /* GRDBDemoWatchOS.app */,
568E5FCB1E926430002582E0 /* GRDBDemoWatchOS Extension.appex */,
56185BF025B80B8900B9C30F /* GRDBDemoiOSTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -264,37 +309,66 @@
56B036051E8D9EBE003B6DA4 /* GRDBDemoiOS */ = {
isa = PBXGroup;
children = (
56B036061E8D9EBE003B6DA4 /* AppDelegate.swift */,
56B036191E8D9F38003B6DA4 /* AppDatabase.swift */,
56B036061E8D9EBE003B6DA4 /* AppDelegate.swift */,
56185BBE25B8036100B9C30F /* Persistence.swift */,
56B0361A1E8D9F38003B6DA4 /* Player.swift */,
56B0361F1E8D9F4C003B6DA4 /* PlayerEditionViewController.swift */,
56B036201E8D9F4C003B6DA4 /* PlayersViewController.swift */,
56B0360A1E8D9EBE003B6DA4 /* Main.storyboard */,
56B0360D1E8D9EBE003B6DA4 /* Assets.xcassets */,
56B0360F1E8D9EBE003B6DA4 /* LaunchScreen.storyboard */,
56B036121E8D9EBE003B6DA4 /* Info.plist */,
56FE6F2524A90CE400711EDF /* SceneDelegate.swift */,
56FE6F4E24A9112900711EDF /* Resources */,
56FE6F5124A9118000711EDF /* Support */,
56FE6F4F24A9114200711EDF /* ViewControllers */,
);
path = GRDBDemoiOS;
sourceTree = "<group>";
};
56B036271E8D9F79003B6DA4 /* Products */ = {
56FE6F4E24A9112900711EDF /* Resources */ = {
isa = PBXGroup;
children = (
56B0363B1E8D9F79003B6DA4 /* GRDB.framework */,
56B0363D1E8D9F79003B6DA4 /* GRDBOSXTests.xctest */,
56B0363F1E8D9F79003B6DA4 /* GRDBOSXPerformanceTests.xctest */,
563BD2F11F8364C1006A5390 /* GRDBOSXPerformanceComparisonTests.xctest */,
56B036411E8D9F79003B6DA4 /* GRDBOSXCrashTests.xctest */,
56B0364D1E8D9F79003B6DA4 /* GRDB.framework */,
56B0364F1E8D9F79003B6DA4 /* GRDBiOSTests.xctest */,
56B0365B1E8D9F79003B6DA4 /* GRDB.framework */,
56B0360D1E8D9EBE003B6DA4 /* Assets.xcassets */,
56B0360F1E8D9EBE003B6DA4 /* LaunchScreen.storyboard */,
56B0360A1E8D9EBE003B6DA4 /* Main.storyboard */,
);
name = Products;
path = Resources;
sourceTree = "<group>";
};
56FE6F4F24A9114200711EDF /* ViewControllers */ = {
isa = PBXGroup;
children = (
56B0361F1E8D9F4C003B6DA4 /* PlayerEditionViewController.swift */,
56B036201E8D9F4C003B6DA4 /* PlayerListViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
56FE6F5124A9118000711EDF /* Support */ = {
isa = PBXGroup;
children = (
56B036121E8D9EBE003B6DA4 /* Info.plist */,
);
name = Support;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
56185BEF25B80B8900B9C30F /* GRDBDemoiOSTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56185BFF25B80B8900B9C30F /* Build configuration list for PBXNativeTarget "GRDBDemoiOSTests" */;
buildPhases = (
56185BEC25B80B8900B9C30F /* Sources */,
56185BED25B80B8900B9C30F /* Frameworks */,
56185BEE25B80B8900B9C30F /* Resources */,
);
buildRules = (
);
dependencies = (
56185BF625B80B8900B9C30F /* PBXTargetDependency */,
);
name = GRDBDemoiOSTests;
productName = GRDBDemoiOSTests;
productReference = 56185BF025B80B8900B9C30F /* GRDBDemoiOSTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
568E5FBE1E926430002582E0 /* GRDBDemoWatchOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = 568E5FDE1E926430002582E0 /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS" */;
@@ -324,8 +398,7 @@
buildRules = (
);
dependencies = (
568E5FE31E926535002582E0 /* PBXTargetDependency */,
568E5FE71E926547002582E0 /* PBXTargetDependency */,
56606D23235593A300185962 /* PBXTargetDependency */,
);
name = "GRDBDemoWatchOS Extension";
productName = "GRDBDemoWatchOS Extension";
@@ -345,8 +418,7 @@
buildRules = (
);
dependencies = (
56B0365D1E8D9F8F003B6DA4 /* PBXTargetDependency */,
56B036611E8D9FB1003B6DA4 /* PBXTargetDependency */,
56606D1E2355937900185962 /* PBXTargetDependency */,
568E5FD81E926430002582E0 /* PBXTargetDependency */,
);
name = GRDBDemoiOS;
@@ -360,10 +432,16 @@
56B035FB1E8D9EBE003B6DA4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1020;
LastSwiftUpdateCheck = 1230;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = "Gwendal Roué";
TargetAttributes = {
56185BEF25B80B8900B9C30F = {
CreatedOnToolsVersion = 12.3;
DevelopmentTeam = AMD8W895CT;
ProvisioningStyle = Automatic;
TestTargetID = 56B036021E8D9EBE003B6DA4;
};
568E5FBE1E926430002582E0 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = AMD8W895CT;
@@ -396,7 +474,7 @@
projectDirPath = "";
projectReferences = (
{
ProductGroup = 56B036271E8D9F79003B6DA4 /* Products */;
ProductGroup = 56606CFD2355931F00185962 /* Products */;
ProjectRef = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */;
},
);
@@ -405,70 +483,78 @@
56B036021E8D9EBE003B6DA4 /* GRDBDemoiOS */,
568E5FBE1E926430002582E0 /* GRDBDemoWatchOS */,
568E5FCA1E926430002582E0 /* GRDBDemoWatchOS Extension */,
56185BEF25B80B8900B9C30F /* GRDBDemoiOSTests */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
563BD2F11F8364C1006A5390 /* GRDBOSXPerformanceComparisonTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXPerformanceComparisonTests.xctest;
remoteRef = 563BD2F01F8364C1006A5390 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0363B1E8D9F79003B6DA4 /* GRDB.framework */ = {
56606D0A2355931F00185962 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 56B0363A1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D092355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0363D1E8D9F79003B6DA4 /* GRDBOSXTests.xctest */ = {
56606D0C2355931F00185962 /* GRDBOSXTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXTests.xctest;
remoteRef = 56B0363C1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D0B2355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0363F1E8D9F79003B6DA4 /* GRDBOSXPerformanceTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXPerformanceTests.xctest;
remoteRef = 56B0363E1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B036411E8D9F79003B6DA4 /* GRDBOSXCrashTests.xctest */ = {
56606D122355931F00185962 /* GRDBOSXCrashTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBOSXCrashTests.xctest;
remoteRef = 56B036401E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D112355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0364D1E8D9F79003B6DA4 /* GRDB.framework */ = {
56606D142355931F00185962 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 56B0364C1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D132355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0364F1E8D9F79003B6DA4 /* GRDBiOSTests.xctest */ = {
56606D162355931F00185962 /* GRDBiOSTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBiOSTests.xctest;
remoteRef = 56B0364E1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D152355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56B0365B1E8D9F79003B6DA4 /* GRDB.framework */ = {
56606D182355931F00185962 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 56B0365A1E8D9F79003B6DA4 /* PBXContainerItemProxy */;
remoteRef = 56606D172355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56606D1A2355931F00185962 /* GRDB.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GRDB.framework;
remoteRef = 56606D192355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
56606D1C2355931F00185962 /* GRDBtvOSTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = GRDBtvOSTests.xctest;
remoteRef = 56606D1B2355931F00185962 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
56185BEE25B80B8900B9C30F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
568E5FBD1E926430002582E0 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -499,6 +585,15 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
56185BEC25B80B8900B9C30F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56185C0725B80CEC00B9C30F /* PlayerTests.swift in Sources */,
56185BF325B80B8900B9C30F /* AppDatabaseTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
568E5FC71E926430002582E0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -512,10 +607,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
56FE6F2624A90CE400711EDF /* SceneDelegate.swift in Sources */,
56B0361C1E8D9F38003B6DA4 /* Player.swift in Sources */,
56B0361B1E8D9F38003B6DA4 /* AppDatabase.swift in Sources */,
56185BBF25B8036100B9C30F /* Persistence.swift in Sources */,
56B036071E8D9EBE003B6DA4 /* AppDelegate.swift in Sources */,
56B036241E8D9F4C003B6DA4 /* PlayersViewController.swift in Sources */,
56B036241E8D9F4C003B6DA4 /* PlayerListViewController.swift in Sources */,
56B036231E8D9F4C003B6DA4 /* PlayerEditionViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -523,6 +620,21 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
56185BF625B80B8900B9C30F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 56B036021E8D9EBE003B6DA4 /* GRDBDemoiOS */;
targetProxy = 56185BF525B80B8900B9C30F /* PBXContainerItemProxy */;
};
56606D1E2355937900185962 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBiOS;
targetProxy = 56606D1D2355937900185962 /* PBXContainerItemProxy */;
};
56606D23235593A300185962 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBWatchOS;
targetProxy = 56606D22235593A300185962 /* PBXContainerItemProxy */;
};
568E5FCE1E926430002582E0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 568E5FCA1E926430002582E0 /* GRDBDemoWatchOS Extension */;
@@ -533,26 +645,6 @@
target = 568E5FBE1E926430002582E0 /* GRDBDemoWatchOS */;
targetProxy = 568E5FD71E926430002582E0 /* PBXContainerItemProxy */;
};
568E5FE31E926535002582E0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBWatchOS;
targetProxy = 568E5FE21E926535002582E0 /* PBXContainerItemProxy */;
};
568E5FE71E926547002582E0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBWatchOS;
targetProxy = 568E5FE61E926547002582E0 /* PBXContainerItemProxy */;
};
56B0365D1E8D9F8F003B6DA4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBiOS;
targetProxy = 56B0365C1E8D9F8F003B6DA4 /* PBXContainerItemProxy */;
};
56B036611E8D9FB1003B6DA4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBiOS;
targetProxy = 56B036601E8D9FB1003B6DA4 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -583,6 +675,51 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
56185BF725B80B8900B9C30F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = AMD8W895CT;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = GRDBDemoiOSTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOSTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBDemoiOS.app/GRDBDemoiOS";
};
name = Debug;
};
56185BF825B80B8900B9C30F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = AMD8W895CT;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = GRDBDemoiOSTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOSTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBDemoiOS.app/GRDBDemoiOS";
};
name = Release;
};
568E5FDB1E926430002582E0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -591,12 +728,11 @@
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2.watchkitapp.watchkitextension;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.2;
};
name = Debug;
};
@@ -608,12 +744,11 @@
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2.watchkitapp.watchkitextension;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.2;
};
name = Release;
};
@@ -626,12 +761,11 @@
DEVELOPMENT_TEAM = AMD8W895CT;
IBSC_MODULE = GRDBDemoWatchOS_Extension;
INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2.watchkitapp;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.2;
};
name = Debug;
};
@@ -644,12 +778,11 @@
DEVELOPMENT_TEAM = AMD8W895CT;
IBSC_MODULE = GRDBDemoWatchOS_Extension;
INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2.watchkitapp;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.2;
};
name = Release;
};
@@ -679,6 +812,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -703,12 +837,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
};
@@ -738,6 +874,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -756,11 +893,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
};
@@ -773,7 +912,7 @@
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = GRDBDemoiOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -787,7 +926,7 @@
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = GRDBDemoiOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS2;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -795,6 +934,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56185BFF25B80B8900B9C30F /* Build configuration list for PBXNativeTarget "GRDBDemoiOSTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56185BF725B80B8900B9C30F /* Debug */,
56185BF825B80B8900B9C30F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
568E5FDA1E926430002582E0 /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS Extension" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -56,18 +56,17 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56185BEF25B80B8900B9C30F"
BuildableName = "GRDBDemoiOSTests.xctest"
BlueprintName = "GRDBDemoiOSTests"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@@ -79,10 +78,8 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -90,18 +87,7 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -109,10 +95,8 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -120,16 +104,7 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -28,21 +28,20 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56185BEF25B80B8900B9C30F"
BuildableName = "GRDBDemoiOSTests.xctest"
BlueprintName = "GRDBDemoiOSTests"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
@@ -61,8 +60,6 @@
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -0,0 +1,154 @@
import GRDB
/// AppDatabase lets the application access the database.
///
/// It applies the pratices recommended at
/// https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
final class AppDatabase {
/// Creates an `AppDatabase`, and make sure the database schema is ready.
init(_ dbWriter: DatabaseWriter) throws {
self.dbWriter = dbWriter
try migrator.migrate(dbWriter)
}
/// Provides access to the database.
///
/// Application can use a `DatabasePool`, and tests can use a fast
/// in-memory `DatabaseQueue`.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
private let dbWriter: DatabaseWriter
/// The DatabaseMigrator that defines the database schema.
///
/// See https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md
private var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
#if DEBUG
// Speed up development by nuking the database when migrations change
// See https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md#the-erasedatabaseonschemachange-option
migrator.eraseDatabaseOnSchemaChange = true
#endif
migrator.registerMigration("createPlayer") { db in
// Create a table
// See https://github.com/groue/GRDB.swift#create-tables
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
}
}
// Migrations for future application versions will be inserted here:
// migrator.registerMigration(...) { db in
// ...
// }
return migrator
}
}
// MARK: - Database Access: Writes
extension AppDatabase {
/// Saves (inserts or updates) a player. When the method returns, the
/// player is present in the database, and its id is not nil.
func savePlayer(_ player: inout Player) throws {
try dbWriter.write { db in
try player.save(db)
}
}
/// Delete the specified players
func deletePlayers(ids: [Int64]) throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db, keys: ids)
}
}
/// Delete all players
func deleteAllPlayers() throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db)
}
}
/// Refresh all players (by performing some random changes, for demo purpose).
func refreshPlayers() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
// When database is empty, insert new random players
try createRandomPlayers(db)
} else {
// Insert a player
if Bool.random() {
var player = Player.newRandom()
try player.insert(db)
}
// Delete a random player
if Bool.random() {
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
}
// Update some players
for var player in try Player.fetchAll(db) where Bool.random() {
try player.updateChanges(db) {
$0.score = Player.randomScore()
}
}
}
}
}
/// Create random players if the database is empty.
func createRandomPlayersIfEmpty() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
try createRandomPlayers(db)
}
}
}
/// Support for `createRandomPlayersIfEmpty()` and `refreshPlayers()`.
private func createRandomPlayers(_ db: Database) throws {
for _ in 0..<8 {
var player = Player.newRandom()
try player.insert(db)
}
}
}
// MARK: - Database Access: Reads
extension AppDatabase {
/// Tracks changes in players ordered by name
func observePlayersOrderedByName(
onError: @escaping (Error) -> Void,
onChange: @escaping ([Player]) -> Void)
-> DatabaseCancellable
{
ValueObservation
.tracking(Player.all().orderedByName().fetchAll)
.start(
in: dbWriter,
onError: onError,
onChange: onChange)
}
/// Tracks changes in players ordered by score
func observePlayersOrderedByScore(
onError: @escaping (Error) -> Void,
onChange: @escaping ([Player]) -> Void)
-> DatabaseCancellable
{
ValueObservation
.tracking(Player.all().orderedByScore().fetchAll)
.start(
in: dbWriter,
onError: onError,
onChange: onChange)
}
}
@@ -0,0 +1,22 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -0,0 +1,43 @@
import GRDB
extension AppDatabase {
/// The database for the application
static let shared = makeShared()
private static func makeShared() -> AppDatabase {
do {
// Create a folder for storing the SQLite database, as well as
// the various temporary files created during normal database
// operations (https://sqlite.org/tempfiles.html).
let fileManager = FileManager()
let folderURL = try fileManager
.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("database", isDirectory: true)
try fileManager.createDirectory(at: folderURL, withIntermediateDirectories: true)
// Connect to a database on disk
// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
let dbURL = folderURL.appendingPathComponent("db.sqlite")
let dbPool = try DatabasePool(path: dbURL.path)
// Create the AppDatabase
let appDatabase = try AppDatabase(dbPool)
// Populate the database if it is empty, for better demo purpose.
try appDatabase.createRandomPlayersIfEmpty()
return appDatabase
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate.
//
// Typical reasons for an error here include:
// * The parent directory cannot be created, or disallows writing.
// * The database is not accessible, due to permissions or data protection when the device is locked.
// * The device is out of space.
// * The database could not be migrated to its latest schema version.
// Check the error message to determine what the actual problem was.
fatalError("Unresolved error \(error)")
}
}
}
@@ -0,0 +1,104 @@
import GRDB
/// The Player struct.
///
/// Hashable conformance supports table view updates
struct Player: Hashable {
/// The player id.
///
/// Int64 is the recommended type for auto-incremented database ids.
/// Use nil for players that are not inserted yet in the database.
var id: Int64?
var name: String
var score: Int
}
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é"]
/// Creates a new player with empty name and zero score
static func new() -> Player {
Player(id: nil, name: "", score: 0)
}
/// Creates a new player with random name and random score
static func newRandom() -> Player {
Player(id: nil, name: randomName(), score: randomScore())
}
/// Returns a random name
static func randomName() -> String {
names.randomElement()!
}
/// Returns a random score
static func randomScore() -> Int {
10 * Int.random(in: 0...100)
}
}
// MARK: - Persistence
/// Make Player a Codable Record.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#records
extension Player: Codable, FetchableRecord, MutablePersistableRecord {
// Define database columns from CodingKeys
fileprivate enum Columns {
static let name = Column(CodingKeys.name)
static let score = Column(CodingKeys.score)
}
/// Updates a player id after it has been inserted in the database.
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
// MARK: - Player Database Requests
/// Define some player requests used by the application.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#requests
/// See https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
extension DerivableRequest where RowDecoder == Player {
/// A request of players ordered by name.
///
/// For example:
///
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByName().fetchAll(db)
/// }
func orderedByName() -> Self {
// Sort by name in a localized case insensitive fashion
// See https://github.com/groue/GRDB.swift/blob/master/README.md#string-comparison
order(Player.Columns.name.collating(.localizedCaseInsensitiveCompare))
}
/// A request of players ordered by score.
///
/// For example:
///
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByScore().fetchAll(db)
/// }
/// let bestPlayer: Player? = try dbWriter.read { db in
/// try Player.all().orderedByScore().fetchOne(db)
/// }
func orderedByScore() -> Self {
// Sort by descending score, and then by name, in a
// localized case insensitive fashion
// See https://github.com/groue/GRDB.swift/blob/master/README.md#string-comparison
order(
Player.Columns.score.desc,
Player.Columns.name.collating(.localizedCaseInsensitiveCompare))
}
}
@@ -0,0 +1,116 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "icon_20pt@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "icon_20pt@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "icon_29pt@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "icon_29pt@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon_40pt@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon_40pt@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "icon_60pt@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "icon_60pt@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "icon_20pt.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "icon_20pt@2x-1.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon_29pt.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon_29pt@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon_40pt.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon_40pt@2x-1.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon_76pt.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon_76pt@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "icon_83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Loaded 100 of 631 files, more files were not shown because too many files have changed in this diff. Show more