Compare commits

...
980 Commits
Author SHA1 Message Date
Gwendal Roué f3992a034d Merge branch 'development' 2022-03-26 11:52:33 +01:00
Gwendal Roué 8b120fa9b6 v5.22.1 2022-03-26 11:52:17 +01:00
Gwendal Roué 8b58ec4cee Merge branch 'dev/issue1194' into development 2022-03-26 11:46:03 +01:00
Gwendal Roué 9b7b603a69 Documentation 2022-03-26 11:44:33 +01:00
Gwendal Roué a3a26bf88f Fix #1194 2022-03-26 11:43:44 +01:00
Gwendal Roué 770484b78d Failing test for #1194 2022-03-26 11:33:10 +01:00
Gwendal Roué fafa74c246 Fix ValueObservation.publisher documentation 2022-03-22 19:24:06 +01:00
Gwendal Roué 62450b5817 Bump performance comparison dependencies 2022-03-22 18:00:21 +01:00
Gwendal Roué e9b8df68ee Merge branch 'development' 2022-03-22 17:38:18 +01:00
Gwendal Roué 9fa831b6bb v5.22.0 2022-03-22 16:41:40 +01:00
Gwendal Roué 43e1871005 Fix for Xcode 12.4 2022-03-22 13:46:09 +01:00
Gwendal Roué 8a6e784428 Fix for Xcode 12.5.1
Without this change, the compiler would crash with Abort trap: 6
2022-03-22 09:26:12 +01:00
Gwendal Roué 727ca68b98 CHANGELOG 2022-03-22 08:36:24 +01:00
Gwendal Roué fb3e08aba8 Merge pull request #1186 from benrb/databaseerror-message
DatabaseError provide error message as localizedFailureReason
2022-03-22 08:26:14 +01:00
Ben Barnett 1c614e8de6 Test localizedFailureReason is not nil
-localizedFailureReason can be nil in some cases, but not in the one we are testing here
2022-03-20 08:23:35 +00:00
Ben Barnett 3f0a8e6730 Provide error message as a failure reason 2022-03-20 08:07:39 +00:00
Gwendal Roué 6916a8feca #1183 cleanup 2022-03-18 03:36:20 +01:00
Gwendal Roué e08dfdb0bf Merge pull request #1183 from groue/dev/strong-observation
Starting a ValueObservation keeps a strong reference on the database connection.
2022-03-17 19:17:03 +01:00
Gwendal Roué 6236b8a068 Move Headers build phase before Compile Sources
This prevents a build error when running tests with Xcode 13.3:

error: Cycle inside GRDBiOS; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
2022-03-17 18:50:11 +01:00
Gwendal Roué 55dea6f9d2 Makefile: support for Xcode 13.3 2022-03-17 18:44:30 +01:00
Gwendal Roué cdb08988f4 CHANGELOG 2022-03-17 18:44:30 +01:00
Gwendal Roué 881bbd3f0d Update documentation 2022-03-17 18:44:30 +01:00
Gwendal Roué 6ab3fea8fb Refactor ValueObservation 2022-03-17 18:44:30 +01:00
Gwendal Roué 287ceb8b07 Documentation & cleanup 2022-03-17 18:44:30 +01:00
Gwendal Roué 4eefb9afbe Merge pull request #1184 from GetToSet/ethanwong/update-row-adapter-doc
Update RowAdapter doc to cover all concrete adapters.
2022-03-17 18:05:09 +01:00
Ethan Wong 4ea04ec978 Update RowAdapter doc to cover all concrete adapters. 2022-03-18 00:59:16 +08:00
Gwendal Roué c30b49117b If a scope is found, there is no point searching for prefetched rows 2022-03-04 12:04:02 +01:00
Gwendal Roué ec975819b7 Fix for container.decodeNil(forKey:) in the context of including(all:) 2022-03-04 11:55:53 +01:00
Gwendal Roué b974dfa9a7 Use fetchSet when available 2022-03-04 11:40:42 +01:00
Gwendal Roué e19f21be99 TODO 2022-03-04 10:28:23 +01:00
Gwendal Roué 9b0e41ad58 Details about date formats 2022-02-13 12:27:27 +01:00
Gwendal Roué d40474d2b7 Merge branch 'development' 2022-02-06 12:14:25 +01:00
Gwendal Roué 685074932e v5.21.0 2022-02-06 12:14:05 +01:00
Gwendal Roué f1a23bacc0 Extend the thank you notice 2022-02-06 12:10:35 +01:00
Gwendal Roué fbef103f01 CHANGELOG 2022-02-06 12:09:27 +01:00
Gwendal Roué fc9f0bcad1 Wording 2022-02-06 10:20:06 +01:00
Gwendal Roué 1929e96d11 Merge pull request #1165 from BeehiveInnovations/development
Add dynamic library to products to support dynamic linking
2022-02-06 10:13:31 +01:00
Gwendal Roué 9d4eb8a6dd test_install_SPM_Dynamic_Project: use a destination
Otherwise `make test_install_SPM_Dynamic_Project` uses a default destination, which CAN be the current mac, and thus require code signing:

% make test_install_SPM_Dynamic_Project
...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], ... }
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
...
❌  error: Signing for "ios-dynamic" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'ios-dynamic' from project 'ios-dynamic')
** BUILD FAILED **
2022-02-06 10:00:58 +01:00
Fahad 3914a9ec21 Updated Makefile. Updated code-signing team 2022-02-06 01:25:34 +04:00
Fahad 29bacc138c Replaced test project with iOS project 2022-02-06 01:14:19 +04:00
Beehive InnovationsandGwendal Roué ba866359b2 Update README.md
Co-authored-by: Gwendal Roué <gr@pierlis.com>
2022-02-03 23:11:54 +04:00
Beehive InnovationsandGwendal Roué ffced55d3c Update README.md
Co-authored-by: Gwendal Roué <gr@pierlis.com>
2022-02-03 22:52:10 +04:00
Beehive Innovations 74caa96dcb Undo and use automatic
More clarity on this now - helps compile optimize and skip producing a `.a` static library entirely.
2022-02-03 22:13:12 +04:00
Beehive Innovations f6bea21e80 The first target should explicitly say static
Otherwise the behavior is undefined since omitting the type may at some point in time cause Xcode to pull it in as dynamic (when they fix their dependency resolution).
2022-02-03 21:44:06 +04:00
Fahad 27f6125099 Dynamic library test added 2022-02-03 13:36:52 +04:00
Beehive Innovations 70ea2027e4 Renamed dynamic library name
In line with naming standard used by other libraries
2022-02-03 13:11:24 +04:00
Beehive Innovations e28658c574 Updated SPM installation instructions
Added note about static / dynamic
2022-02-03 13:09:52 +04:00
fahad@guidedways.com c184b76849 Add dynamic library to products to allows dynamic linking 2022-02-03 09:25:42 +04:00
Gwendal Roué d23d74f65f Merge pull request #1164 from groue/dev/migrator-is-not-concurrent
Drop async apis from DatabaseMigrator
2022-02-01 18:17:02 +01:00
Gwendal Roué 984a5b4c4c CHANGELOG 2022-02-01 16:55:05 +01:00
Gwendal Roué 8e84beee36 Fix Swift 5.6 warnings 2022-02-01 10:08:24 +01:00
Gwendal Roué 95ce4a3f8a Drop async apis from DatabaseMigrator
This is because DatabaseMigrator can't be Sendable as long as it runs migrations that embed non-@Sendable closures.
2022-02-01 09:53:20 +01:00
Gwendal Roué 98ca653c6a Merge branch 'development' 2022-02-01 09:07:15 +01:00
Gwendal Roué e5a8e130d7 v5.20.0 2022-02-01 07:44:09 +01:00
Gwendal Roué 72e8dd2816 Cleanup 2022-01-31 20:20:02 +01:00
Gwendal Roué b5338650db Bump performance comparison dependencies 2022-01-31 19:23:55 +01:00
Gwendal Roué 75f72472ff Cleanup 2022-01-31 08:37:57 +01:00
Gwendal Roué 09f7d4d952 Complete #1161 2022-01-30 15:27:11 +01:00
Gwendal Roué c1c3cf6605 Merge pull request #1162 from groue/dev/fix-truncate-optimization
Fix truncate optimization handling
2022-01-30 15:26:14 +01:00
Gwendal Roué fc7f24ef6e Test case insensitivity of truncation optimization prevention 2022-01-30 14:57:37 +01:00
Gwendal Roué 3d0b34590f Fix typo 2022-01-30 14:49:31 +01:00
Gwendal Roué 2d6c2873e0 CHANGELOG 2022-01-30 14:42:22 +01:00
Gwendal Roué 4e65425c00 Cleanup 2022-01-30 14:41:29 +01:00
Gwendal Roué b82f92f726 Test for cursor next() followed by forEach() 2022-01-30 14:33:22 +01:00
Gwendal Roué b8c0e9d2c2 Fix failing test for cached statement which does not prevent the truncate optimization 2022-01-30 14:24:28 +01:00
Gwendal Roué b2df255306 Failing test for cached statement which does not prevent the truncate optimization 2022-01-30 14:12:46 +01:00
Gwendal Roué c60b8cfc53 Refactor prevention of truncate optimization
We now always use the same authorizer, which is always ready to prevent truncate optimization depending on the current transaction observers.
2022-01-30 14:07:43 +01:00
Gwendal Roué 9dc6fbd7f9 Fix #1159 2022-01-30 12:27:19 +01:00
Gwendal Roué 9a4e1f7806 Merge pull request #1161 from groue/dev/write-target-queue
Target DispatchQueue for non-read-only database connections
2022-01-30 12:07:25 +01:00
Gwendal Roué 5dde1409ad CHANGELOG 2022-01-29 17:54:33 +01:00
Gwendal Roué 936fd3ed5f Test that DatabaseMigrator.eraseDatabaseOnSchemaChange does not deadlock on Configuration.writeTargetQueue 2022-01-29 17:47:30 +01:00
Gwendal Roué ed4471c5b9 Configuration.writeTargetQueue 2022-01-29 17:45:21 +01:00
Gwendal Roué dd025a14e4 Merge pull request #1160 from groue/dev/privacy
Hide statement arguments by default
2022-01-29 16:29:58 +01:00
Gwendal Roué 29808e51ff Fix typo 2022-01-29 16:06:22 +01:00
Gwendal Roué 426044154c Fix public statement arguments for system SQLite 2022-01-29 15:54:39 +01:00
Gwendal Roué d69db0b9a1 CHANGELOG 2022-01-29 15:32:21 +01:00
Gwendal Roué 914bd14cd1 CHANGELOG 2022-01-29 15:27:44 +01:00
Gwendal Roué b5395a097c Documentation 2022-01-29 15:27:40 +01:00
Gwendal Roué 99c596f778 Fix DatabaseError public initializer 2022-01-29 15:21:44 +01:00
Gwendal Roué fd22fac5c0 Don't shed too much light on expandedSQL & expandedDescription properties 2022-01-29 15:12:41 +01:00
Gwendal Roué 6e3a15ebed Statement.description no longer contains statement arguments 2022-01-29 14:57:18 +01:00
Gwendal Roué bb8b39f7fd Documentation for public statement arguments 2022-01-29 14:54:47 +01:00
Gwendal Roué fc5138ae91 Configuration.publicStatementArguments
This flags allows database errors and trace events to hide or show statement arguments by default.
2022-01-28 13:57:12 +01:00
Gwendal Roué d3985c7ebf TraceEvent.description no longer contains statement arguments
Use TraceEvent.expandedDescription in order to see statements arguments
2022-01-27 19:30:00 +01:00
Gwendal Roué 9f0ba49c93 DatabaseError.description no longer contains statement arguments
Use DatabaseError.expandedDescription in order to see statements arguments
2022-01-27 19:30:00 +01:00
Gwendal Roué 09922c34ff Code formatting 2022-01-23 12:24:34 +01:00
Gwendal Roué 3826003d93 TODO 2022-01-23 10:51:15 +01:00
Gwendal Roué 9baa72cfd7 Mention association annotation methods in the main README 2022-01-21 13:48:51 +01:00
Gwendal Roué aacc69f485 Fix typos 2022-01-21 13:43:44 +01:00
Gwendal Roué 301fb34702 Fix failing test for including(all:) on limited request and composite primary keys 2022-01-21 13:42:42 +01:00
Gwendal Roué 6444285ee2 Failing test for including(all:) on limited request and composite primary keys 2022-01-21 13:39:40 +01:00
Gwendal Roué bd42dc69f0 CHANGELOG 2022-01-19 19:27:50 +01:00
Gwendal Roué 14d8763a84 Merge branch 'development' 2022-01-19 16:20:21 +01:00
Gwendal Roué c46e8257d8 v5.19.0 2022-01-19 16:18:59 +01:00
Gwendal Roué 948c7870bd Merge pull request #1151 from freak4pc/fk-docs
Fix documentation for foreignKeysEnabled
2022-01-19 15:50:16 +01:00
Shai MishaliandGwendal Roué fa896eee23 Update GRDB/Core/Configuration.swift
Co-authored-by: Gwendal Roué <gr@pierlis.com>
2022-01-19 16:46:55 +02:00
Shai Mishali c4023ccf0a Fix documentation for foreignKeysEnabled 2022-01-19 15:48:11 +02:00
Gwendal Roué fe92b93f0b CHANGELOG 2022-01-19 08:15:19 +01:00
Gwendal Roué 28109a3947 Merge pull request #1144 from TimAEllis/feature/add-drop-column
Add drop column support
2022-01-19 08:06:24 +01:00
Gwendal Roué 124cba1b21 Work around missing SQLITE_ALTER_TABLE action 2022-01-19 07:29:16 +01:00
Gwendal Roué ca47426c61 Merge pull request #1149 from BB9z/fix-typos
Fix typos
2022-01-19 06:31:12 +01:00
Gwendal Roué 90c85c6703 TODO 2022-01-19 06:25:33 +01:00
BB9z 6d3f309cad Fix typos 2022-01-19 00:10:42 +08:00
Gwendal Roué 06dbaba7cc Add failing test for schema cache invalidation 2022-01-18 08:50:42 +01:00
Timothy Ellis daf44d9baa Exposed drop(column:) to custom builds and cipher 2022-01-18 10:11:12 +11:00
Timothy Ellis 187a661626 Updated to reflect drop column 2022-01-17 10:31:11 +11:00
Timothy Ellis 55302cb937 Added test for drop column 2022-01-17 10:02:23 +11:00
Timothy Ellis 869d776962 Added drop column support 2022-01-17 10:02:04 +11:00
Gwendal Roué b53b43b1fc Cleanup 2022-01-16 14:50:55 +01:00
Gwendal Roué 42d29b305e Cleanup 2022-01-16 13:54:03 +01:00
Gwendal Roué 8f100a6395 Document that GRDB/SQLCipher must be the only pod
Addresses #1141
2022-01-16 10:49:02 +01:00
Gwendal Roué 44dd21690f Merge pull request #1139 from groue/dev/more-1124
Deal with authorization callbacks from more cursors
2022-01-14 18:43:13 +01:00
Gwendal Roué 6d31190c3f DatabaseCursor.forEach() honors the _isDone flag 2022-01-14 18:31:16 +01:00
Gwendal Roué 549f7ec66e Cleanup and cursor profiling tests 2022-01-14 18:25:30 +01:00
Gwendal Roué 3eea2967b3 Improve error message 2022-01-14 17:49:17 +01:00
Gwendal Roué 8e6827070f Improve documentation 2022-01-14 13:47:54 +01:00
Gwendal Roué d105b35750 More #1124-related documentation 2022-01-14 13:29:34 +01:00
Gwendal Roué 149d5ac151 Fix GRDBProfiling 2022-01-14 13:13:34 +01:00
Gwendal Roué ed6c5438b9 Move DatabaseCursor state to Statement 2022-01-14 13:13:34 +01:00
Gwendal Roué bd67153095 Fix #1124 for more cursors 2022-01-13 14:28:04 +01:00
Gwendal Roué 3fff6b2f51 Fix typo 2022-01-13 07:29:38 +01:00
Gwendal Roué 62a0b1c148 Fix typo 2022-01-09 19:03:31 +01:00
Gwendal Roué dfca044433 Merge branch 'development' 2022-01-09 18:56:04 +01:00
Gwendal Roué 78df734f51 v5.18.0 2022-01-09 17:36:31 +01:00
Gwendal Roué e72b7e4597 Merge pull request #1133 from groue/dev/strict-tables
Support for STRICT tables
2022-01-09 17:22:50 +01:00
Gwendal Roué fb6c695658 CHANGELOG 2022-01-09 17:12:17 +01:00
Gwendal Roué a1c0c6d1f3 Update documentation for the new table/index creation options 2022-01-09 17:01:37 +01:00
Gwendal Roué 68f3e5586b Test strict tables, and table/index creation options 2022-01-09 17:01:37 +01:00
Gwendal Roué 8760033045 Update the list of extended result codes from SQLite 3.37.2
This updated list contains SQLITE_CONSTRAINT_DATATYPE, introduced with strict tables.
2022-01-09 17:01:37 +01:00
Gwendal Roué b2fabf5fc3 Strict tables need REAL and ANY column types 2022-01-09 17:01:37 +01:00
Gwendal Roué 95f1d83d78 The .strict table creation option
The .strict table creation option

The .strict table creation option
2022-01-09 17:01:37 +01:00
Gwendal Roué 790c054a28 Fix Swiftlint warnings 2022-01-09 14:43:27 +01:00
Gwendal Roué 06a5d6f44b Merge pull request #1132 from groue/dev/sqlite-3.72.2
Bump custom SQLite builds v3.72.2
2022-01-09 14:42:28 +01:00
Gwendal Roué 3145a916a0 CHANGELOG 2022-01-09 14:33:33 +01:00
Gwendal Roué 94ff9f3e45 The casing of ColumnInfo.type depends on the SQLite version 2022-01-09 14:28:00 +01:00
Gwendal Roué c172dac909 Update test for SQLite to v3.37.2 2022-01-09 14:21:51 +01:00
Gwendal Roué 5b7ba122e8 Bump custom SQLite to v3.37.2 2022-01-09 14:06:27 +01:00
Gwendal Roué 0513e0acf8 Enhance wording in the pull request template 2022-01-09 13:42:22 +01:00
Gwendal Roué b3d49de023 Mention CONTRIBUTING in the pull request template 2022-01-09 13:41:11 +01:00
Gwendal Roué 779e2c202f Merge pull request #1128 from groue/dev/issue-1124
Deal with authorization callbacks from cursors of FetchableRecord
2022-01-09 13:38:20 +01:00
Gwendal Roué be45781cf9 CHANGELOG 2022-01-09 13:31:03 +01:00
Gwendal Roué c7d816b860 Merge branch 'development' into dev/issue-1124 2022-01-09 13:27:54 +01:00
Gwendal Roué a0f6f7a9ab Merge pull request #1129 from groue/dev/detached-column
Detached columns
2022-01-09 13:27:04 +01:00
Gwendal Roué 86c0180487 CHANGELOG 2022-01-09 13:17:29 +01:00
Gwendal Roué 80c11d0bc4 Merge branch 'development' into dev/detached-column 2022-01-09 13:13:31 +01:00
Gwendal Roué 66602ba2e2 CHANGELOG 2022-01-09 13:13:11 +01:00
Gwendal Roué 8fdcc020e0 Documentation 2022-01-08 14:09:14 +01:00
Gwendal Roué 1bb2029e74 Fix #1124 by dealing with authorizers 2022-01-08 13:51:41 +01:00
Gwendal Roué fc0e1bede1 Methods that fully consume a cursor prefer forEach to next
This allows custom forEach implementations to wrap the full consumption of a cursor
2022-01-08 13:50:14 +01:00
Gwendal Roué 823af1944e Cursor.forEach is a customization point 2022-01-08 13:47:54 +01:00
Gwendal Roué 2093b477df Failing test for #1124 2022-01-08 13:18:32 +01:00
Gwendal Roué 29cd08cba4 Fix typo 2022-01-07 15:01:29 +01:00
Gwendal Roué 76523db5b9 Removed undesired :nodoc: comment 2022-01-07 14:58:42 +01:00
Gwendal Roué c0305853bc Enhance fatal error message for reversed literal ordering terms 2022-01-07 14:43:57 +01:00
Gwendal Roué 5d51f2a884 New Embedding SQL in Query Interface Requests chapter 2022-01-07 14:41:15 +01:00
Gwendal Roué bdf54e80a9 Mention detached columns in the documentation of expression.forKey(_:) 2022-01-07 13:30:27 +01:00
Gwendal Roué e799c8534e ColumnExpression.detached 2022-01-07 10:07:15 +01:00
Gwendal Roué 536ad2ebff Merge branch 'master' into development 2022-01-07 10:06:42 +01:00
Gwendal Roué 972f45295f Request make smokeTest to pass before submitting a pull request. 2022-01-07 10:06:21 +01:00
Gwendal Roué b96bd52c38 Merge branch 'dev/issue-1074-incremental_backup_api' into development 2022-01-06 18:36:31 +01:00
Gwendal Roué 2af0a74676 Fix SQLCipher 3 and 4 test projects 2022-01-06 14:13:25 +01:00
Gwendal Roué 4aa37f6169 Expert users need raw access to expert values 2022-01-06 13:52:09 +01:00
Gwendal Roué 37571525e6 Merge branch 'development' into dev/issue-1074-incremental_backup_api 2022-01-06 13:45:26 +01:00
Gwendal Roué 911b2a76d8 Merge pull request #1121 from byohay/feature/fix-variables-with-spaces
GRDB: quote PROJECT_DIR and SRCROOT environment variables.
2021-12-31 14:32:29 +01:00
Gwendal Roué 54b13de632 Merge pull request #1120 from jnross/joe/fix-typo
Fix typos of the word "default"
2021-12-31 13:56:56 +01:00
Ben Yohay 4a3232199f GRDB: quote PROJECT_DIR and SRCROOT environment variables.
Using those variables without quoting will yield unexpected results if
they contain spaces.
2021-12-29 14:40:56 +02:00
Joseph Ross bf28abbb25 Fix typos of the word "default" 2021-12-28 14:49:33 -08:00
Gwendal Roué c945504a34 Addition and substraction are not bijective functions (due to floating point rounding errors) 2021-12-21 11:13:28 +01:00
Gwendal Roué 8217966215 Table creation methods accept throwing closures 2021-12-21 09:26:55 +01:00
Gwendal Roué c96a74658c TODO 2021-12-19 12:34:16 +01:00
Gwendal Roué 042e220f49 Rewrite CONTRIBUTING.md 2021-12-18 14:31:02 +01:00
Michael Allman a71639159b Add DatabaseBackupProgress and update the documentation 2021-12-15 01:52:25 -05:00
Gwendal Roué d633927999 Merge branch 'development' 2021-12-14 19:33:32 +01:00
Gwendal Roué 8df7020ad7 v5.17.0 2021-12-14 19:32:51 +01:00
Gwendal Roué bc95c5c977 Performance tests: upgrade dependencies 2021-12-14 19:15:59 +01:00
Gwendal Roué ef4709d3f0 Fix async vaccum(info:) tests by using the same encryption level for the destination database 2021-12-14 14:21:16 +01:00
Gwendal Roué e1984721dc Merge pull request #1079 from groue/dev/async
Async / Await
2021-12-14 13:29:02 +01:00
Gwendal Roué 469898c5df CHANGELOG 2021-12-14 13:15:22 +01:00
Gwendal Roué 0207aef4dc CHANGELOG 2021-12-14 12:48:48 +01:00
Gwendal Roué d7604d2174 Merge branch 'development' into dev/async 2021-12-14 12:46:49 +01:00
Gwendal Roué 89421c92fb More support for inclusion checks with explicit collation
This commit addresses https://github.com/groue/GRDB.swift/issues/1094

The position of the `collating` method is now irrelevant in all those cases:

// name COLLATE NOCASE IN ('foo', 'bar')
["foo", "bar"].contains(Column("name")).collating(.nocase)
["foo", "bar"].contains(Column("name").collating(.nocase))

// name BETWEEN 'foo' AND 'bar' COLLATE NOCASE
("foo"..."bar").contains(Column("name")).collating(.nocase)
("foo"..."bar").contains(Column("name").collating(.nocase))

// (name >= 'foo' COLLATE NOCASE) AND (name < 'bar' COLLATE NOCASE)
("foo"..<"bar").contains(Column("name")).collating(.nocase)
("foo"..<"bar").contains(Column("name").collating(.nocase))
2021-12-14 12:45:50 +01:00
Gwendal Roué 0cf4c4efba Merge branch 'development' into dev/async 2021-12-12 17:00:08 +01:00
Gwendal Roué 710142edc0 CHANGELOG 2021-12-12 16:44:43 +01:00
Gwendal Roué 7001b60cf7 More support for association existence check
New: support for associated tables WITHOUT ROWID with a compound primary key
New: support for associated views

Checking for the existence of associated CTEs is still not implemented (it fails with "table does not exist" error).
2021-12-12 16:43:40 +01:00
Gwendal Roué dcc2d211b2 Database.primaryKey() fails for views 2021-12-12 16:14:25 +01:00
Gwendal Roué 340203686d ValueObservation.removeDuplicates(by:) 2021-12-12 15:12:34 +01:00
Gwendal Roué ae609cec3b Support for the TOTAL SQL aggregate function 2021-12-12 14:46:43 +01:00
Gwendal Roué 8ba89a398a Add ABS and LENGTH SQL functions on association aggregates 2021-12-12 14:27:41 +01:00
Gwendal Roué 95b3f447e4 Revert "Make sure Inflections.default is lazily loaded, even in optimized release builds"
This reverts commit c62ccf1de7 (aimed at fixing #755).

We can do this because https://github.com/apple/swift/pull/30445 is present in the Swift 5.3 release https://github.com/apple/swift/releases/tag/swift-5.3-RELEASE
2021-12-12 13:57:34 +01:00
Gwendal Roué bc2a66e40f Don't throw any error when checking if a table is WITHOUT ROWID 2021-12-12 13:29:02 +01:00
Gwendal Roué cb32a0d0cc CHANGELOG 2021-12-12 12:56:53 +01:00
Gwendal Roué effc991de1 Deprecate DatabaseRegion.init(table:)
This commit reverts #510
2021-12-12 12:36:27 +01:00
Gwendal Roué 3049b88fea Merge pull request #1110 from maxhumber/patch-1
Minor changes to a tip in the README
2021-12-12 10:27:13 +01:00
Max Humber c39db96521 Minor changes to a tip in the README 2021-12-11 15:28:02 -05:00
Gwendal Roué d7514f84f1 Disable concurrency check flags by default 2021-12-10 12:40:08 +01:00
Gwendal Roué 1b62e06c4a Expose Sendable conformance to Swift 5.5
But async apis are still only exposed to Swift 5.5.2.

Sendable conformances are helpful for users of Xcode < 13.2.
2021-12-10 08:08:47 +01:00
Michael Allman bedf2dbcd4 Revise and correct some names and backup code documentation 2021-12-08 10:23:11 -08:00
Michael Allman 13e195db40 Revise incremental backup API to report progress via a throwing callback
function
2021-12-08 09:37:10 -08:00
Michael Allman 087ad10086 Add an API to track progress of and cancel backups in progress, for both
the DatabaseReader/DatabaseWriter API and Database API
2021-12-08 09:37:10 -08:00
Michael Allman f012c011b1 Import the Foundation framework in DatabaseReader.swift, which is required to get the Progress class 2021-12-08 09:37:10 -08:00
Michael Allman f829d46b7f Change default backup page step size from 5 to 100, which is the value used in the sqlite3 cli .backup command 2021-12-08 09:37:10 -08:00
Michael Allman ab6f18e46d Initial commit of code to implement progress-reporting database backups 2021-12-08 09:37:10 -08:00
Gwendal Roué 9579671c02 Remove a concurrency-related warning 2021-12-08 18:16:36 +01:00
Gwendal Roué 01f4c04c4d DatabaseReader is Sendable 2021-12-08 18:12:28 +01:00
Gwendal Roué 7ac78a8ec1 Share concurrency check flags with tests 2021-12-08 18:11:44 +01:00
Gwendal Roué 97e00ab44f Fix async test for SQLCipher VACUUM INTO 2021-12-08 13:18:12 +01:00
Gwendal Roué 33d9ca0e97 UIApplication notification names are isolated to @MainActor
I believe this is incorrect: FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor)

Meanwhile, just use the string version.

A workaround based on a MainActor-isolated task can't work due to conflict between compiler version and minimum iOS target:

    #if compiler(>=5.5) && canImport(_Concurrency)
    if #available(...) { // Check for availability of concurrency runtime
        Task { @MainActor [weak self] in
            NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
        }
    } else {
        // IMPOSSIBLE CASE: No access to Task, no access to notification names
    }
    #else
    NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
    #endif
2021-12-08 12:48:19 +01:00
Gwendal Roué b2985b77c4 Concurrency check flags depend on Xcode version
Xcode 12 won't accept those flags. And we only need them starting Xcode 13.2
2021-12-08 12:00:32 +01:00
Gwendal Roué ec882e8126 Enable concurrency check flags by default 2021-12-08 11:18:54 +01:00
Gwendal Roué 61b0df8017 Enable async APIs on Xcode 13.2+ only
Xcode 13.1 won't have access to async apis. This simplifies our availability checks.

The techniques were inspired from:

- https://github.com/swift-server/guides/blob/main/docs/concurrency-adoption-guidelines.md#api-design
- https://github.com/swift-server/guides/blob/main/docs/concurrency-adoption-guidelines.md#backwards-compatibility-of-declarations-and-checked-swift-concurrency
2021-12-08 11:17:40 +01:00
Gwendal Roué 103266d70c Merge branch 'development' into dev/async 2021-12-08 08:00:49 +01:00
Gwendal Roué 3f02724e60 RowDecodingError is Sendable
Xcode 13.2 RC won't compile unless we make a Sendable copy of the row that could not be decoded.
2021-12-08 07:59:43 +01:00
Gwendal Roué ca05a93c98 Merge pull request #1107 from tcwalther/tw-fix-db-create-index-docstring
Fix docstring for Database.create(index: ...)
2021-12-07 13:32:26 +01:00
Thomas Walther 48f6cee7a6 Fix docstring for Database.create(index: ...) 2021-12-07 13:20:14 +01:00
Gwendal Roué 8ed16f4440 Fix some compiler warnings with -Xfrontend -warn-concurrency
https://twitter.com/olebegemann/status/1467893554915782668
2021-12-07 09:23:37 +01:00
Gwendal Roué 6ec3ebc398 Merge branch 'development' into dev/async 2021-12-06 18:04:35 +01:00
Gwendal Roué 86d0fedfbb Fix wording 2021-12-05 17:08:15 +01:00
Gwendal Roué 0330365d49 Merge branch 'development' 2021-12-05 16:59:59 +01:00
Gwendal Roué ca2f36781e v5.16.0 2021-12-05 16:59:37 +01:00
Gwendal Roué 6c7f71f620 Fix typo 2021-12-05 16:47:32 +01:00
Gwendal Roué 60bf5d30b0 Merge pull request #1106 from groue/dev/annotated-with-association
Sugar for fetching only a few columns of associated records
2021-12-05 16:41:49 +01:00
Gwendal Roué 94caf4ba97 todo: find a way to prefix the selection with the association key 2021-12-05 15:53:59 +01:00
Gwendal Roué a7002e1e09 Enhance "Columns Selected by an Association" 2021-12-05 15:22:07 +01:00
Gwendal Roué 54a991b3b9 Emphasize sections 2021-12-05 15:15:38 +01:00
Gwendal Roué 54ca12437a CHANGELOG 2021-12-05 15:10:25 +01:00
Gwendal Roué 3298cca75f Rewrite the Joining And Prefetching Associated Records chapter 2021-12-05 15:10:25 +01:00
Gwendal Roué 4fe0b687d2 Documentation for annotated(withOptional:), annotated(withRequired:) 2021-12-05 15:04:51 +01:00
Gwendal Roué 9df0f4cdbd Inline documentation for annotated(withOptional:), annotated(withRequired:) 2021-12-05 15:04:44 +01:00
Gwendal Roué e1dc24ac93 Update examples with Team/Player 2021-12-04 10:01:31 +01:00
Gwendal Roué 88e60ed0c6 Update FAQ: How do I select only one column of an associated record? 2021-12-04 09:50:16 +01:00
Gwendal Roué b4ca103002 Tests for annotated(withOptional:), annotated(withRequired:) 2021-12-04 09:49:23 +01:00
Gwendal Roué 564c4cef5c annotated(withOptional:), annotated(withRequired:) 2021-12-03 19:24:56 +01:00
Gwendal Roué 7a77a1fd06 Merge branch 'development' 2021-12-02 19:43:04 +01:00
Gwendal Roué c7291db360 v5.15.0 2021-12-02 18:48:36 +01:00
Gwendal Roué a52d1b1d21 Merge pull request #1102 from groue/dev/ValueObservation-explicit-region-tracking
Explicit tracked region for ValueObservation
2021-12-02 18:40:40 +01:00
Gwendal Roué 89b1783220 TrackingMode is a property of ValueObservation
No reducer changes the tracking mode, so let's simplify the code.
2021-12-02 17:22:18 +01:00
Gwendal Roué 76d2168988 Extend the general description of ValueObservation behavior
Link to the ability to track something which is not the fetched region.
2021-12-02 17:22:18 +01:00
Gwendal Roué e419bb55ca Enhance documentation of DatabaseRegion 2021-12-02 17:22:18 +01:00
Gwendal Roué 06eb45db65 Documentation for ValueObservation(region:fetch:) 2021-12-02 17:22:18 +01:00
Gwendal Roué 6180e4b815 Fix for Swift 5.3 2021-12-02 17:22:18 +01:00
Gwendal Roué 85747935c8 ValueObservation can track an explicit database region 2021-12-02 17:22:18 +01:00
Gwendal Roué 36fba9a79a TODO: deprecate DatabaseRegion(table:)
We have `Table` now, wich is DatabaseRegionConvertible.

This deprecation will revert https://github.com/groue/GRDB.swift/pull/510
2021-12-02 17:21:58 +01:00
Gwendal Roué 6240585a03 Make sure ValueObservation fetches in an isolated transaction
Previously, ValueObservation could fetch in a non-isolated way. When an external connection would commit changes, we could fetch inconsistent values. Here we make sure ValueObservation always fetch in an isolated way.
2021-12-02 09:46:02 +01:00
Gwendal Roué ad66fbc666 ValueObserver documentation 2021-12-02 09:46:02 +01:00
Gwendal Roué e69092ca6a Add DatabaseRegionConvertible to Table 2021-12-02 09:45:38 +01:00
Gwendal Roué bb2ce74125 Add helper method Database.isolated(readOnly:) 2021-12-02 09:45:28 +01:00
Gwendal Roué 06bf3980b6 Fix documentation links 2021-12-02 09:17:36 +01:00
Gwendal Roué 97d4a60148 Merge branch 'development' into dev/async
# Conflicts:
#	Documentation/DemoApps/GRDBDemoiOS/README.md
#	Documentation/DemoApps/README.md
2021-11-27 12:05:24 +01:00
Gwendal Roué 6dc7367853 Merge branch 'development' 2021-11-25 18:29:23 +01:00
Gwendal Roué 4228df9c06 v5.14.0 2021-11-25 18:23:31 +01:00
Gwendal Roué ca9fd1f8e6 CHANGELOG 2021-11-25 18:18:15 +01:00
Gwendal Roué 1fbf2f8693 GRDBCombineDemo uses the GRDBQuery package 2021-11-25 17:26:19 +01:00
Gwendal Roué 811c41af6d @Query has been exported to https://github.com/groue/GRDBQuery 2021-11-25 15:25:40 +01:00
Gwendal Roué 5d87609f4b Ignore .swiftpm 2021-11-25 15:08:53 +01:00
Gwendal Roué a9036a4563 Ignore .swiftpm 2021-11-25 14:49:37 +01:00
Gwendal Roué 988c7bb62f Query documentation 2021-11-25 13:56:07 +01:00
Gwendal Roué 51182fc862 Query documentation 2021-11-25 13:55:00 +01:00
Gwendal Roué 485509a8cc Query documentation 2021-11-25 13:47:27 +01:00
Gwendal Roué a81f80cddb Query documentation 2021-11-25 13:46:50 +01:00
Gwendal Roué d590a06212 Query documentation 2021-11-25 12:39:50 +01:00
Gwendal Roué b3a1497791 Query documentation 2021-11-25 12:38:27 +01:00
Gwendal Roué c7f0a80a91 Query documentation 2021-11-25 10:52:10 +01:00
Gwendal Roué 068081d043 Query documentation 2021-11-25 10:37:06 +01:00
Gwendal Roué 01ba7de2f9 Query documentation 2021-11-25 10:16:38 +01:00
Gwendal Roué 10e784bee3 Query documentation 2021-11-25 10:11:35 +01:00
Gwendal Roué 21c6c9c794 Query documentation 2021-11-25 09:49:19 +01:00
Gwendal Roué dec515aceb Query documentation 2021-11-25 09:42:21 +01:00
Gwendal Roué 9be04da707 Query documentation 2021-11-25 09:41:25 +01:00
Gwendal Roué 6b02b4ca02 Rename Query generic parameter to Request 2021-11-25 09:37:40 +01:00
Gwendal Roué 5983473aa5 Query documentation 2021-11-25 09:33:24 +01:00
Gwendal Roué 1c4456a9fc Query documentation 2021-11-25 09:28:59 +01:00
Gwendal Roué 82a2776acd Query documentation 2021-11-25 09:14:54 +01:00
Gwendal Roué c7fb5cb3e3 Query demo README 2021-11-24 20:48:56 +01:00
Gwendal Roué f726b670f9 Polish Query demo app 2021-11-24 20:18:37 +01:00
Gwendal Roué 62e710b9b1 Cleanup Query demo app 2021-11-24 19:16:39 +01:00
Gwendal Roué 66f953a21a Rename Query demo app 2021-11-24 17:19:07 +01:00
Gwendal Roué ceed45cf22 QuerySideEffect demo 2021-11-24 09:40:15 +01:00
Gwendal Roué 13a040ae1b CHANGELOG 2021-11-18 08:39:01 +01:00
Gwendal Roué d8b83fba12 improve compilation time 2021-11-18 08:34:59 +01:00
Gwendal Roué 93c4249619 ForeignKeyViolation.databaseError(_:) 2021-11-16 08:51:33 +01:00
Gwendal Roué ebc8524706 Add missing public qualifiers 2021-11-16 08:45:34 +01:00
Gwendal Roué ea41f34f3d Quote table name in raw SQL query 2021-11-16 08:40:16 +01:00
Gwendal Roué 861ca5f022 Merge branch 'development' into dev/async 2021-11-07 16:30:37 +01:00
Gwendal Roué 59f9482aa7 Fix links to documentation images 2021-11-07 16:29:17 +01:00
Gwendal Roué 8658b7bc10 Merge branch 'development' 2021-11-07 16:20:59 +01:00
Gwendal Roué 42eeb54d6f v5.13.0 2021-11-07 16:06:50 +01:00
Gwendal Roué fe32981e0e Performance report: fallback for hardware name
The https://apple.stackexchange.com/a/98089 technique does not work on my mac
2021-11-07 16:06:50 +01:00
Gwendal Roué 0c9de25a8c Bump number of operations performed by performance tests
Apple Silicon and SSD are too fast, and we need to display higher numbers
2021-11-07 16:06:50 +01:00
Gwendal Roué 2b5d3f1d72 Upgrade Realm version in performance tests 2021-11-07 16:06:50 +01:00
Gwendal Roué 9da2e66e46 Fix flaky test 2021-11-07 14:58:18 +01:00
Gwendal Roué 8bf45e5452 Remove debugging code 2021-11-07 14:46:36 +01:00
Gwendal Roué d85168dd3c Query cleanup 2021-11-07 13:47:04 +01:00
Gwendal Roué 7ed103d5e4 Documentation 2021-11-07 13:25:50 +01:00
Gwendal Roué b44a9eb470 Extract @Query into its own package 2021-11-07 12:03:55 +01:00
Gwendal Roué d240d8c5f0 Fix typo 2021-11-07 11:58:51 +01:00
Gwendal Roué 74f268a378 Makefile: test_GRDBAsyncDemo 2021-11-07 11:49:42 +01:00
Gwendal Roué f74ce91a17 Merge branch 'development' into dev/async
# Conflicts:
#	CHANGELOG.md
#	Documentation/Concurrency.md
#	README.md
2021-11-07 11:47:01 +01:00
Gwendal Roué 23a9b6e1ae Makefile: test BUILD_LIBRARY_FOR_DISTRIBUTION & XCFramework 2021-11-07 11:13:35 +01:00
Gwendal Roué 03822bdf99 Makefile: skip test_framework_GRDBtvOS_minTarget until simulator is installed 2021-11-07 10:45:03 +01:00
Gwendal Roué b0c77a5e0f Makefile: tests for demo apps 2021-11-07 10:41:12 +01:00
Gwendal Roué af2d65ef49 Fix Swiftlint warnings 2021-11-07 10:32:00 +01:00
Gwendal Roué 72271b0299 CHANGELOG 2021-11-07 10:07:46 +01:00
Gwendal Roué b5433803ef Makefile: support for Xcode 13.1 2021-11-07 10:03:42 +01:00
Gwendal Roué 037443e600 Wording 2021-11-07 09:36:50 +01:00
Gwendal Roué 19b182b6a8 Remove the immediate transactions advice
It has write transactions fail faster, but it also has writes that only read, or writes that do nothing fail - for no good reason.
2021-11-07 09:20:38 +01:00
Gwendal Roué 0955ac3001 New concurrent read illustration 2021-11-07 09:14:23 +01:00
Gwendal Roué ff7773cf41 Wording 2021-11-07 08:29:24 +01:00
Gwendal Roué 8a0cbb63f5 Wording 2021-11-07 08:25:24 +01:00
Gwendal Roué d3e55cf8f6 wording 2021-11-07 08:23:47 +01:00
Gwendal Roué 7af3858ff6 More robust DatabasePool.close() test 2021-11-07 08:17:48 +01:00
Gwendal Roué c3bbd3d6f8 CHANGELOG 2021-11-07 08:17:46 +01:00
Gwendal Roué eb9d0bce58 Documentation 2021-11-07 08:16:58 +01:00
Gwendal Roué 716e223844 Fix typo 2021-11-06 17:09:12 +01:00
Gwendal Roué 1df5d834e8 Wording 2021-11-06 17:06:51 +01:00
Gwendal Roué 05b03ef56c Wording 2021-11-06 17:02:47 +01:00
Gwendal Roué 06827de207 All fetches are stale 2021-11-06 17:00:19 +01:00
Gwendal Roué 1070b9bd9d Exercise guarantees in context 2021-11-06 16:05:05 +01:00
Gwendal Roué de4c06478d New Concurrency Images 2021-11-06 16:00:40 +01:00
Gwendal Roué 78d5b4abaa Doc of completion block-based async accesses 2021-11-06 12:39:05 +01:00
Gwendal Roué 5e89d08fd0 Layout Concurrency Guide 2021-11-06 12:27:19 +01:00
Gwendal Roué 3d5b436a81 CHANGELOG 2021-11-06 12:23:54 +01:00
Gwendal Roué 1738ad34cd Extract the Concurrency Guide 2021-11-06 12:23:54 +01:00
Gwendal Roué 65668cfc8e Documentation 2021-11-06 11:22:16 +01:00
Gwendal Roué 9249efbe6f Fix UIKit warnings 2021-11-06 09:43:38 +01:00
Gwendal Roué 913860f3ce UUID encoding strategies uppercaseString and lowercaseString
This commit was influenced by https://forums.swift.org/t/53058
2021-11-04 20:33:55 +01:00
Gwendal Roué 088f76db9e Merge pull request #1095 from groue/dev/foreign-keys-checks
Precise foreign key checks for migrations
2021-11-04 19:38:56 +01:00
Gwendal Roué 454dd73c4c CHANGELOG 2021-11-04 18:52:19 +01:00
Gwendal Roué c81a4dbf32 Distinguish "FOREIGN KEY constraint failed" from "FOREIGN KEY constraint violation" errors 2021-11-04 18:44:44 +01:00
Gwendal Roué 127c4e0440 Rename methods that check foreign keys 2021-11-04 18:26:24 +01:00
Gwendal Roué ffdc80646e Documentation 2021-11-04 16:12:46 +01:00
Gwendal Roué 7e9a2f5a73 Fix typo 2021-11-04 15:12:24 +01:00
Gwendal Roué 8a36f4d94e Clean up tests 2021-11-04 15:10:41 +01:00
Gwendal Roué 63ba4fb294 Rename unsafeWithoutDeferredForeignKeyChecks to disablingDeferredForeignKeyChecks 2021-11-04 15:10:33 +01:00
Gwendal Roué d0997efbb6 Documentation 2021-11-04 14:27:34 +01:00
Gwendal Roué 6193c6aa00 foreignKeyViolations() and checkForeignKeyViolations() 2021-11-04 14:19:11 +01:00
Gwendal Roué b66b907fbc Documentation 2021-11-03 14:56:59 +01:00
Gwendal Roué 51c15e9db6 Precise handling of foreign key checks in migrations 2021-11-03 13:26:24 +01:00
Gwendal Roué 0a8967ccde move applied migration identifiers table creation to the top of migrations execution
https://github.com/zdnk/GRDB.swift/commit/51ff937397248355d4b264aedfd5a8f05893a2b8

Thanks @zdnk :-)
2021-11-03 08:33:09 +01:00
Gwendal Roué 19fd58f64f Documentation 2021-11-02 21:48:51 +01:00
Gwendal Roué 19c7ec568c Documentation 2021-11-02 21:42:44 +01:00
Gwendal Roué bc8a31dcd2 Documentation 2021-11-02 20:33:03 +01:00
Gwendal Roué 2273efa07f Improve documentation of persistence methods 2021-11-02 08:13:34 +01:00
Gwendal Roué 62f568d932 Merge branch 'development' into dev/async 2021-11-02 06:02:29 +01:00
Gwendal Roué 1aab03b02a Fix close() test
The behavior of sqlite3_close_v2() depends on SQLite version. Don't test this behavior.
2021-11-01 19:55:31 +01:00
Gwendal Roué 1646dfc49b Fix FAQ organization 2021-11-01 10:28:31 +01:00
Gwendal Roué 640a67257f Documentation for async DatabaseMigrator.migrate() 2021-11-01 10:19:03 +01:00
Gwendal Roué 5be27dd90a CHANGELOG 2021-11-01 10:08:19 +01:00
Gwendal Roué 485ce79293 More ValueObservation async cancellation test 2021-11-01 09:45:16 +01:00
Gwendal Roué 5725d9db21 Refactor the ValueObservation async cancellation test 2021-11-01 08:03:00 +01:00
Gwendal Roué 7897c6a799 asyncUnsafeRead handle closed connection 2021-11-01 07:25:26 +01:00
Gwendal Roué 5f549ef6af Cleanup with Table 2021-11-01 07:22:09 +01:00
Gwendal Roué ac94a2f90e Merge branch 'development' into dev/async 2021-10-31 19:35:13 +01:00
Gwendal Roué 15b38353bc Add experimental warning to the documentation of async methods 2021-10-31 19:35:05 +01:00
Gwendal Roué a7c1a99866 Fix wording 2021-10-31 18:48:26 +01:00
Gwendal Roué 1a87faacfa Merge branch 'development' into dev/async 2021-10-31 18:32:03 +01:00
Gwendal Roué 5cc881138e CHANGELOG 2021-10-31 18:31:32 +01:00
Gwendal Roué 5e56a4465c close() documentation 2021-10-31 18:27:08 +01:00
Gwendal Roué 20cb50f52d Public close() method 2021-10-31 18:12:13 +01:00
Gwendal Roué b4f30784f4 Support for SwiftLint installed via Homebrew on Apple Silicon 2021-10-31 15:32:26 +01:00
Gwendal Roué 0f0c345ebb Fix markdown format 2021-10-31 14:38:10 +01:00
Gwendal Roué 1ee2c8097a SharedValueObservation is experimental 2021-10-31 13:55:18 +01:00
Gwendal Roué 3e58f35f1e I'm so fed up with this
https://developer.apple.com/forums/thread/663975
2021-10-31 13:54:53 +01:00
Gwendal Roué f70b75633c Documentation: fix typo 2021-10-31 12:34:09 +01:00
Gwendal Roué 3a44311b95 Documentation: fix typos and wordings 2021-10-31 12:33:17 +01:00
Gwendal Roué e0a6f43101 Documentation: async/await examples 2021-10-31 12:30:44 +01:00
Gwendal Roué 0c8c8cb1f4 Concurrency Guide: fix wordings 2021-10-31 12:22:23 +01:00
Gwendal Roué fa8598d1e8 Async/Await support is experimental 2021-10-31 11:50:05 +01:00
Gwendal Roué 6cf5a2c33d Merge branch 'development' into dev/async
# Conflicts:
#	CHANGELOG.md
2021-10-31 11:48:27 +01:00
Gwendal Roué 9790d05795 CHANGELOG 2021-10-31 11:29:32 +01:00
Gwendal Roué 273b9befd8 Update documentation for date and uuid encoding strategies 2021-10-31 11:26:27 +01:00
Gwendal Roué 31a5180a58 CHANGELOG 2021-10-31 11:09:22 +01:00
Gwendal Roué 8076e7c725 Fix failing tests for key/id encoding strategies 2021-10-31 11:07:17 +01:00
Gwendal Roué 4cc3768344 Failing tests for key/id encoding strategies 2021-10-31 11:04:01 +01:00
Gwendal Roué 0317c4e454 Reuse screenshot of Combine demo 2021-10-31 06:06:55 +01:00
Gwendal Roué db78c22904 Demo app requirements 2021-10-31 06:04:46 +01:00
Gwendal Roué 6b36c74de9 Concurrency: move saved(_:) and inserted(_:) suggestion to a FAQ 2021-10-31 06:03:35 +01:00
Gwendal Roué 51ab275714 Concurrency: suggest saved(_:) and inserted(_:) 2021-10-30 23:44:30 +02:00
Gwendal Roué b9e1f4604e Concurrency Guide: fix wordings 2021-10-30 23:20:29 +02:00
Gwendal Roué 0b853c5447 Concurrency Guide: fix wordings 2021-10-30 21:08:02 +02:00
Gwendal Roué 691ee8f7fd Concurrency Guide: fix typos and wordings 2021-10-30 20:38:48 +02:00
Gwendal Roué c755dc70ef Restrict async/await to Xcode 13.1+ 2021-10-30 20:09:39 +02:00
Gwendal Roué 9cc30018b6 CHANGELOG 2021-10-30 19:52:09 +02:00
Gwendal Roué 4616ef5229 Remove Concurrency guide from main README 2021-10-30 19:47:57 +02:00
Gwendal Roué 10a741a346 Concurrency Guide 2021-10-30 19:47:57 +02:00
Gwendal Roué 3c78029b3c SwiftUI demo apps: PlayerEditionView saves player when back button is pressed 2021-10-25 19:07:40 +02:00
Gwendal Roué 3ea6fb2201 Merge branch 'development' into dev/async 2021-10-25 18:23:00 +02:00
Gwendal Roué de7d5f42d4 Clarify the benefits of shared observations 2021-10-25 08:47:50 +02:00
Gwendal Roué 450a7c2d71 SharedValueObservation async sequence 2021-10-24 17:47:08 +02:00
Gwendal Roué 2542ad7de8 Reuse ValueObservationStart, and move BufferingPolicy to AsyncValueObservation 2021-10-24 17:33:32 +02:00
Gwendal Roué 2a665df672 Merge branch 'development' into dev/async 2021-10-24 17:13:16 +02:00
Gwendal Roué bddbc31733 Merge pull request #1088 from groue/dev/shareValueObservation
Shared ValueObservation
2021-10-24 17:11:31 +02:00
Gwendal Roué 92e4c8f785 I want a new keyboard ASAP 2021-10-24 17:06:25 +02:00
Gwendal Roué 909afc0233 Fix typo 2021-10-24 17:05:10 +02:00
Gwendal Roué d73228a812 Documentation 2021-10-24 17:04:07 +02:00
Gwendal Roué 76cac45720 Fix typo 2021-10-24 16:35:32 +02:00
Gwendal Roué 22a4f08f40 CHANGELOG 2021-10-24 16:25:18 +02:00
Gwendal Roué ae0edde7c5 Documentation 2021-10-24 16:22:47 +02:00
Gwendal Roué c62e4fd94c Documentation 2021-10-24 16:17:46 +02:00
Gwendal Roué 7690db9284 Documentation 2021-10-24 16:15:46 +02:00
Gwendal Roué 2f212b8a5f SharedValueObservation error handling 2021-10-24 15:46:32 +02:00
Gwendal Roué abc6c55e14 Documentation 2021-10-24 15:17:52 +02:00
Gwendal Roué 450ff62392 Fix SQLCipher tests 2021-10-24 14:03:39 +02:00
Gwendal Roué a5dd61ff13 Fix availability checks in tests
Fix `make test_framework_GRDBiOS_minTarget` with Xcode 13
2021-10-24 13:41:07 +02:00
Gwendal Roué c3618e0cf0 SharedValueObservation publisher 2021-10-24 12:38:00 +02:00
Gwendal Roué a3a804fa82 Upgrade CombineExpectations 2021-10-24 12:37:28 +02:00
Gwendal Roué 8ccaf59d4d Default SharedValueObservation extent: .whileObserved 2021-10-23 17:47:12 +02:00
Gwendal Roué 9e0b1b3ded SharedValueObservation 2021-10-23 17:23:48 +02:00
Gwendal Roué 0a65399a7b Merge branch 'development' into dev/async 2021-10-23 12:48:33 +02:00
Gwendal Roué 618969ab2a More tests for optional collections from prefetched rows 2021-10-23 12:46:30 +02:00
Gwendal Roué 53c662d179 Decode optional collections from prefetched rows
This allows to define records that only decode to-many associations when they are eager-loaded.

See https://github.com/groue/GRDB.swift/issues/1084#issuecomment-948880910
2021-10-23 12:40:55 +02:00
Gwendal Roué 02f71cfecc AsyncValueObservation: let user control buffering policy 2021-10-20 08:16:24 +02:00
Gwendal Roué 00cd547ea6 UIKit demo app: use UIAction 2021-10-19 20:12:26 +02:00
Gwendal Roué 66bbf15f58 UIKit demo app: use @IBSegueAction 2021-10-19 19:30:23 +02:00
Gwendal Roué dbb19979d6 Demo app: prefer tracking over trackingConstantRegion
For those specific player requests, trackingConstantRegion is _correct_. But readers may blindly copy and paste, and use trackingConstantRegion when they should not.

So the demo apps prefer the unoptimized but always-correct `tracking` method instead.
2021-10-19 08:57:45 +02:00
Gwendal Roué 0d8d40d683 Demo apps: document why we use .immediate observation scheduling 2021-10-19 08:55:41 +02:00
Gwendal Roué 5d69d2a35b All demo apps provide unbounded read-only access to the database
Also, UIKit app now does not have to deal with an initial asynchronous delivery of players
2021-10-19 08:54:48 +02:00
Gwendal Roué 128399871a Demo projects organization 2021-10-19 08:15:14 +02:00
Gwendal Roué 4dd5677755 Demo apps: rename newRandom to makeRandom 2021-10-19 08:03:56 +02:00
Gwendal Roué dbf3335188 Demo apps: prefer inserted(_:) over mutating a temp variable 2021-10-19 08:02:09 +02:00
Gwendal Roué 048082f4b2 Demo apps: prefer isEmpty(db) over fetchCount(db) == 0 2021-10-19 07:58:03 +02:00
Gwendal Roué 6a980f90da Async sequence is unsuitable for preventing flash of missing content
See https://forums.swift.org/t/52862 for a longer explanation.

Fortunately, we can base @Query on Combine publishers, which do not have this problem.
2021-10-18 08:41:44 +02:00
Gwendal Roué e4bfea8bcc Use inserted(_:) in order to avoid a temporary variable 2021-10-17 21:25:19 +02:00
Gwendal Roué 329a7c8301 @Query cleanup & documentation 2021-10-17 14:09:53 +02:00
Gwendal Roué 1ff5159d40 Add the MIT license to Query.swift
This file is designed to be copied into user apps: make sure the license comes along.
2021-10-17 13:38:28 +02:00
Gwendal Roué d6f8a9a9ea UIKit demo app is iOS15+/watchOS8+ 2021-10-17 13:26:42 +02:00
Gwendal Roué c711efc7e0 Combine demo app is iOS15+ 2021-10-17 13:26:42 +02:00
Gwendal Roué 01d2bc89a9 Cleanup async demo app 2021-10-17 13:26:42 +02:00
Gwendal Roué 6bcee422b7 Improve tests of async demo app 2021-10-17 13:26:42 +02:00
Gwendal Roué 07faea9cfe Restore demo app tests 2021-10-17 13:26:42 +02:00
Gwendal Roué b76950f695 Follow EnvironmentValues.managedObjectContext example: appDatabase is not optional 2021-10-17 13:26:42 +02:00
Gwendal Roué b9e79791a3 Modernize syntax 2021-10-17 13:26:42 +02:00
Gwendal Roué 533cef692f Use SwiftUI Label 2021-10-17 13:26:42 +02:00
Gwendal Roué 0bed585fd0 Use dismiss from SwiftUI environment 2021-10-17 13:26:42 +02:00
Gwendal Roué 54bef0bba6 Workaround "flash of missing content" https://forums.swift.org/t/52862 2021-10-17 13:26:42 +02:00
Gwendal Roué a7820f9a35 Cleanup 2021-10-17 13:26:42 +02:00
Gwendal Roué bd89311f4d Refactor Query for async sequences 2021-10-17 13:26:41 +02:00
Gwendal Roué 1e17bf011f Refactor Query for AppDatabase access 2021-10-17 13:26:41 +02:00
Gwendal Roué ed8ff31b3e GRDBAsyncDemo 2021-10-17 13:26:41 +02:00
Gwendal Roué 0ead20cdd6 All async apis are experimental 2021-10-17 13:26:41 +02:00
Gwendal Roué 2ad6131d08 Require canImport(_Concurrency)
This fixes the build for macOS 11.5
2021-10-17 13:26:41 +02:00
Gwendal Roué 646782d499 test AsyncValueObservation with all DatabaseQueue & Pool
Also use .trackingConstantRegion since it triggers optimizations
2021-10-17 13:24:10 +02:00
Gwendal Roué a888c46b1a New: AsyncValueObservation 2021-10-17 13:24:10 +02:00
Gwendal Roué 046d1d6355 -Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks 2021-10-17 13:24:10 +02:00
Gwendal Roué 8936ef6a40 DatabaseMigrator async methods
migrate(_:)
migrate(_:upTo:)
2021-10-17 13:24:10 +02:00
Gwendal Roué 8754b10a40 Documentation of DatabaseWriter async methods 2021-10-17 13:24:10 +02:00
Gwendal Roué 1f73c20ae2 DatabaseWriter async methods
write, writeWithoutTransaction, barrierWriteWithoutTransaction, erase, vacuum, vacuum(into:)
2021-10-17 13:24:10 +02:00
Gwendal Roué a827188881 async DatabaseReader.unsafeRead 2021-10-17 13:23:34 +02:00
Gwendal Roué 64be4763f2 async DatabaseReader.read 2021-10-17 13:23:34 +02:00
Gwendal Roué 20a1c8666e Merge pull request #1078 from groue/dev/qol
More convenience methods
2021-10-17 13:21:22 +02:00
Gwendal Roué e6f00a7c4b CHANGELOG 2021-10-17 13:11:06 +02:00
Gwendal Roué aa05148a18 Documentation 2021-10-17 13:05:07 +02:00
Gwendal Roué 94c86211bc Add inserted and saved in the list of record methods 2021-10-17 13:00:13 +02:00
Gwendal Roué b4570c0e84 Fix typos in Table documentation 2021-10-17 12:56:24 +02:00
Gwendal Roué 8c9ac0ecd2 Documentation for exists, isEmpty, saved, inserted 2021-10-17 12:28:42 +02:00
Gwendal Roué 5f44162abe Rename request.exists(_:) to isEmpty(_:) 2021-10-17 12:27:19 +02:00
Gwendal Roué 55b938a1f5 Test exists(_:), exists(_🔑) and exists(_🆔) 2021-10-17 12:27:19 +02:00
Gwendal Roué 235ea2e689 Test saved(_:) and inserted(_:) 2021-10-17 12:27:19 +02:00
Gwendal Roué 7a046fb27e exists(_:) quality of life improvements 2021-10-17 12:27:19 +02:00
Gwendal Roué cbd68099a9 inserted(_:) and saved(_:) quality of life improvements 2021-10-17 12:27:19 +02:00
Gwendal Roué 6d44c05f3b DatabasePool.erase() prevents concurrent reads until it has completed 2021-10-13 14:46:47 +02:00
Gwendal Roué fe6d4665ee CHANGELOG 2021-10-12 18:32:38 +02:00
Gwendal Roué 0c6c2c7eb4 Merge pull request #1076 from groue/dev/require-swift-5.3
Require Swift 5.3
2021-10-12 18:29:44 +02:00
Gwendal Roué 03fe178439 Bump Xcode compatibility version of projects (Xcode 12+) 2021-10-11 17:13:26 +02:00
Gwendal Roué ff126c1543 SE-0276 Multi-Pattern Catch Clauses 2021-10-11 16:24:38 +02:00
Gwendal Roué 038c320f07 Require Swift 5.3. 2021-10-11 16:18:29 +02:00
Gwendal Roué ba88a150c0 Improve inline doc of database access methods 2021-10-11 15:50:06 +02:00
Gwendal Roué 32df5e27c3 Test for DatabaseRegionObservation tracking DatabaseRegion.fullDatabase 2021-10-01 11:13:41 +02:00
Gwendal Roué 2d4398798a SE-0299 for DatabaseRegionConvertible.fullDatabase 2021-10-01 11:13:20 +02:00
Gwendal Roué 32b2923e89 Merge branch 'development' 2021-09-25 19:44:17 +02:00
Gwendal Roué dbb4668033 v5.12.0 2021-09-25 19:13:10 +02:00
Gwendal Roué abcbf72421 CHANGELOG 2021-09-25 19:13:10 +02:00
Gwendal Roué 6724862eea Bump min iOS version to 11.0
This drops support for 32 bit devices
Fix #1059
Fix #1033
2021-09-25 19:13:10 +02:00
Gwendal Roué 79c5c1d1ba Failing test for #1059
Xcode 13, make test_install_SPM_ios_release
2021-09-25 19:13:10 +02:00
Gwendal Roué bc9ea84bb2 Merge pull request #1052 from jason-gabriele/fix-swift-error
Change init to fix Swift error
2021-09-22 10:34:43 +02:00
Gwendal Roué c0d70f9ef0 Refactor FTS5 tokenization in order to support custom tokenizers 2021-09-21 19:34:06 +02:00
Gwendal Roué bcd65f534b CHANGELOG 2021-09-20 17:55:56 +02:00
Gwendal Roué 7ae5010353 Document the tokenize(_:) method 2021-09-20 17:53:59 +02:00
Gwendal Roué 46eceb5e28 Document prefix-based FTS patterns 2021-09-20 17:47:17 +02:00
Gwendal Roué dfe519ea9b Build FTS patterns from prefixes 2021-09-20 17:35:47 +02:00
Gwendal Roué b0b8872798 Expose FTS tokenization methods 2021-09-20 17:14:07 +02:00
jason fbc0ee77bb Change init to fix Swift error 2021-09-08 13:57:24 -07:00
Gwendal Roué 1acf8e4b1e Merge branch 'development' 2021-09-03 14:59:18 +02:00
Gwendal Roué 042fbe958d v5.11.0 2021-09-03 14:59:02 +02:00
Gwendal Roué e4bc3da4d7 Merge pull request #1029 from sberrevoets/master
Column coding strategies for Codable records
2021-09-03 14:55:20 +02:00
Gwendal Roué cc23263897 Update thank you notice 2021-09-03 14:51:01 +02:00
Gwendal Roué c7e05caf86 CHANGELOG 2021-09-03 14:50:53 +02:00
Gwendal Roué dabdb0d590 Merge branch 'development' into pr-1029 2021-09-03 14:37:29 +02:00
Gwendal Roué 14ca47f84d CHANGELOG 2021-09-03 14:37:14 +02:00
Gwendal Roué d63429ea23 DatabaseMigrator.migrations 2021-09-03 14:31:46 +02:00
Gwendal Roué 87e9a0d0e0 Add license 2021-08-30 19:21:37 +02:00
Gwendal Roué d2e7485b02 Thorough testing of DatabaseColumnDecodingStrategy with including(all:)
We make sure strategies are correctly applied for each involved record type.
2021-08-29 14:14:31 +02:00
Gwendal Roué c23d977759 Thorough testing of DatabaseColumnDecodingStrategy with including(optional:) and including(required:)
We make sure strategies are correctly applied for each involved record type.
2021-08-29 14:12:23 +02:00
Gwendal Roué 0842e11281 Thourough testing of DatabaseColumnDecodingStrategy 2021-08-29 13:53:22 +02:00
Gwendal Roué e6e2536f6b Reverse DatabaseColumnDecodingStrategy
It does not convert coding keys to columns, but columns to CodingKeys, exactly as JSONDecoder.KeyDecodingStrategy
2021-08-29 13:52:36 +02:00
Gwendal Roué 86e4adf860 Spot a design flaw 2021-08-29 10:08:08 +02:00
Gwendal Roué c36aa2bfda Fix typo 2021-08-29 09:59:49 +02:00
Gwendal Roué 427a00582f Rename keyDecodingStrategy to columnDecodingStrategy 2021-08-29 09:55:06 +02:00
Gwendal Roué 6f024373b3 Fix failing test 2021-08-29 09:51:31 +02:00
Gwendal Roué 76f8b5547f Failing test 2021-08-29 09:51:24 +02:00
Gwendal Roué e60a31f401 Fix failing test 2021-08-29 09:40:32 +02:00
Gwendal Roué 8846ea3c25 Failing test 2021-08-29 09:40:16 +02:00
Gwendal Roué d567630966 Column decoding strategy only applies to columns 2021-08-29 08:55:39 +02:00
Gwendal Roué 5a04183baf Fix test name 2021-08-29 08:55:06 +02:00
Gwendal Roué 8aa640f84b Documentation: Column Names Coding Strategies 2021-08-29 08:41:46 +02:00
Gwendal Roué 42045ad8fb Merge remote-tracking branch 'origin/development' into pr1029 2021-08-29 08:37:13 +02:00
Gwendal Roué 0914b56c41 Add mark 2021-08-29 08:31:36 +02:00
Gwendal Roué 33e2c379db Make it clear that strategies apply to columns only
...and not to row scopes or prefetched records
2021-08-28 16:24:53 +02:00
Gwendal Roué 06763e47d2 Share convertToSnakeCase() 2021-08-28 16:05:41 +02:00
Gwendal Roué 5f23d97903 Add the custom strategies 2021-08-28 15:50:34 +02:00
Gwendal Roué 03a8e03a92 Documentation
Doc of cases is copied from JSONDecoder.KeyDecodingStrategy and JSONEncoder.KeyEncodingStrategy
2021-08-28 15:48:31 +02:00
Gwendal Roué 987b8a48e5 Key coding strategies transform keys into columns
They are not String transformers
2021-08-28 15:41:12 +02:00
Gwendal Roué cbc24751d1 Merge pull request #1046 from groue/dev/issue1043
Improve performance of by-index row decoding
2021-08-28 15:28:19 +02:00
Gwendal Roué e0b397fd4e Upgrade versions of compared libraries 2021-08-28 14:55:18 +02:00
Gwendal Roué c26df67e78 Raise the number of iterations for more precise average 2021-08-28 14:54:51 +02:00
Gwendal Roué ae60de399e Inline GRDBPrecondition 2021-08-28 14:54:51 +02:00
Gwendal Roué b06dc5dc77 Do not inline RowDecodingError.valueMismatch creation 2021-08-28 14:54:51 +02:00
Gwendal Roué c0c8eec75d Replace _checkedIndex with _checkIndex
That's what the stdlib Array does
2021-08-28 14:54:51 +02:00
Gwendal Roué 151a457251 Inline StatementColumnConvertible decoding 2021-08-28 14:53:54 +02:00
Gwendal Roué fc4b55dd97 Restore compilation flags to their pristine state
This reverts an undesired change in 0511fec001
2021-08-26 17:30:30 +02:00
Gwendal Roué ba41c22304 Merge branch 'development' 2021-08-22 16:18:55 +02:00
Gwendal Roué 04c18e3fd6 v5.10.0 2021-08-22 16:18:25 +02:00
Gwendal Roué 28f2aa1423 Upgrade performance comparison dependencies 2021-08-22 16:18:25 +02:00
Gwendal Roué 5ecc069bb4 TODO 2021-08-22 13:34:07 +02:00
Gwendal Roué 47934cc858 TODO 2021-08-22 12:44:54 +02:00
Gwendal Roué 0511fec001 SE-0299: enhance access to Column.rowID 2021-08-22 12:42:53 +02:00
Gwendal Roué 14b5eea277 CHANGELOG 2021-08-22 11:12:10 +02:00
Gwendal Roué c7294af809 Merge pull request #1038 from GetToSet/development
Add match operator in ColumnExpression for FTS5.
2021-08-22 11:10:02 +02:00
Gwendal Roué 8eff518850 Documentation for FTS5 column matching 2021-08-22 11:03:54 +02:00
Gwendal Roué 48ef691897 Disallow FTS5 column matching against NULL
SQLite just throws a syntax error
2021-08-22 11:03:18 +02:00
Ethan Wong 836432c4ce Add tests of column matching expression for fts5 2021-08-22 16:30:07 +08:00
Ethan Wong 2f3311cd1e Add match operator in ColumnExpression for FTS5 2021-08-22 16:12:39 +08:00
Gwendal Roué 8f7a2b6a8e Documentation: Combine and Data Consistency 2021-08-21 18:18:57 +02:00
Gwendal Roué 7ae35068c4 Merge pull request #1037 from groue/dev/BUILD_LIBRARY_FOR_DISTRIBUTION
Support BUILD_LIBRARY_FOR_DISTRIBUTION
2021-08-21 17:34:32 +02:00
Gwendal Roué 6639e9c598 CHANGELOG 2021-08-21 15:55:37 +02:00
Gwendal Roué e6cdbb156d FAQ: Does GRDB support library evolution and ABI stability 2021-08-21 15:48:17 +02:00
Gwendal Roué e2c9734df1 Specialize StatementColumnConvertible cursors 2021-08-21 15:48:07 +02:00
Gwendal Roué 18e9b1b9aa Specialize StatementColumnConvertible decoding 2021-08-21 14:53:11 +02:00
Gwendal Roué 59c4d42076 Remove test warnings with BUILD_LIBRARY_FOR_DISTRIBUTION 2021-08-21 14:08:46 +02:00
Gwendal Roué 665770c50c Remove all ABI annotations 2021-08-21 13:14:54 +02:00
Gwendal Roué f36f4aaf74 Deprecate count(_ counted: SQLSelectable) 2021-08-21 12:44:14 +02:00
Gwendal Roué 2858b803d0 Remove useless <Void> qualifiers
SQLRequest and CommonTableExpression are <Row> by default
2021-08-21 12:25:04 +02:00
Gwendal Roué faf100dbba Merge pull request #1036 from groue/dev/github-action
Basic GitHub action
2021-08-21 12:10:53 +02:00
Gwendal Roué 8af2b4bf1b Basic GitHub action 2021-08-21 12:06:09 +02:00
Gwendal Roué 253c878367 Cleanup 2021-08-17 08:30:51 +02:00
Gwendal Roué f5b1219549 SQLStatementCursor no longer allocates a copy of the sql C string
Based on https://forums.swift.org/t/stable-pointer-into-a-c-string-without-copying-it/51244
2021-08-16 18:59:55 +02:00
Gwendal Roué eda960de58 Merge branch 'development' 2021-08-15 19:12:58 +02:00
Gwendal Roué f0443a63eb v5.9.0 2021-08-15 19:12:48 +02:00
Gwendal Roué 24b978c3bb Update thank you notice 2021-08-15 14:33:03 +02:00
Gwendal Roué 3d180183a4 CHANGELOG 2021-08-15 14:32:51 +02:00
Gwendal Roué 98930d7f1d Merge pull request #1025 from DrawboardLtd/value-observer-reducer-locking
Added locking around `reducer` to mitigate Release build crashes.
2021-08-15 14:23:18 +02:00
Gwendal Roué adc16ea7dc Protect mutating TextOutputStream with a lock
This change addresses https://github.com/groue/GRDB.swift/pull/1025#issuecomment-898894618
2021-08-15 13:03:37 +02:00
Scott Berrevoets 79abf62a47 Fix name and convert Decodables as well 2021-08-14 21:45:35 -07:00
Scott Berrevoets 4ab7f1cf3e Add support for encoding as well 2021-08-12 20:12:10 -07:00
Scott Berrevoets cdc7805471 Add option for converting snake case
This adds an option to convert column names from snake case to camel
case, similar to how JSONDecoder works. In fact, the implementation here
is largely based on JSONDecoder's implementation.
2021-08-12 20:11:54 -07:00
Renaud Lienhart 7791e300d2 Use the ValueObserver.synchronized() helper 2021-08-06 09:27:39 +10:00
Matt Gallagher 8350dced55 Added locking around reducer to mitigate Release build crashes. 2021-08-06 09:10:29 +10:00
Gwendal Roué 97221c7bd6 Documentation 2021-07-31 09:39:24 +02:00
Gwendal Roué eb6895207e Remove Swiftlint warnings 2021-07-30 16:14:03 +02:00
Gwendal Roué d93b2f16e4 Remove the promising swiftlint rule that catches urls in doc comments
It yields false positives.

https://github.com/groue/GRDB.swift/pull/1012#issuecomment-889919351
2021-07-30 16:12:47 +02:00
Gwendal Roué f09a5e105d CHANGELOG 2021-07-30 14:34:38 +02:00
Gwendal Roué e6f6a11277 Merge pull request #1019 from groue/dev/merge-statements
Merge prepared statement types, and introduce statement cursor
2021-07-30 14:31:48 +02:00
Gwendal Roué fe95d07062 Documentation 2021-07-30 14:25:49 +02:00
Gwendal Roué dc3fac95db allStatements() can build statements without any arguments 2021-07-30 14:24:08 +02:00
Gwendal Roué be0a2c01e1 More allStatements() documentation 2021-07-30 13:55:59 +02:00
Gwendal Roué f232dfde27 CHANGELOG 2021-07-30 13:44:23 +02:00
Gwendal Roué e1dd96603b Test that cursors can trigger transaction observers
This is important because users will start executing database modifications with fetching methods, now that they have db.allStatement().
2021-07-30 13:41:52 +02:00
Gwendal Roué f2296c065a Test that cursors can invalidate schema cache
This is important because users will start executing DROP statements with fetching methods, now that they have db.allStatement().
2021-07-30 13:02:36 +02:00
Gwendal Roué 096eeffecf More allStatements() documentation 2021-07-30 12:54:52 +02:00
Gwendal Roué 6bbec1495d fix typo 2021-07-30 08:53:31 +02:00
Gwendal Roué a60fe170de Document allStatements() 2021-07-30 08:51:57 +02:00
Gwendal Roué 5cd34da6ca Use allStatements() from makeStatement() 2021-07-30 08:50:15 +02:00
Gwendal Roué a4acbf4854 Tests consuming values from allStatements() 2021-07-29 23:04:02 +02:00
Gwendal Roué c9eb67dae8 Database.allStatements(sql:literal:)
Addresses #1015
2021-07-29 22:41:49 +02:00
Gwendal Roué bf601e6810 Merge SelectStatement and UpdateStatement
Addresses #1015
2021-07-29 20:20:15 +02:00
Gwendal Roué c45f681813 Update thank you notice 2021-07-21 08:41:10 +02:00
Gwendal Roué 6a2645e0be CHANGELOG 2021-07-21 08:40:53 +02:00
Gwendal Roué 96108a5b9b Merge pull request #1012 from ZevEisenberg/add-brackets-to-urls
Add brackets to urls in doc comments to make them clickable
2021-07-21 07:53:58 +02:00
Zev Eisenberg a6e0d47d61 Add lint rule to catch URLs in doc comments that are not wrapped in angle brackets. 2021-07-20 21:10:36 -04:00
Zev Eisenberg 8b060e6b09 Add angle brackets to URLs to make them clickable in Xcode's rendered documentation. 2021-07-20 20:53:58 -04:00
Gwendal Roué f0a99a9100 Merge pull request #1010 from tternes/tt-add-vacuum-into
Add VACUUM INTO Support
2021-07-20 20:15:33 +02:00
Gwendal Roué 6cc45202a0 Enable vacuum(into:) with SQLCipher 2021-07-20 20:02:18 +02:00
Gwendal Roué 368594b051 Disable VACUUM INTO tests when not available 2021-07-20 19:42:40 +02:00
Gwendal Roué 8d4416d02e Update thank you notice 2021-07-20 19:36:49 +02:00
Gwendal Roué 6db245efe5 CHANGELOG 2021-07-20 19:35:59 +02:00
Gwendal Roué c115b6a92d Explain why vacuum(into:) is not available on DatabaseReader 2021-07-20 19:31:22 +02:00
Thaddeus Ternes dc40da1ef2 Improvements based on PR feedback 2021-07-19 21:59:43 -05:00
Gwendal Roué 374595d89e Merge pull request #1009 from kaishin/patch-1
Remove extra dot at the end of reference URL
2021-07-19 18:49:23 +02:00
Gwendal Roué 2d05dd488c Update TODO.md 2021-07-19 11:42:26 +02:00
Thaddeus Ternes 7d0c8c6657 Refactor tests, fix inline documentation parameter value 2021-07-12 02:28:49 -05:00
Thaddeus Ternes ed9fb39982 Add inline documentation 2021-07-12 01:26:34 -05:00
Thaddeus Ternes b28f75c5a2 Add VACUUM INTO support to DatabaseWriter 2021-07-12 01:19:45 -05:00
Reda Lemeden 1ac364defb Remove extra dot at the end of reference URL 2021-07-12 02:11:34 +02:00
Gwendal Roué e19de4e42e Merge branch 'dev/codable-database-value' into development 2021-07-04 19:29:47 +02:00
Gwendal Roué 57cf9b45b6 Add missing Foundation import for SPM 2021-07-04 19:28:27 +02:00
Gwendal Roué d772e8da3a CHANGELOG 2021-07-04 18:37:44 +02:00
Gwendal Roué ad48aa6eec Document the default DatabaseValueConvertible+Codable implementation 2021-07-04 18:36:56 +02:00
Gwendal Roué 620eb6f21c Default DatabaseValueConvertible+Codable implementation uses the JSON format 2021-07-04 17:34:31 +02:00
Gwendal Roué 653837bb02 Merge branch 'master' into development 2021-07-04 12:05:30 +02:00
Gwendal Roué 3de6f51427 Document that cipher_plaintext_header_size disables the salt 2021-07-01 09:12:57 +02:00
Gwendal Roué 9456fe809d Fix for Xcode 11.4 2021-06-27 16:36:18 +02:00
Gwendal Roué e907bc2686 Fix tvOS 14.5 simulator for Travis 2021-06-27 16:11:37 +02:00
Gwendal Roué e386553c18 Update Makefile for Xcode 12.5 2021-06-27 16:04:58 +02:00
Gwendal Roué 3b435d018f Use Xcode 12.5 on Travis 2021-06-27 15:54:56 +02:00
Gwendal Roué b5de7a907a Update link to 0xdead10cc documentation 2021-06-27 15:43:32 +02:00
Gwendal Roué e5bb488b00 CHANGELOG 2021-06-27 15:39:21 +02:00
Gwendal Roué 76852c1f9c Improve documentation about handling of NULL in foreign keys 2021-06-27 15:36:43 +02:00
Gwendal Roué 2f36fc06f5 Fix failing tests for #999 2021-06-27 15:36:12 +02:00
Gwendal Roué ff576d945c Failing tests for #999 2021-06-27 15:35:44 +02:00
Gwendal Roué 0098369e29 Simplify Refinable 2021-06-27 13:11:26 +02:00
Gwendal Roué fb5a3ba388 CHANGELOG 2021-06-22 08:27:38 +02:00
Gwendal Roué 98f398cd75 Deemphasize Table 2021-06-22 08:26:55 +02:00
Gwendal Roué f2dbbee428 Merge pull request #993 from groue/dev/Table
QueryInterfaceRequest builder with dynamic table/view name
2021-06-22 08:15:46 +02:00
Gwendal Roué f54467af3c Fix test for batch deletion of Identifiable type with Optional ID 2021-06-21 18:26:35 +02:00
Gwendal Roué 8c361acd7f Update documentation: batch delete/updates are available on TableRecord 2021-06-21 18:21:04 +02:00
Gwendal Roué bdfd5ce277 Table: batch delete & update
Also, MutablePersistableRecord is no longer necessary for such operations. TableRecord is enough.
2021-06-21 18:08:27 +02:00
Gwendal Roué 120c973e29 Refactor test for association from CTE to Table 2021-06-20 14:31:45 +02:00
Gwendal Roué 17ee1debdc Test associations from TableRecord to Table 2021-06-20 14:26:21 +02:00
Gwendal Roué b154998ae6 Fix documentation 2021-06-20 11:57:53 +02:00
Gwendal Roué eedd3af59b Test association from CTE to Table 2021-06-20 11:54:55 +02:00
Gwendal Roué c5b6325cf6 Table documentation 2021-06-20 11:39:14 +02:00
Gwendal Roué 629840f6f2 Table.fetchCount(_:) 2021-06-20 11:37:59 +02:00
Gwendal Roué e7ef3e1867 Prevent aggregate misuse
I wrote association.max("id") when I meant association.max(Column("id"))
2021-06-20 11:08:24 +02:00
Gwendal Roué 32bbee9c8a Tests for Table Associations 2021-06-20 11:07:38 +02:00
Gwendal Roué 9def48f4f6 Tests for Table 2021-06-19 17:31:40 +02:00
Gwendal Roué 92d10e2713 Table fetching methods 2021-06-19 17:31:23 +02:00
Gwendal Roué 3d855a6a90 Table request methods 2021-06-19 15:25:14 +02:00
Gwendal Roué d7971d76e7 Introduce Table 2021-06-19 14:30:04 +02:00
Gwendal Roué 220d221ea6 CHANGELOG 2021-06-19 14:03:37 +02:00
Gwendal Roué 2ce588ad76 Cached statements from a SQL literal
Addresses https://github.com/groue/GRDB.swift/issues/985#issuecomment-859570434
2021-06-19 13:57:53 +02:00
Gwendal Roué 7050e3cc48 Naive fix for #983 2021-06-19 13:31:30 +02:00
Gwendal Roué fed0b6b136 CHANGELOG 2021-06-19 13:24:27 +02:00
Gwendal Roué e3674ccdf2 Documentation for selectID() 2021-06-19 13:21:13 +02:00
Gwendal Roué 046564dab6 Fix #991 2021-06-19 13:05:24 +02:00
Gwendal Roué d6069888b8 Update thank you notice 2021-06-19 12:24:31 +02:00
Gwendal Roué a9ea79dba9 CHANGELOG 2021-06-19 12:24:23 +02:00
Gwendal Roué 18083165a1 Merge pull request #989 from pp5x/pp5x/fts-synchronize-if-not-exists
FTS: add support of ifNotExists in synchronize()
2021-06-19 12:20:13 +02:00
Gwendal Roué 1aeb10439f synchronize: failing test for FTS5 ifNotExists support 2021-06-17 19:30:24 +02:00
Gwendal Roué 1a2de126ce Fix #988 2021-06-17 19:30:03 +02:00
Pierre Pagnoux d8cb3066a1 synchronize: failing test for ifNotExists support 2021-06-15 17:35:45 +02:00
Gwendal Roué c3b3d2eeb8 Fix Xcode 13 beta 1 compilation warnings 2021-06-08 05:54:45 +02:00
Gwendal Roué 52b1727bb3 Fix Xcode 13 beta 1 compilation error 2021-06-08 05:54:31 +02:00
Gwendal Roué a328349514 Thank you notice 2021-05-31 14:04:02 +02:00
Gwendal Roué 5666ffb4a7 CHANGELOG 2021-05-31 14:03:56 +02:00
Gwendal Roué e6ef8740eb Merge branch 'master' into development 2021-05-31 13:58:51 +02:00
Gwendal Roué df6c2e2b05 Merge pull request #980 from jroselightricks/feature/spelling
Fix spelling succesful -> successful.
2021-05-31 13:58:25 +02:00
Jonathan Rose ae7f83dc40 Fix spelling succesful -> successful. 2021-05-31 14:28:28 +03:00
Gwendal Roué 1693a706e0 Skip tests that do not support encrypted databases 2021-05-29 13:26:17 +02:00
Gwendal Roué af13c91744 Merge branch 'development' 2021-05-16 15:25:33 +02:00
Gwendal Roué b5dea2164f v5.8.0 2021-05-16 15:25:15 +02:00
Gwendal Roué 148897ad73 Simplify 2021-05-04 07:27:21 +02:00
Gwendal Roué 095bfde072 CHANGELOG 2021-05-02 18:05:13 +02:00
Gwendal Roué fabdb73785 Merge pull request #967 from steipete/peter/selectStatement-Debug
Make SelectStatement conform to CustomStringConvertible
2021-05-02 18:03:44 +02:00
Gwendal Roué f30f970cf2 Merge pull request #973 from groue/dev/issue-971
Restore access to attached databases from record types
2021-05-02 10:12:58 +02:00
Gwendal Roué 1c2499528c Merge branch 'development' into dev/issue-971 2021-05-02 10:12:41 +02:00
Gwendal Roué 766e731bf9 Merge pull request #974 from groue/dev/issue-965
Provide access to included associations when root table is not selected
2021-05-02 10:11:12 +02:00
Gwendal Roué b9496a01e1 Simplify FAQ now that Statement conforms to CustomStringConvertible 2021-05-02 10:07:07 +02:00
Gwendal Roué 1554c80fdb Statement.sql checks correct scheduling 2021-05-02 10:02:21 +02:00
Gwendal Roué 61ee7cc3f7 Move SelectStatement.description to Statement 2021-05-02 10:01:44 +02:00
Gwendal Roué 0f481e7867 CHANGELOG 2021-05-01 17:32:02 +02:00
Gwendal Roué ed3397176a Documentation 2021-05-01 17:28:49 +02:00
Gwendal Roué 5f4c64ceda Fix failing tests for #965 2021-05-01 17:00:12 +02:00
Gwendal Roué e5a810105a Failing tests for #965 2021-05-01 16:59:38 +02:00
Gwendal Roué a46b2ad127 Fix "cannot ATTACH database within transaction" error in older versions of SQLite 2021-05-01 15:08:36 +02:00
Gwendal Roué 3ccac4098a CHANGELOG 2021-05-01 15:06:08 +02:00
Gwendal Roué a4e8bbe2da Add test for cross-attached-databases association 2021-05-01 14:55:53 +02:00
Gwendal Roué 52bc7eb7c6 Cleanup 2021-05-01 14:40:20 +02:00
Gwendal Roué e8802fb010 Fix #971 2021-05-01 14:32:01 +02:00
Gwendal Roué 885f43dbad Failing tests for #971 2021-05-01 14:27:44 +02:00
Peter Steinberger 5dfab017e5 Make SelectStatement conform to CustomStringConvertible 2021-04-22 14:12:10 +02:00
Gwendal Roué 35d6ac0041 CHANGELOG 2021-04-18 18:21:22 +02:00
Gwendal Roué eae64b587a Documentation 2021-04-18 17:25:05 +02:00
Gwendal Roué fb6ae07722 Documentation 2021-04-18 17:22:08 +02:00
Gwendal Roué 491e17f62e Documentation 2021-04-18 17:21:13 +02:00
Gwendal Roué f521002e74 Documentation 2021-04-18 17:17:30 +02:00
Gwendal Roué bbaee79618 Documentation 2021-04-18 17:10:47 +02:00
Gwendal Roué 64951c84d7 Documentation 2021-04-18 17:08:02 +02:00
Gwendal Roué 5996b64469 Documentation 2021-04-18 17:00:55 +02:00
Gwendal Roué 65b2fecdfc Documentation 2021-04-18 16:56:38 +02:00
Gwendal Roué 232086e50e Documentation 2021-04-18 16:41:53 +02:00
Gwendal Roué 8f7feda27c Documentation 2021-04-18 16:31:44 +02:00
Gwendal Roué 6aa6c4d4b5 Documentation 2021-04-18 16:19:06 +02:00
Gwendal Roué afc360cf78 Documentation 2021-04-18 16:13:42 +02:00
Gwendal Roué 5673d73738 Documentation 2021-04-18 16:09:22 +02:00
Gwendal Roué 4a894f2b43 Documentation 2021-04-18 16:05:35 +02:00
Gwendal Roué 83cd6d1469 Change Query Interface Organization picture 2021-04-18 14:28:48 +02:00
Gwendal Roué 0b2e5d836f Query Interface Organization 2021-04-18 14:26:46 +02:00
Gwendal Roué b9576aedbe SQLCollection is not public 2021-04-18 11:41:11 +02:00
Gwendal Roué 2f549d21bf Can't articulate distinctive features yet 2021-04-18 11:28:56 +02:00
Gwendal Roué 4d6958b52a Documentation 2021-04-17 20:55:21 +02:00
Gwendal Roué 588b2677e7 Documentation 2021-04-17 20:52:26 +02:00
Gwendal Roué 66e52eea40 Documentation 2021-04-17 20:46:29 +02:00
Gwendal Roué 975cbaa7e8 MyPlayground setup 2021-04-17 20:31:27 +02:00
Gwendal Roué 9e265f7ebc Documentation 2021-04-17 20:19:33 +02:00
Gwendal Roué 37522f3766 Documentation 2021-04-17 19:55:01 +02:00
Gwendal Roué 4980beda69 Documentation 2021-04-17 16:47:28 +02:00
Gwendal Roué 69b9c7331f Documentation 2021-04-17 16:46:16 +02:00
Gwendal Roué 28375f5c1a Organization image 2021-04-17 16:41:37 +02:00
Gwendal Roué e019617a50 Documentation 2021-04-17 16:21:11 +02:00
Gwendal Roué 8ff0c456dc Documentation 2021-04-17 16:13:49 +02:00
Gwendal Roué 744b0c5661 Documentation 2021-04-17 16:10:28 +02:00
Gwendal Roué c6003143c4 Documentation 2021-04-17 16:04:51 +02:00
Gwendal Roué b0545bcfb0 CHANGELOG 2021-04-17 15:52:17 +02:00
Gwendal Roué 3976feb6ab Query Interface Organization 2021-04-17 15:52:11 +02:00
Gwendal Roué 002399ff1a Remove limit(_:offset:) from documentation 2021-04-17 15:44:53 +02:00
Gwendal Roué cdc21531fc Query Interface Organization 2021-04-17 15:41:03 +02:00
Gwendal Roué 7afe011b69 Improve documentation 2021-04-17 15:38:30 +02:00
Gwendal Roué 12809f5891 Fix duplicate file warning 2021-04-17 13:22:27 +02:00
Gwendal Roué 7fd51f440a Warn about DerivableRequest.limit(_:offset:)
We can't deprecate it because the compiler emits a warning on acceptable request.limit() calls :-(
2021-04-17 13:22:08 +02:00
Gwendal Roué 4f0d3b31e1 SQLRequest is SQLRequest<Row> unless stated otherwise 2021-04-17 12:53:20 +02:00
Gwendal Roué 36039fb6a3 Documentation 2021-04-17 12:48:18 +02:00
Gwendal Roué e66e59cd21 Remove misleading documentation
Limiting to-many associations does not do what this false documentation is saying
2021-04-15 18:24:54 +02:00
Gwendal Roué a3279c9f63 Distinctive Features 2021-04-15 18:02:43 +02:00
Gwendal Roué 5ed64ea8f8 CHANGELOG 2021-04-14 20:13:58 +02:00
Gwendal Roué 62763ece52 Documentation for LIKE ESCAPE 2021-04-14 20:12:02 +02:00
Gwendal Roué c50f698eae Add support for the ESCAPE clause of the LIKE operator
Address #962
2021-04-14 20:06:54 +02:00
Gwendal Roué 31e2b01c10 Merge branch 'development' 2021-04-11 16:32:47 +02:00
Gwendal Roué 7fd786955c v5.7.4 2021-04-11 16:17:39 +02:00
Gwendal Roué af13283aa7 Update thank you notice 2021-04-11 15:48:56 +02:00
Gwendal Roué 6a5d196c2d CHANGELOG 2021-04-11 15:47:32 +02:00
Gwendal Roué 6959ac80b5 Merge pull request #960 from MartinP7r/userinfo_tests
adds test for userInfo being applied to database encoder/decoder
2021-04-11 15:40:03 +02:00
Martin Pfundmair 0c4e483e9e adds test for userInfo in EncodableRecord.databaseJSONDecoder()
Making sure that `databaseEncodingUserInfo` is being applied to `FetchableRecord.databaseJSONDecoder()`

This tries to cover the other half of the changes in PR groue#958
2021-04-11 09:29:33 +09:00
Gwendal Roué f9c162b657 CHANGELOG 2021-04-10 18:16:53 +02:00
Gwendal Roué c0f537c5e6 Merge pull request #956 from groue/dev/observation-case-insensitivity
Fix case-sensitivity of region-based database observation
2021-04-10 18:12:03 +02:00
Martin Pfundmair 8895d590a0 adds test for userInfo in FetchableRecord.databaseJSONDecoder()
Making sure that databaseDecodingUserInfo is being applied to FetchableRecord.databaseJSONDecoder()

This tries to cover some of the changes in PR groue#958
2021-04-11 00:02:09 +09:00
Gwendal Roué a44c518e31 Fix DatabaseRegion tests for tvOS 10.2 2021-04-10 16:27:46 +02:00
Gwendal Roué 0571d9b3b8 Fix DatabaseRegion tests for iOS 10.3.1 2021-04-10 16:27:45 +02:00
Gwendal Roué c0a3e61253 DatabaseRegion is now case-preserving and case-insensitive 2021-04-10 16:27:45 +02:00
Gwendal Roué c02901b335 Fix canonicalName(_:ofType:) 2021-04-10 16:27:45 +02:00
Gwendal Roué ee2d6d8074 CaseInsensitiveIdentifier should help 2021-04-10 16:27:45 +02:00
Gwendal Roué b51dc81c3a Failing tests for #954 2021-04-10 16:27:45 +02:00
Gwendal Roué 47199ed72b Merge branch 'master' into development 2021-04-10 16:26:55 +02:00
Gwendal Roué 28bddb04fa Merge pull request #955 from steipete/peter/query-base
Ensure Query can be updated
2021-04-10 16:20:14 +02:00
Gwendal Roué c34615ced3 Document that @steipete's test has turned moot
We don't 100% need to address this now, but we 100% need to remember this in the future.
2021-04-10 16:10:02 +02:00
Gwendal Roué a5ffc52dbe Restore the barebone app setup
Leave the AppView(initialOrdering:) initializer, though, so that readers can get some inspiration.
2021-04-10 15:45:00 +02:00
Gwendal Roué fd61a5f1ea Remove 14.5 IPHONEOS_DEPLOYMENT_TARGET
Tests succeed on 14.4, and 14.0 target does not generate any Xcode warning
2021-04-10 15:37:18 +02:00
Gwendal Roué 0f70e9d9c9 Remove all DEVELOPMENT_TEAM from demo app 2021-04-10 15:35:42 +02:00
Gwendal Roué d4f1102976 Document how AppDatabase.makeShared() supports test
This helps readers understand the purpose of those lines, and remove them if they are not interested.
2021-04-10 15:07:02 +02:00
Martin Pfundmair 1591948c10 Merge pull request #958 from Rightpoint/userinfo-fix
Always add userInfo to databaseJSONDecoder and databaseJSONEncoder
2021-04-10 15:21:52 +09:00
Chris Ballinger 43de1c24a7 Add userInfo to databaseJSONDecoder and databaseJSONEncoder 2021-04-08 13:11:59 -07:00
Peter Steinberger 481f6e93e5 Add UI test to show late-changing of Query 2021-04-08 10:41:20 +02:00
Peter Steinberger 6887441264 Ensure Query can be updated 2021-04-07 15:32:59 +02:00
Gwendal Roué e017eddf4f Merge branch 'development' 2021-04-05 17:00:08 +02:00
Gwendal Roué 53d75c37aa v5.7.3 2021-04-05 16:59:44 +02:00
Gwendal Roué 331990ce33 CHANGELOG 2021-04-05 16:54:56 +02:00
Gwendal Roué 63a52acb34 Merge pull request #953 from groue/dev/refactor-SwiftUI-demo
Refactor the SwiftUI demo app
2021-04-05 16:51:17 +02:00
Gwendal Roué 6958a10a08 Refactor the SwiftUI demo application 2021-04-05 15:28:45 +02:00
Martin Pfundmair 5d14b3d6db Merge pull request #952 from holsety/tiny/typo
Fix a tiny typo
2021-04-05 08:00:44 +09:00
hlst de0709163c Fix a tiny typo 2021-04-05 06:31:56 +08:00
Gwendal Roué 8c872fccfc End of experiment. But we squeezed a few more cycles :-) 2021-04-04 13:50:17 +02:00
Martin Pfundmair 46867877fd Merge pull request #951 from alexwlchan/patch-1
Fix a typo: "bet set" ~> "be set"
2021-04-04 09:25:09 +09:00
Alex Chan 622ecda283 Fix a typo: "bet set" ~> "be set" 2021-04-03 21:06:05 +01:00
Gwendal Roué 5f9911ff0d Performance tests for optimized records 2021-04-03 18:02:15 +02:00
Gwendal Roué eaf830c05c Fix paths in performance report 2021-04-03 16:47:53 +02:00
Gwendal Roué 064dec5095 Upgrade Realm 2021-04-03 16:26:27 +02:00
Gwendal Roué 89521a7288 Improve statement binding performance 2021-04-03 14:52:22 +02:00
Gwendal Roué 76d4e38cd1 CHANGELOG and thank you notice for #950 2021-04-02 08:29:25 +02:00
Gwendal Roué c56a56a2f3 Merge pull request #950 from MartinP7r/fix/json-column-memory
Fix memory consumption when encoding JSON columns
2021-04-02 08:26:21 +02:00
Martin Pfundmair 02d3518194 adds autoreleasepool for databaseJSONEncoder
when encoding json columns in order to prevent memory build up
2021-04-01 18:40:19 +09:00
Gwendal Roué 67892d7cdb CHANGELOG 2021-03-29 06:12:17 +02:00
Gwendal Roué 0e091124a2 v5.7.2 2021-03-29 06:09:24 +02:00
Gwendal Roué 2402185235 Make SQLLiteral public 2021-03-29 06:08:44 +02:00
Gwendal Roué f406062b81 Merge pull request #948 from xAlien95/patch-1
Fix documentation typo
2021-03-29 06:06:17 +02:00
Stefano De Carolis 7bf25925c7 Fix documentation typo 2021-03-29 02:25:10 +02:00
Gwendal Roué 8dd8a57de3 v5.7.1 2021-03-28 15:33:58 +02:00
Gwendal Roué fa8a8f0b87 Add fixit for SQLLiteral 2021-03-28 15:31:23 +02:00
Gwendal Roué fa2c489ee4 Fix typo 2021-03-28 10:20:35 +02:00
Gwendal Roué 2cb0baf88e Merge branch 'development' 2021-03-28 10:17:20 +02:00
Gwendal Roué 1ab23dfa52 v5.7.0 2021-03-28 10:16:20 +02:00
Gwendal Roué bd29585461 Wording 2021-03-28 10:12:55 +02:00
Gwendal Roué f1cd6dbae8 CHANGELOG 2021-03-28 09:56:47 +02:00
Gwendal Roué a91d9b23e0 Merge pull request #947 from Rightpoint/codable-access
Allow access to Encoder from KeyedEncodingContainer
2021-03-28 09:51:57 +02:00
Gwendal Roué 7eb348cb2a [skip travis] New Identifiable Records documentation chapter 2021-03-28 08:39:43 +02:00
Gwendal Roué ab4ae144ac [skip travis] Simplify Record introduction 2021-03-28 07:51:12 +02:00
Gwendal Roué 09899e9bcf filter(id:) does not accept optionals 2021-03-28 06:48:22 +02:00
Gwendal Roué 2625653532 Improve documentation of the EXISTS operator 2021-03-27 22:49:58 +01:00
Gwendal Roué ea26dea687 Fix typo 2021-03-27 22:20:30 +01:00
Gwendal Roué 4a17281bd7 Fix typo 2021-03-27 22:09:11 +01:00
Gwendal Roué e9ba3e6ccc Fix typo 2021-03-27 22:08:20 +01:00
Gwendal Roué 9692410e7d CHANGELOG 2021-03-27 22:07:09 +01:00
Gwendal Roué b69dfb1709 Document the type-safe extensions to Identifiable records 2021-03-27 22:07:04 +01:00
Gwendal Roué 4307eedbc0 Update demo apps with the new type-safe primary key methods 2021-03-27 21:10:34 +01:00
Gwendal Roué 521f9e498a deleteOne(_🆔) and deleteAll(_:ids:) 2021-03-27 21:07:01 +01:00
Gwendal Roué e7ce5f13e7 Tests for rowid filtering of Identifiable types 2021-03-27 21:06:01 +01:00
Gwendal Roué 55c0abef8b Tests for id filtering of Identifiable types 2021-03-27 19:46:03 +01:00
Gwendal Roué 9489174b98 Filter by id for Identifiable types with optional ID type 2021-03-27 18:47:16 +01:00
Gwendal Roué b086b99821 Filter by id for Identifiable types 2021-03-27 17:43:01 +01:00
Chris Ballinger 984dea156c Allow access to Encoder and Decoder from KeyedCodingContainer 2021-03-27 08:57:44 -07:00
Gwendal Roué 1297a781fd Better fatal error messages for unimplemented features 2021-03-27 16:41:23 +01:00
Gwendal Roué c4f9ddd688 Simplify handling of collated expressions 2021-03-27 16:34:37 +01:00
Gwendal Roué fcff9b34ba Make sure empty migrator publisher is async as well 2021-03-27 15:23:30 +01:00
Gwendal Roué 914ad1b882 Address #945 by running a distinctive query
When a user finds this query in the error log, it will be easier for everybody to understand why it happens.
2021-03-27 14:56:08 +01:00
Gwendal Roué b13922b76e Database schema cache distinguishes the main from the temp schema
Addresses https://github.com/groue/GRDB.swift/pull/946#issuecomment-805756799
2021-03-27 14:50:25 +01:00
Gwendal Roué f6f4839e07 Document that WITHOUT ROWID tables can't be tracked (#945) 2021-03-27 11:50:38 +01:00
Gwendal Roué c5aeec3385 Documentation 2021-03-23 18:33:02 +01:00
Gwendal Roué 21b22ab3fb Travis: check old Xcode version first 2021-03-21 16:38:26 +01:00
Gwendal Roué 39eb57fe64 Fix for Xcode 11.4 2021-03-21 16:36:54 +01:00
Gwendal Roué bbacfd5ec1 Wording 2021-03-21 16:32:35 +01:00
Gwendal Roué 7bbec01dec Remove references to GRDBObjc 2021-03-21 14:25:19 +01:00
Gwendal Roué 969f28945c Focus 2021-03-21 14:20:25 +01:00
Gwendal Roué 869f6cb3b3 Focus 2021-03-21 14:19:49 +01:00
Gwendal Roué 607e53b04e Add an "In a glance" usage section 2021-03-21 14:14:15 +01:00
Gwendal Roué 051fdb37b6 Rename SQLLiteral to SQL 2021-03-21 13:33:49 +01:00
Gwendal Roué db963cbbb2 TODO 2021-03-21 13:05:45 +01:00
Gwendal Roué 13120063e0 TODO 2021-03-21 13:01:00 +01:00
Gwendal Roué be02e920d2 Dry up number documentation 2021-03-21 12:58:52 +01:00
Gwendal Roué 901b9c6fe6 More NSNumber/NSDecimalNumber tests 2021-03-21 12:58:11 +01:00
Gwendal Roué 64f5e6bdca Always use Decimal(string:) when decoding strings 2021-03-21 12:57:50 +01:00
Gwendal Roué 178727fd5b CHANGELOG 2021-03-20 20:22:40 +01:00
Gwendal Roué 791a8ed41b Update documentation for NSNumber, NSDecimalNumber, and Decimal 2021-03-20 20:14:31 +01:00
Gwendal Roué d9083a7bf5 Support for Foundation.Decimal 2021-03-20 20:11:26 +01:00
Gwendal Roué e355af3584 Decode NSNumber from textual database values 2021-03-20 17:15:16 +01:00
Gwendal Roué 5b39494125 TODO 2021-03-20 15:51:06 +01:00
Gwendal Roué 4f709e8e4f CHANGELOG 2021-03-20 15:51:01 +01:00
Gwendal Roué 63448fb0bc Documentation for EXISTS 2021-03-20 15:47:00 +01:00
Gwendal Roué 989a0e82eb Test for EXISTS expression 2021-03-20 15:46:46 +01:00
Gwendal Roué 8ba05a011d EXISTS expression 2021-03-20 15:24:32 +01:00
Gwendal Roué 659e6a53bb Documentation 2021-03-20 14:40:17 +01:00
Gwendal Roué 8a7ab17349 TODO 2021-03-20 14:37:54 +01:00
Gwendal Roué 3113e20f69 CHANGELOG 2021-03-20 14:37:13 +01:00
Gwendal Roué e44dc8486a Documentation for asynchronous migrations 2021-03-20 14:33:37 +01:00
Gwendal Roué 21a2206443 Remove asynchronous migration to target identifier
Migrating up to a specific identifier is a test-oriented use case: it does not need any async version.
2021-03-20 14:20:41 +01:00
Gwendal Roué f38c2ff754 Test DatabasePublishers.Migrate 2021-03-20 14:12:09 +01:00
Gwendal Roué 8ad880e20d DatabaseMigrator publisher 2021-03-20 14:11:43 +01:00
Gwendal Roué 50cec3fce7 Asynchronous migrations tests 2021-03-20 13:27:40 +01:00
Gwendal Roué c9c652dddc DatabaseMigrator async migrations 2021-03-20 13:25:43 +01:00
Gwendal Roué edde38837e TODO 2021-03-20 12:21:53 +01:00
Gwendal Roué c4443eead8 SELECT * FROM cte is no longer a special case, because SQLGenerationContext knows about the available CTEs 2021-03-19 19:06:47 +01:00
Gwendal Roué 7c023d5c1f CHANGELOG 2021-03-18 19:30:50 +01:00
Gwendal Roué 99a06f1c05 CHANGELOG 2021-03-18 19:29:02 +01:00
Gwendal Roué 0c2b5318bf Documentation 2021-03-18 19:28:46 +01:00
Gwendal Roué c47316a846 Documentation 2021-03-18 19:25:07 +01:00
Gwendal Roué 529b042b8a Database.makeSelectStatement(literal:) tests 2021-03-18 19:24:37 +01:00
Gwendal Roué 5aa1184e68 Database.makeSelectStatement(literal:) 2021-03-18 19:24:24 +01:00
Gwendal Roué a912c5cbe5 Documentation 2021-03-18 18:53:16 +01:00
Gwendal Roué 3753bd8d6d Database.makeUpdateStatement(literal:) tests 2021-03-18 18:48:22 +01:00
Gwendal Roué a6f7d9ba86 Database.makeUpdateStatement(literal:) accepts all arguments, or no arguments 2021-03-18 18:48:06 +01:00
Gwendal Roué fdc47d7158 Database.makeUpdateStatement(literal:) 2021-03-18 17:08:25 +01:00
Gwendal Roué 8aa4807f9b CHANGELOG 2021-03-17 21:57:49 +01:00
Gwendal Roué 339fbdf1ce Literal column alteration 2021-03-17 21:54:56 +01:00
Gwendal Roué ada972d78d Documentation 2021-03-17 21:31:35 +01:00
Gwendal Roué 085c8f5953 Literal table and constraint definition 2021-03-17 20:26:49 +01:00
Gwendal Roué 1f4db99a37 Documentation fix 2021-03-17 20:26:10 +01:00
Gwendal Roué 076813826f CHANGELOG 2021-03-17 19:01:04 +01:00
Gwendal Roué fcb6049381 Test SQLLiteral protocols in practice 2021-03-17 18:21:44 +01:00
Gwendal Roué 4c88d792f0 Documentation 2021-03-14 14:13:29 +01:00
Gwendal Roué 9d64a32814 Improve SQLLiteral documentation 2021-03-14 13:26:16 +01:00
Gwendal Roué 77db650464 More SQLLiteral interpolation test 2021-03-14 13:08:10 +01:00
Gwendal Roué 0e8a42aedc Tests for interpretations of SQLLiteral
If those tests break, we have introduced a breaking change.
2021-03-14 12:57:15 +01:00
Gwendal Roué 8ad096ae35 Refactor column counting for improved testability 2021-03-14 11:49:35 +01:00
Gwendal Roué ac436a2770 Make SQLLiteral less painful to use 2021-03-14 11:09:29 +01:00
Gwendal Roué 0133ff9056 Merge pull request #938 from michaelkirk/patch-1
fix small typos
2021-03-13 07:56:31 +01:00
Michael Kirk 178fb8688a fix small typos 2021-03-12 15:53:35 -08:00
Gwendal Roué 0b5f7e960b [skip travis] Mention key-value tables as a valid alternative
Inspired from https://twitter.com/dhartbit/status/1370434943956959238
2021-03-12 19:30:42 +01:00
Gwendal Roué ae3c491661 Merge branch 'development' 2021-03-12 17:47:50 +01:00
Gwendal Roué 8548d7a727 v5.6.0 2021-03-12 17:12:41 +01:00
Gwendal Roué daab7aef2c Fix typo 2021-03-12 15:37:29 +01:00
Gwendal Roué ba9b4db197 Fix typo 2021-03-12 15:33:35 +01:00
Gwendal Roué cab795a4a9 Wording 2021-03-12 15:32:00 +01:00
Gwendal Roué b331a715ef CHANGELOG 2021-03-12 15:30:31 +01:00
Gwendal Roué 48e214b4b3 Link to demo app tests 2021-03-12 14:42:51 +01:00
Gwendal Roué 65beb24d41 Simplify 2021-03-12 14:33:01 +01:00
Gwendal Roué e1c7150714 Documentation 2021-03-12 14:26:43 +01:00
Gwendal Roué cc93f43ee4 Better introduction to DerivableRequest
Also reintroduce extensions to QueryInterfaceRequest
2021-03-12 14:24:47 +01:00
Gwendal Roué 33174fce8e Documentation 2021-03-12 14:00:31 +01:00
Gwendal Roué cb8611587c Fix Swiftlint warning 2021-03-12 13:48:41 +01:00
Gwendal Roué 6e7555514a More collection initializers from cursors
- support for minimumCapacity
- support for Dictionary (cursors with unique keys)
2021-03-12 13:48:25 +01:00
Gwendal Roué 8b1efb2c80 Single-Row Tables guide 2021-03-12 11:31:32 +01:00
Gwendal Roué 8388486289 TODO 2021-03-12 08:32:32 +01:00
Gwendal Roué c3dcd7636e Merge pull request #936 from groue/dev/more-eager-loading
Complete Associations and the DerivableRequest Protocol
2021-03-11 19:35:39 +01:00
Gwendal Roué 464b77bdcd Improve "Record Types Hide Intimate Database Details" 2021-03-10 13:25:25 +01:00
Gwendal Roué fe437fb7e3 Improve "Record Types Hide Intimate Database Details" 2021-03-10 13:21:25 +01:00
Gwendal Roué 1a2a6898eb Improve "Record Types Hide Intimate Database Details" 2021-03-10 13:07:16 +01:00
Gwendal Roué de2a37fb89 Improve "Record Types Hide Intimate Database Details" 2021-03-10 13:06:05 +01:00
Gwendal Roué 1d5604815d Improve "Record Types Hide Intimate Database Details" 2021-03-10 13:05:11 +01:00
Gwendal Roué 4de5059373 Improve "Record Types Hide Intimate Database Details" 2021-03-10 12:55:25 +01:00
Gwendal Roué 850040c51e Fix typo 2021-03-10 09:02:00 +01:00
Gwendal Roué eb0983facd Wording 2021-03-10 08:59:40 +01:00
Gwendal Roué 9e974a4c96 Fix typo 2021-03-10 08:58:39 +01:00
Gwendal Roué 609fcf6a6d CHANGELOG 2021-03-10 08:57:46 +01:00
Gwendal Roué 5e61d38272 Add a Record Types Hide Intimate Database Details chapter 2021-03-10 08:56:53 +01:00
Gwendal Roué cdbca5d215 Fix sample code 2021-03-09 08:29:14 +01:00
Gwendal Roué 9bda5fc41b Move the Further Refinements to Associations chapter 2021-03-09 08:27:29 +01:00
Gwendal Roué 04d35381a6 Documentation 2021-03-09 07:57:57 +01:00
Gwendal Roué 1f27e724c9 Open a door 2021-03-09 07:21:43 +01:00
Gwendal Roué b22afd7f17 CHANGELOG 2021-03-08 21:56:47 +01:00
Gwendal Roué ed3d1e1ac4 selectOnly() clears the isDistinct flag 2021-03-08 21:36:09 +01:00
Gwendal Roué 4521e6b37d Make filterPromise an optional promise instead of a promise of optional
This way, filterPromise and havingExpressionPromise have the same type
2021-03-08 21:25:27 +01:00
Gwendal Roué 42718db49d Documentation 2021-03-08 21:11:36 +01:00
Gwendal Roué e08df854dd Lower the tone about record responsabilities 2021-03-08 20:50:17 +01:00
Gwendal Roué f4b7d99aab Remove warning about associations that use CTEs 2021-03-08 19:59:47 +01:00
Gwendal Roué 4dd8042894 Make it possible to decode arrays of scalars from including(all:) 2021-03-08 14:21:35 +01:00
Gwendal Roué 4583bbfa90 Test for joined associations that use CTEs 2021-03-08 14:10:43 +01:00
Gwendal Roué a655974eb0 Let joined associations use CTEs 2021-03-08 14:10:38 +01:00
Gwendal Roué d4fc1d9566 Update documentation for the new Association/DerivableRequest powers 2021-03-08 08:36:32 +01:00
Gwendal Roué f9b554d00a Merge AggregateJoinableRequest into DerivableRequest
Also put distinct(), limit(_:offset:) and with(_:) into DerivableRequest
2021-03-08 07:55:20 +01:00
Gwendal Roué 6b733cfc0a Tests for including(all:) with distinct, limited, grouped, and cte-decorated associations 2021-03-07 20:32:21 +01:00
Gwendal Roué f0aec27095 AssociationToMany: distinct(), limit(_:offset:), with(_:) 2021-03-07 20:25:30 +01:00
Gwendal Roué 092b0d0e44 Move with(cte) methods to the file it belongs to 2021-03-07 19:58:15 +01:00
Gwendal Roué d2a22ddd97 Make sure joined associations do not use prefetched to-many features
One can't join a distinct, grouped, or limited association.
2021-03-07 19:56:04 +01:00
Gwendal Roué 9c6ff6a1c0 Simplifly association aggregates
We don't need any promise. We used to, but SQLExpression.fastPrimaryKey has been introduced since then.
2021-03-07 19:36:08 +01:00
Gwendal Roué a4dca3390a AggregateJoinableRequest is the new protocol that supports aggregate annotations
AssociationToMany is a subprotocol of AggregateJoinableRequest :-)
2021-03-07 19:15:09 +01:00
Gwendal Roué ea6a052b73 Merge all SQLRelation properties 2021-03-07 17:12:44 +01:00
Gwendal Roué f49fab0cff Merge SQLQuery into SQLRelation 2021-03-07 14:37:53 +01:00
Gwendal Roué 37faf0a1fd Upgrade obsolete documentation 2021-03-07 14:20:28 +01:00
Gwendal Roué 4b5a6b503a TODO 2021-03-07 13:12:28 +01:00
Gwendal Roué 2a85b1230b Merge pull request #934 from groue/dev/issue-932
Fix a crash in the ValueObservation publisher
2021-03-07 12:12:44 +01:00
Gwendal Roué 3eb17fdbb7 CHANGELOG 2021-03-07 12:11:50 +01:00
Gwendal Roué 5400217bb6 ReceiveValuesOnSubscription forwards cancellation
Fixes #932
2021-03-07 12:10:35 +01:00
Gwendal Roué 71083a5586 Merge pull request #933 from groue/dev/issue-931
Fix DatabaseMigrator.eraseDatabaseOnSchemaChange in the context of shared databases
2021-03-07 12:09:04 +01:00
Gwendal Roué 37279dfad2 CHANGELOG 2021-03-06 14:20:11 +01:00
Gwendal Roué 8be0976bd1 Fix #931 2021-03-06 14:01:56 +01:00
Gwendal Roué 7623a96034 Failing test for #931 2021-03-06 13:34:27 +01:00
Gwendal Roué 424df6dee3 TODO 2021-03-06 13:25:59 +01:00
Gwendal Roué 48b6faa45e Improve documentation of Configuration.prepareDatabase 2021-03-06 13:25:52 +01:00
Gwendal Roué bac7b6b0e5 Refactor function calls
and make it possible to express other DISTINCT aggregates than COUNT: SUM(DISTINCT ...), etc.
2021-03-06 13:25:25 +01:00
Gwendal Roué 174766925a Remove warning 2021-03-03 20:04:08 +01:00
Gwendal Roué 9d5cb15380 SQLExpression documentation & cleanup 2021-03-03 20:03:56 +01:00
Gwendal Roué 284ebbd3ef [skip travis] Update thank you notice 2021-03-03 14:09:23 +01:00
Gwendal Roué 3b6cf4c12b Merge branch 'development' 2021-03-03 13:00:39 +01:00
Gwendal Roué 2329a5c7b4 v5.5.0 2021-03-03 13:00:21 +01:00
Gwendal Roué 8f50d70703 Merge pull request #930 from groue/dev/issue-929
Fix SQL generation for `COLLATE`, `IN`, `NOT IN`
2021-03-03 07:56:14 +01:00
Gwendal Roué d2d515658e CHANGELOG 2021-03-02 20:21:51 +01:00
Gwendal Roué 72123494ca Add test for NOT IN and collated expressions 2021-03-02 20:16:15 +01:00
Gwendal Roué 7b81fd1bff Fix documentation for #929 2021-03-02 20:12:38 +01:00
Gwendal Roué 5ea7296e7a Add support for subquery.contains(collated expression) 2021-03-02 20:09:24 +01:00
Gwendal Roué 279b00f890 Fix failing tests for #929 2021-03-02 20:03:19 +01:00
Gwendal Roué 01d71d6f35 Failing tests for #929 2021-03-02 20:02:46 +01:00
Gwendal Roué 96df69b3fb Add fundamental test for #929 2021-03-02 19:06:18 +01:00
Gwendal Roué b17fce357d Merge pull request #925 from groue/dev/RowDecodingError
Foundation for decoding errors
2021-03-01 09:03:20 +01:00
Gwendal Roué 37dfd95ae1 Symmetry with StatementColumnConvertible 2021-02-26 19:31:41 +01:00
Gwendal Roué b834b9876d Data.fastDecodeNoCopyIfPresent can not fail 2021-02-26 18:51:14 +01:00
Gwendal Roué 7f48e66fdc Reduce inlined code 2021-02-26 18:50:47 +01:00
Gwendal Roué b7c57dc7f2 Attempt at clarifying the (complex) decoding api
The difficulty is due to fast decoding of StatementColumnConvertible, and non-copied Data, from raw SQLite statement.

We want it to be inlinable, and possible in nested rows.

Added missing tests for nested rows
2021-02-25 20:45:12 +01:00
Gwendal Roué cb2405a8b9 RowDecodingError 2021-02-21 14:21:04 +01:00
Gwendal Roué 4398777f07 TODO 2021-02-20 17:03:17 +01:00
Gwendal Roué 6e8285e4ec CHANGELOG 2021-02-20 13:02:30 +01:00
Gwendal Roué aceaaf24d2 Paranoid: Wrap DatabaseQueue.read in a transaction
This guarantees snapshot isolation even in case of external connections
2021-02-20 12:59:27 +01:00
Gwendal Roué 64bb63e304 CommonTableExpression has an implicit Row RowDecoder 2021-02-20 12:47:13 +01:00
Gwendal Roué a681ccf2b9 Fix: DatabaseQueue.read is throws, not rethrows 2021-02-20 11:55:19 +01:00
Gwendal Roué 8c8a25a73b Spot the possible improvement on SQLRelation children 2021-02-20 11:42:54 +01:00
Gwendal Roué d419d23368 Tests for SQLRelation children 2021-02-19 16:28:22 +01:00
Gwendal Roué 081500b5ce TODO 2021-02-19 13:26:18 +01:00
Gwendal Roué 7dd36ecc0f Tests for SQLRelation children 2021-02-19 07:36:33 +01:00
Gwendal Roué 10a16ac6f0 Rename .allNotPrefetched to .bridge 2021-02-18 08:42:01 +01:00
Gwendal Roué d7f61fa0f5 Documentation 2021-02-18 07:58:10 +01:00
Gwendal Roué 3665a533cf Add missing tests for has-many through association with three steps 2021-02-17 20:04:35 +01:00
Gwendal Roué c9332a8c9e Fix typo 2021-02-17 20:03:59 +01:00
Gwendal Roué e40534942c format 2021-02-17 18:19:52 +01:00
Gwendal Roué de52856cf3 Aliasing is not qualifying 2021-02-17 18:11:00 +01:00
Gwendal Roué 0dd345eb91 SQLQuery no longer depends on SQLExpressible and other high-level protocols 2021-02-17 18:00:53 +01:00
Gwendal Roué c4620aa587 SQLRelation no longer depends on SQLExpressible and _JoinableRequest
Those are one level up
2021-02-17 17:43:57 +01:00
Gwendal Roué bda63c70bf Document the type of variables 2021-02-17 13:51:23 +01:00
Gwendal Roué 3407715599 CHANGELOG 2021-02-17 13:47:15 +01:00
Gwendal Roué 7eaf579c18 Update CommonTableExpression documentation about the implicit Void RowDecoder 2021-02-17 13:44:51 +01:00
Gwendal Roué 488849535e CommonTableExpression has an implicit Void RowDecoder 2021-02-17 13:22:28 +01:00
Gwendal Roué 15b892af6e Implement filters with SQLExpression? instead of [SQLExpression]
Those arrays were introduced so that we can generate nicer sql: `a AND b AND c`, instead of `(a AND b) AND c`.

This flattening is provided by the && operator and `SQLExpression.associativeBinary`, so those arrays are no longer needed.
2021-02-17 08:45:57 +01:00
Gwendal Roué cceb24a1e5 Merge branch 'development' 2021-02-15 19:17:27 +01:00
Gwendal Roué bea454a0b9 v5.4.0 2021-02-15 19:16:06 +01:00
Gwendal Roué 276fb2d698 Performance tests: upgrade dependencies 2021-02-15 18:54:32 +01:00
Gwendal Roué 8e3046b00f Move Sequence.joined(operator:) back to SQLSpecificExpressible
`[1, 2, 3].joined(operator: .add)` is not supported. It would pollute autocompletion.

This commit fixes a regression introduced in 920417b.
2021-02-15 18:16:18 +01:00
Gwendal Roué 8a5790ed8b Move SQLSelectable and SQLOrderingTerm down from SQLExpressible to SQLSpecificExpressible 2021-02-15 14:01:42 +01:00
Gwendal Roué fd6f5ec525 CHANGELOG 2021-02-15 13:55:58 +01:00
Gwendal Roué 987d549ff0 Remove obsolete test in demo app 2021-02-15 07:59:48 +01:00
Gwendal Roué f57e724ef6 Merge pull request #922 from groue/experiments/enums
Refactor query interface implementation
2021-02-15 07:22:42 +01:00
Gwendal Roué 920417beb3 Replace protocols with enums 2021-02-14 18:28:15 +01:00
Gwendal Roué 2a016ac4f5 TODO 2021-02-12 18:47:37 +01:00
Gwendal Roué ba3a3f7c38 Move definition of TableRecord to CTE associations 2021-02-09 18:14:35 +01:00
Gwendal Roué ae6f5dd0f5 Extract ForeignKey 2021-02-09 18:14:35 +01:00
Gwendal Roué 7914805524 Remove TableRecord requirements for QueryInterfaceRequest aggregates 2021-02-09 18:14:35 +01:00
Gwendal Roué 5c2f113631 TODO 2021-02-08 13:07:02 +01:00
Gwendal Roué d3df3ed5ec Makefile: support for Xcode 12.4 and Big Sur
Bump min iOS and tvOS versions to 11.4 because Big Sur does not support older simulators:

$ xcrun simctl list runtimes
iOS 10.3 (10.3.1 - 14E8301) - com.apple.CoreSimulator.SimRuntime.iOS-10-3 (unavailable, The iOS 10.3 simulator runtime is not supported on hosts after macOS 10.15.99.)
tvOS 10.2 (10.2 - 14W260) - com.apple.CoreSimulator.SimRuntime.tvOS-10-2 (unavailable, The tvOS 10.2 simulator runtime is not supported on hosts after macOS 10.15.99.)
2021-02-07 17:23:10 +01:00
Gwendal Roué 40389ee102 Decouple associations from their origin database table
This allows us to create an association without providing the origin table name, and thus to build association without TableRecord.
2021-02-07 16:01:34 +01:00
Gwendal Roué edc8c2aeea Fix sample code 2021-01-30 09:52:35 +01:00
Gwendal Roué f9ad87e54f Documentation 2021-01-29 19:49:55 +01:00
Gwendal Roué a6a10270a0 TODO 2021-01-29 08:11:16 +01:00
Gwendal Roué 9a1ff5e9a0 BRAG 2021-01-28 19:09:46 +01:00
Gwendal Roué 7151648279 Cleanup demo apps 2021-01-28 08:44:34 +01:00
Gwendal Roué 921c629a5e Documentation: Adding support for missing SQL functions or operators 2021-01-28 08:43:14 +01:00
Gwendal Roué 25b2a0392d SQL interpolation supports embedding collations into SQL literals 2021-01-28 08:39:40 +01:00
Gwendal Roué cb7aa3c14f TODO 2021-01-28 08:36:14 +01:00
451 changed files with 45304 additions and 14325 deletions

No files matched your search

+7 -5
View File
@@ -3,10 +3,12 @@
### Pull Request Checklist
<!--
Please verify that your pull request checks those boxes:
Please check the boxes that apply to your pull request:
-->
- [ ] This pull request is submitted against the `development` branch.
- [ ] Inline documentation has been updated.
- [ ] README.md or another dedicated guide has been updated.
- [ ] Changes are tested.
- [ ] CONTRIBUTING: You have read https://github.com/groue/GRDB.swift/blob/master/CONTRIBUTING.md
- [ ] BRANCH: This pull request is submitted against the `development` branch.
- [ ] DOCUMENTATION: Inline documentation has been updated.
- [ ] DOCUMENTATION: README.md or another dedicated guide has been updated.
- [ ] TESTS: Changes are tested.
- [ ] TESTS: The `make smokeTest` terminal command runs without failure.
+19
View File
@@ -0,0 +1,19 @@
name: CI
on:
push:
branches: [ master, development ]
pull_request:
branches: [ master, development ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
+4
View File
@@ -106,9 +106,13 @@ Podfile.lock
# SPM
.build
.swiftpm/
GRDB.xcworkspace/xcshareddata/swiftpm
#Package.resolved
Tests/SPM/Packages
# Ruby
.ruby-version
# Test products
Tests/products
+120 -120
View File
@@ -26,126 +26,6 @@ git:
jobs:
include:
###########################################
## Test GRDB Xcode 12.2
- name: "Test GRDB Xcode 12.2 - GRDBOSX - Swift 5.3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBOSX_maxSwift
- name: "Test GRDB Xcode 12.2 - GRDBOSX - Swift 5.2"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBOSX_minSwift
- name: "Test GRDB Xcode 12.2 - GRDBWatchOS"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBWatchOS
- name: "Test GRDB Xcode 12.2 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12.2 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBiOS_minTarget
- name: "Test GRDB Xcode 12.2 - GRDBtvOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12 - GRDBtvOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBtvOS_minTarget
- name: "Test GRDB Xcode 12.2 - SPM"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_SPM
###########################################
## Test GRDBCustom Xcode 12.2
- name: "Test GRDBCustom Xcode 12.2 - GRDBOSX"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteOSX
- name: "Test GRDBCustom Xcode 12.2 - GRDBiOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
- name: "Test GRDBCustom Xcode 12.2 - GRDBiOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test SQLCipher Xcode 12.2
- name: "Test SQLCipher Xcode 12.2 - SQLCipher 3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_SQLCipher3
- name: "Test SQLCipher Xcode 12.2 - SQLCipher 4"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_framework_SQLCipher4
###########################################
## Test Installation Xcode 12.2
# Manual Install
- name: "Test Installation Xcode 12.2 - Manual Install"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_manual
# Travis is much too slow, and always fail this job
# # CocoaPods Lint
# - name: "Test Installation Xcode 12.2 - CocoaPods Lint"
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode12.2
# script: make test_CocoaPodsLint_GRDB
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.2 - CocoaPods Framework"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_GRDB_CocoaPods_framework
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.2 - CocoaPods Static"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.2
script: make test_install_GRDB_CocoaPods_static
# 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
@@ -159,3 +39,123 @@ jobs:
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11.4
script: make test_framework_GRDBiOS_minTarget
###########################################
## Test GRDB Xcode 12.5
- name: "Test GRDB Xcode 12.5 - GRDBOSX - Swift 5.3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBOSX_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBOSX - Swift 5.2"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBOSX_minSwift
- name: "Test GRDB Xcode 12.5 - GRDBWatchOS"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBWatchOS
- name: "Test GRDB Xcode 12.5 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBiOS_minTarget
- name: "Test GRDB Xcode 12.5 - GRDBtvOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBtvOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBtvOS_minTarget
- name: "Test GRDB Xcode 12.5 - SPM"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_SPM
###########################################
## Test GRDBCustom Xcode 12.5
- name: "Test GRDBCustom Xcode 12.5 - GRDBOSX"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteOSX
- name: "Test GRDBCustom Xcode 12.5 - GRDBiOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
- name: "Test GRDBCustom Xcode 12.5 - GRDBiOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test SQLCipher Xcode 12.5
- name: "Test SQLCipher Xcode 12.5 - SQLCipher 3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_SQLCipher3
- name: "Test SQLCipher Xcode 12.5 - SQLCipher 4"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_SQLCipher4
###########################################
## Test Installation Xcode 12.5
# Manual Install
- name: "Test Installation Xcode 12.5 - Manual Install"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_manual
# Travis is much too slow, and always fail this job
# # CocoaPods Lint
# - name: "Test Installation Xcode 12.5 - CocoaPods Lint"
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode12.5
# script: make test_CocoaPodsLint_GRDB
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.5 - CocoaPods Framework"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_GRDB_CocoaPods_framework
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.5 - CocoaPods Static"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_GRDB_CocoaPods_static
# SPM Install
- name: "Test Installation Xcode 12.5 - SPM Package"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_SPM_Package
# SPM Install
- name: "Test Installation Xcode 12.5 - SPM Package in Xcode Project"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_SPM_Project
# Custom SQLite Install
- name: "Test Installation Xcode 12.5 - Custom SQLite"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_customSQLite
+6
View File
@@ -4,6 +4,12 @@ Here is a list of people who were happy to meet GRDB :-)
---
https://twitter.com/swiftkarim/status/1354753451377483781
> I cannot recommend GRDB enough. It works well with Swift and eliminates whole classes of potential programming errors that can be made with Core Data. Also being able to use raw SQL queries if needed can be extremely useful!
---
https://twitter.com/peres/status/1352219836508729346
> Just the occasional reminder that GRDB and its documentation is the gold standard. That's it.
+361 -2
View File
@@ -7,6 +7,25 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
#### 5.x Releases
- `5.22.x` Releases - [5.22.0](#5220)
- `5.21.x` Releases - [5.21.0](#5210)
- `5.20.x` Releases - [5.20.0](#5200)
- `5.19.x` Releases - [5.19.0](#5190)
- `5.18.x` Releases - [5.18.0](#5180)
- `5.17.x` Releases - [5.17.0](#5170)
- `5.16.x` Releases - [5.16.0](#5160)
- `5.15.x` Releases - [5.15.0](#5150)
- `5.14.x` Releases - [5.14.0](#5140)
- `5.13.x` Releases - [5.13.0](#5130)
- `5.12.x` Releases - [5.12.0](#5120)
- `5.11.x` Releases - [5.11.0](#5110)
- `5.10.x` Releases - [5.10.0](#5100)
- `5.9.x` Releases - [5.9.0](#590)
- `5.8.x` Releases - [5.8.0](#580)
- `5.7.x` Releases - [5.7.0](#570) | [5.7.1](#571) | [5.7.2](#572) | [5.7.3](#573) | [5.7.4](#574)
- `5.6.x` Releases - [5.6.0](#560)
- `5.5.x` Releases - [5.5.0](#550)
- `5.4.x` Releases - [5.4.0](#540)
- `5.3.x` Releases - [5.3.0](#530)
- `5.2.x` Releases - [5.2.0](#520)
- `5.1.x` Releases - [5.1.0](#510)
@@ -68,6 +87,346 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
- [0.110.0](#01100), ...
---
## 5.22.1
Released March 22, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.22.0...v5.22.1)
- **Fixed** a 5.22.0 regression: [#1194](https://github.com/groue/GRDB.swift/issues/1194) ValueObservation could deadlock when the database is configured with a serial target DispatchQueue.
## 5.22.0
Released March 22, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.21.0...v5.22.0)
- **New**: [#1186](https://github.com/groue/GRDB.swift/pull/1186) by [@benrb](https://github.com/benrb): DatabaseError provide error message as localizedFailureReason
- **Breaking Change**: [#1183](https://github.com/groue/GRDB.swift/pull/1183) by [@groue](https://github.com/groue): Starting a ValueObservation keeps a strong reference on the database connection.
## 5.21.0
Released February 6, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.20.0...v5.21.0)
- **New**: [#1165](https://github.com/groue/GRDB.swift/pull/1165) by [@guidedways](https://github.com/guidedways): Support dynamic linking via Swift Package Manager
- **Breaking Change**: [#1164](https://github.com/groue/GRDB.swift/pull/1164) by [@groue](https://github.com/groue): Drop experimental async apis from DatabaseMigrator
## 5.20.0
Released February 1, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.19.0...v5.20.0)
- **Fixed**: Fixed a bug of `including(all:)` for composite foreign keys and limited requests.
- **Fixed**: [#1162](https://github.com/groue/GRDB.swift/pull/1162) by [@groue](https://github.com/groue): Fix truncate optimization handling.
- **New**: [#1160](https://github.com/groue/GRDB.swift/pull/1160) by [@groue](https://github.com/groue): Hide statement arguments by default.
- **New**: [#1161](https://github.com/groue/GRDB.swift/pull/1160) by [@groue](https://github.com/groue): Target DispatchQueue for non-read-only database connections.
- **Documentation Update**: The [Database Configuration](README.md#database-configuration) chapter explains how to opt in for public statement arguments in DEBUG builds.
## 5.19.0
Released January 19, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.18.0...v5.19.0)
- **New**: [#1144](https://github.com/groue/GRDB.swift/pull/1144) by [@TimAEllis](https://github.com/TimAEllis): Add drop column support
- **Fixed**: [#1139](https://github.com/groue/GRDB.swift/pull/1139) by [@groue](https://github.com/groue): Deal with authorization callbacks from more cursors
- **Fixed**: [#1149](https://github.com/groue/GRDB.swift/pull/1149) by [@BB9z](https://github.com/BB9z): Fix typos
## 5.18.0
Released January 9, 2022 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.17.0...v5.18.0)
- **New**: [#1075](https://github.com/groue/GRDB.swift/pull/1075) by [@mallman](https://github.com/mallman): Progress-reporting database backups
- **New**: [#1129](https://github.com/groue/GRDB.swift/pull/1129) by [@groue](https://github.com/groue): Detached columns
- **New**: [#1132](https://github.com/groue/GRDB.swift/pull/1132) by [@groue](https://github.com/groue): Bump custom SQLite builds v3.37.2
- **New**: [#1133](https://github.com/groue/GRDB.swift/pull/1133) by [@groue](https://github.com/groue): Support for STRICT tables
- **Fixed**: [#1120](https://github.com/groue/GRDB.swift/pull/1120) by [@jnross](https://github.com/jnross): Fix typos
- **Fixed**: [#1121](https://github.com/groue/GRDB.swift/pull/1121) by [@byohay](https://github.com/byohay): Quote PROJECT_DIR and SRCROOT environment variables
- **Fixed**: [#1128](https://github.com/groue/GRDB.swift/pull/1128) by [@groue](https://github.com/groue): Deal with authorization callbacks from cursors of FetchableRecord
- **Documentation Update**: A new [Embedding SQL in Query Interface Requests](README.md#embedding-sql-in-query-interface-requests) chapter describes the ways to leverage your SQL skills and extend GRDB apis.
## 5.17.0
Released December 14, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.16.0...v5.17.0)
- **New**: :star: [#1079](https://github.com/groue/GRDB.swift/pull/1079) by [@groue](https://github.com/groue): Async / Await
- **New**: `DatabaseRegion(table: tableName)` is deprecated. Use `Table(tableName)` instead.
- **New**: The `ABS` and `LENGTH` SQL functions are now available on association aggregates, through `abs(aggregate)` and `length(aggregate)`.
- **New**: Support for the [`TOTAL` aggregate function](https://www.sqlite.org/lang_aggfunc.html#sumunc). You can use `total` in Swift, at all places `sum` is available.
- **New**: `ValueObservation.removeDuplicates(by:)` with a closure argument.
- **New**: Testing for the existence of an associated record with `TableAlias.exists` now supports associated views, and associated tables WITHOUT ROWID that have a compound primary key.
- **Fixed**: `Database.primaryKey(_:)` throws when given the name of a view.
- **Documentation Update**: :star: The [Concurrency Guide](Documentation/Concurrency.md) was updated for the new support for asynchronous Swift.
- **Documentation Update**: :star: [GRDBAsyncDemo](Documentation/DemoApps/GRDBAsyncDemo/README.md) is a new SwiftUI demo app that uses the new async apis.
- **Documentation Update**: A new FAQ gives hints for avoiding a [Mutation of captured var in concurrently-executing code](README.md##mutation-of-captured-var-in-concurrently-executing-code) compiler error.
- **Documentation Update**: [#1107](https://github.com/groue/GRDB.swift/pull/1107) by [@tcwalther](https://github.com/tcwalther): Fix docstring for Database.create(index: ...)
- **Documentation Update**: [#1110](https://github.com/groue/GRDB.swift/pull/1110) by [@maxhumber](https://github.com/maxhumber): Minor changes to a tip in the README
## 5.16.0
Released December 5, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.15.0...v5.16.0)
- **New**: [#1106](https://github.com/groue/GRDB.swift/pull/1106) by [@groue](https://github.com/groue): Sugar for fetching only a few columns of associated records
- **Documentation Update**: The [Joining And Prefetching Associated Records](Documentation/AssociationsBasics.md#joining-and-prefetching-associated-records) chapter was fully rewritten. The joining methods `including(required:)` and others are much more detailed, with an exploration of frequent use cases.
- **Documentation Update**: The [Joining And Prefetching Associated Records](Documentation/AssociationsBasics.md#joining-and-prefetching-associated-records) chapter introduces the new `annotated(withRequired:)` and `annotated(withOptional:)` joining methods.
- **Documentation Update**: The new [Choosing a Joining Method Given the Shape of the Decoded Type](Documentation/AssociationsBasics.md#choosing-a-joining-method-given-the-shape-of-the-decoded-type) chapter helps choosing a joining method, given the shape of the fetched data.
## 5.15.0
Released December 2, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.14.0...v5.15.0)
- **Fixed**: `ValueObservation` now always fetches fresh values in an isolated fashion. This prevents all risks of fetching inconsistent data even if an external connection modifies the database.
- **New**: `Table` now conforms to `DatabaseRegionConvertible`. You can write `DatabaseRegionObservation(tracking: Table("player"))`.
- **New**: [#1102](https://github.com/groue/GRDB.swift/pull/1102) by [@groue](https://github.com/groue): Explicit tracked region for ValueObservation
## 5.14.0
Released November 25, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.13.0...v5.14.0)
- **Fix**: `ForeignKeyViolation.failureDescription(_:)` now accepts table names that require quoting.
- **Fix**: Add missing `public` qualifier on `ForeignKeyViolation` properties.
- **New**: `ForeignKeyViolation.databaseError(_:)` turns a foreign key violation into a `DatabaseError`.
- **Documentation Update**: the demo apps were modernized for iOS 15+. The SwiftUI demo app now uses the [GRDBQuery](https://github.com/groue/GRDBQuery) package in order to update its views according to the database content.
## 5.13.0
Released November 7, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.12.0...v5.13.0)
- **Breaking Change**: [#1076](https://github.com/groue/GRDB.swift/pull/1076) by [@groue](https://github.com/groue): Require Swift 5.3 and Xcode 12
- **New**: :star: [#1088](https://github.com/groue/GRDB.swift/pull/1088) by [@groue](https://github.com/groue): Shared ValueObservation
- **New**: :star: [#1095](https://github.com/groue/GRDB.swift/pull/1095) by [@groue](https://github.com/groue): Precise foreign key checks for migrations
- **New**: [#1078](https://github.com/groue/GRDB.swift/pull/1078) by [@groue](https://github.com/groue): Non-mutating persistence methods `saved` and `inserted`, and existence-checking methods `isEmpty` and `exists`
- **New**: `DatabasePool.erase()` prevents concurrent reads until it has completed.
- **New**: The `close()` method allows precise closing of database connections.
- **New**: Filtering records by single-column primary key now properly encodes dates and uuids according to the customized strategies (`filter(id:)`, `deleteAll(_:keys:)`, etc.)
- **New**: `DatabaseUUIDEncodingStrategy.lowercaseString` can encode UUID as a lowercased string. For clarity, the `string` strategy has been deprecated and renamed `uppercaseString`.
- **Documentation Update**: :star: The [Concurrency Guide](Documentation/Concurrency.md) got a major overhaul.
- **Documentation Update**: :star: A new [ValueObservation Sharing](README.md#valueobservation-sharing) chapter describes how to share database observations and spare database resources.
- **Documentation Update**: :star: The [Migrations](Documentation/Migrations.md) guide tells how you can mitigate slow foreign key checks during schema changes.
- **Documentation Update**: The [Date and UUID Coding Strategies](README.md#date-and-uuid-coding-strategies) chapter describes the new support for date and uuid primary key coding in requests by single-column primary key.
- **Documentation Update**: A new [Testing for Record Existence](README.md#testing-for-record-existence) chapter describes the new `request.isEmpty(_:)`, `Record.exists(_:id:)` and `Record.exists(_:key:)` methods.
## 5.12.0
Released September 25, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.11.0...v5.12.0)
- **Breaking Change**: Minimum iOS version is now iOS 11.0, and 32-bits devices are no longer supported. This fixes issues introduced by Xcode 13 ([#1033](https://github.com/groue/GRDB.swift/issues/1033), [#1059](https://github.com/groue/GRDB.swift/issues/1059)).
- **New**: `FTS3Pattern(matchingAllPrefixesIn:)` and `FTS5Pattern(matchingAllPrefixesIn:)` let you build full-text search patterns suitable for prefix queries.
- **New**: `FTS3.tokenize(_:)` and `FTS5Tokenizer.tokenize(_:)` let you tokenize input strings.
- **Documentation Update**: Full-text search documentation was updated for the new search pattern initializers ([FTS3/4](Documentation/FullTextSearch.md#fts3pattern), [FTS5](Documentation/FullTextSearch.md#fts5pattern)), and tokenization methods ([FTS3/4](Documentation/FullTextSearch.md#fts3-and-fts4-tokenization), [FTS5](Documentation/FullTextSearch.md#fts5-tokenization)).
## 5.11.0
Released September 3, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.10.0...v5.11.0)
- **Fixed**: Version 5.10.0, when embedded as an Xcode project, would enable the FTS5 full-text engine on system versions that do not provide it.
- **New**: [#1046](https://github.com/groue/GRDB.swift/pull/1046) by [@groue](https://github.com/groue): Improve performance of by-index row decoding
- **New**: [#1029](https://github.com/groue/GRDB.swift/pull/1029) by [@sberrevoets](https://github.com/sberrevoets), [@groue](https://github.com/groue): Column coding strategies for Codable records
## 5.10.0
Released August 22, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.9.0...v5.10.0)
- **New**: [#1036](https://github.com/groue/GRDB.swift/pull/1036) by [@groue](https://github.com/groue): Restore minimal CI tests
- **New**: [#1037](https://github.com/groue/GRDB.swift/pull/1037) by [@groue](https://github.com/groue): Support BUILD_LIBRARY_FOR_DISTRIBUTION
- **New**: [#1038](https://github.com/groue/GRDB.swift/pull/1038) by [@GetToSet](https://github.com/GetToSet): Add match operator in ColumnExpression for FTS5
- **New**: With Swift 5.5+, enhance access to `Column.rowID`. Row and PersistenceContainer subscripts now accept `row[.rowID]` and `container[.rowID]` ([SE-0299](https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md))
- **Documentation Update**: A new [Combine and Data Consistency](Documentation/Combine.md#combine-and-data-consistency) chapter explains how to make sure database publishers do not break important database invariants.
## 5.9.0
Released August 15, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.8.0...v5.9.0)
- **Fixed**: [#980](https://github.com/groue/GRDB.swift/pull/980) by [@jroselightricks](https://github.com/jroselightricks): Fix spelling
- **Fixed**: [#989](https://github.com/groue/GRDB.swift/pull/989) by [@pp5x](https://github.com/pp5x): FTS: add support of ifNotExists in synchronize()
- **Fixed**: [#999](https://github.com/groue/GRDB.swift/issues/999): `request(for: association)` no longer crashes when the foreign key contains a NULL value.
- **Fixed**: [#1025](https://github.com/groue/GRDB.swift/issues/1025) by [@mattgallagher](https://github.com/mattgallagher): Fix ValueObservation crash
- **Fixed**: Fix thread unsafety in `ValueObservation.print()`
- **New**: The `selectID()` method is now available for [Identifiable Records](README.md#identifiable-records)
- **New**: Cached prepared statements can profit from [SQL Interpolation](Documentation/SQLInterpolation.md):
```swift
let updateStatement = try db.cachedStatement(literal: "INSERT ...")
// ~~~~~~~
```
- **New**: [#993](https://github.com/groue/GRDB.swift/pull/993) by [@groue](https://github.com/groue): QueryInterfaceRequest builder with dynamic table/view name
- **New**: Types that adopt both `DatabaseValueConvertible` and `Codable` now profit from automatic JSON encoding and decoding.
- **New**: [#1010](https://github.com/groue/GRDB.swift/pull/1010) by [@tternes](https://github.com/tternes): Add VACUUM INTO Support
- **New**: [#1012](https://github.com/groue/GRDB.swift/pull/1012) by [@ZevEisenberg](https://github.com/ZevEisenberg): Add brackets to urls in doc comments to make them clickable
- **New**: [#1019](https://github.com/groue/GRDB.swift/pull/1019) by [@groue](https://github.com/groue): Merge prepared statement types, and introduce statement cursor
- **Documentation Update**: The [Requests](README.md#requests) chapter was updated for the new `Table` type that can build requests without any record type.
- **Documentation Update**: The [Custom Value Types](README.md#custom-value-types) chapter was extended about the new support for codable value types encoded as JSON arrays or objects.
- **Documentation Update**: The [Fetching Methods](README.md#fetching-methods) and [Prepared Statements](README.md#prepared-statements) chapters have been updated for the unique `Statement` class, and the new `Database.allStatements()` method.
## 5.8.0
Released May 16, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.7.4...v5.8.0)
- **New**: Support for the `ESCAPE` clause with the `LIKE` operator.
- **New**: You can now define an `SQLRequest` without any generic qualifier (which defaults to `Row`):
```swift
let request = SQLRequest("SELECT ...")
```
- **New**: [#967](https://github.com/groue/GRDB.swift/pull/967) by [@steipete](https://github.com/steipete): Make SelectStatement conform to CustomStringConvertible
- **Fixed**: The `DerivableRequest.limit(_:offset:)` method was ill-designed, and removed from the documentation. It is unfortunately impossible to deprecate it without triggering warnings on the legit use cases (on `QueryInterfaceRequest`).
- **Fixed**: [#973](https://github.com/groue/GRDB.swift/pull/973): Restore access to attached databases from record types
- **Fixed**: [#974](https://github.com/groue/GRDB.swift/pull/974): Provide access to included associations when root table is not selected
- **Documentation Update**: A new [Query Interface Organization](Documentation/QueryInterfaceOrganization.md) document reveals the relationship between the various components of the GRDB query builder.
## 5.7.4
Released April 11, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.7.3...v5.7.4)
- **New**: [#953](https://github.com/groue/GRDB.swift/pull/953): Refactor the SwiftUI demo app
- **Fixed**: [#955](https://github.com/groue/GRDB.swift/pull/955) by [@steipete](https://github.com/steipete): Robustness of @Query in the SwiftUI demo app
- **Fixed**: [#956](https://github.com/groue/GRDB.swift/pull/956): Fix case-sensitivity of region-based database observation
- **New**: [#958](https://github.com/groue/GRDB.swift/pull/958) by [@chrisballinger](https://github.com/chrisballinger): Always add userInfo to databaseJSONDecoder and databaseJSONEncoder
- **New**: [#960](https://github.com/groue/GRDB.swift/pull/960) by [@MartinP7r](https://github.com/MartinP7r): Add tests for userInfo being applied to database encoder/decoder
## 5.7.3
Released April 5, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.7.2...v5.7.3)
- **Fixed**: [#950](https://github.com/groue/GRDB.swift/pull/950) by [@MartinP7r](https://github.com/MartinP7r): Fix memory consumption when encoding JSON columns
- **Fixed**: [#951](https://github.com/groue/GRDB.swift/pull/951) by [@alexwlchan](https://github.com/alexwlchan): Fix documentation typo
- **Fixed**: [#952](https://github.com/groue/GRDB.swift/pull/952) by [@holsety](https://github.com/holsety): Fix documentation typo
- **Documentation Update**: [#953](https://github.com/groue/GRDB.swift/pull/953): Refactor the SwiftUI demo app
#### 5.7.2
- **Fixed**: Really fix breaking change and restore `SQLLiteral` as a deprecated alias for `SQL`.
#### 5.7.1
- **Fixed**: Fix breaking change and restore `SQLLiteral` as a deprecated alias for `SQL`.
## 5.7.0
Released March 28, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.6.0...v5.7.0)
- **New**: [#947](https://github.com/groue/GRDB.swift/pull/947) by [@chrisballinger](https://github.com/chrisballinger): Allow access to Encoder from KeyedEncodingContainer
- **New**: Record types that adopt the standard [Identifiable](https://developer.apple.com/documentation/swift/identifiable) protocol have gained type-safe methods that deal with the primary key. For example:
```swift
let player = try Player.fetchOne(db, id: 42)
try Player.deleteAll(db, ids: [1, 2, 3])
```
See the new [Identifiable Records](README.md#identifiable-records) documentation chapter for more information.
- **New**: `SQLLiteral` has more use cases than initialy expected, and is renamed `SQL`.
- **New**: [`SQL` literal](Documentation/SQLInterpolation.md#sql-literal) can now be directly used as an expression, an ordering term, or a selection item.:
```swift
let name = "O'Brien"
let request = Player
.select(SQL("id, score"), ...)
.filter(SQL("name = \(name)") && ...)
.order(SQL("score DESC"), ...)
```
- **New**: Table creation DSL now supports columns and constraints defined with raw SQL String or [SQL literal](Documentation/SQLInterpolation.md#sql-literal):
```swift
try db.create(table: "player") do { t in
t.column(sql: "id INTEGER PRIMARY KEY AUTOINCREMENT")
t.column(literal: "name TEXT DEFAULT \("Anonymous")")
t.constraint(sql: "CHECK (LENGTH(name) > 0)")
t.constraint(literal: "CHECK (LENGTH(name) <= \(100))")
}
```
- **New**: Prepared statements can profit from [SQL Interpolation](Documentation/SQLInterpolation.md):
```swift
let updateStatement = try db.makeUpdateStatement(literal: "INSERT ...")
let selectStatement = try db.makeSelectStatement(literal: "SELECT ...")
// ~~~~~~~
```
- **New**: [DatabaseMigrator](Documentation/Migrations.md#asynchronous-migrations) can now asynchronously migrate a database. A Combine publisher is also available.
- **New**: Added support for the `EXISTS` and `NOT EXISTS` subquery operators. See the updated [SQL Operators](README.md#sql-operators) documentation.
- **New**: `Foundation.Decimal` can now be stored in the database, and all Foundation number types can be decoded from decimal numbers stored as strings. See the [NSNumber, NSDecimalNumber, and Decimal](README.md#nsnumber-nsdecimalnumber-and-decimal) chapter for details.
## 5.6.0
Released March 12, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.5.0...v5.6.0)
- **Fixed**: [#933](https://github.com/groue/GRDB.swift/pull/933): Fix DatabaseMigrator.eraseDatabaseOnSchemaChange in the context of shared databases
- **Fixed**: [#934](https://github.com/groue/GRDB.swift/pull/934): Fix a crash in the ValueObservation publisher
- **New**: [#936](https://github.com/groue/GRDB.swift/pull/936): Complete Associations and the DerivableRequest Protocol
- **New**: Database cursors can feed more standard Swift collections: `Array(cursor, minimumCapacity: ...)`, `Dictionary(uniqueKeysWithValues: cursor)`, etc (see [Cursors](README.md#cursors)).
- **Documentation update**: The [Associations Guide](Documentation/AssociationsBasics.md) has gained a new [Further Refinements to Associations](Documentation/AssociationsBasics.md#further-refinements-to-associations) chapter which shows the new association methods brought by [#936](https://github.com/groue/GRDB.swift/pull/936).
- **Documentation update**: The [Good Practices for Designing Record Types](Documentation/GoodPracticesForDesigningRecordTypes.md) guide has an updated [Define Record Requests](Documentation/GoodPracticesForDesigningRecordTypes.md#define-record-requests) chapter, now that the `DerivableRequest` protocol has access to `limit`, `distinct`, `group`, `having`, association aggregates, and common table expressions.
- **Documentation update**: The [Good Practices for Designing Record Types](Documentation/GoodPracticesForDesigningRecordTypes.md) guide has a new chapter of good practices: [Record Types Hide Intimate Database Details](Documentation/GoodPracticesForDesigningRecordTypes.md#record-types-hide-intimate-database-details).
- **Documentation update**: A new [Single-Row Tables](Documentation/SingleRowTables.md) guide provides guidance for designing tables that store configuration values, user preferences, and generally some global application state.
## 5.5.0
Released March 3, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.4.0...v5.5.0)
- **New**: You can now define common table expressions without any generic qualifier (which defaults to `Row`):
```swift
let cte = CommonTableExpression(...)
```
The [Common Table Expressions Guide](Documentation/CommonTableExpressions.md) was updated accordingly.
- **New**: `DatabaseQueue` reading methods are now wrapped in a deferred transaction. This guarantees snapshot isolation in case of concurrent writes performed by external connections, and makes `DatabaseQueue` a type suitable for shared databases.
- **Fixed**: `DatabaseQueue.read` is now declared `throws` instead of `rethrows`.
- **Fixed**: [#930](https://github.com/groue/GRDB.swift/pull/930): Fix SQL generation for `COLLATE`, `IN`, `NOT IN`
## 5.4.0
Released February 15, 2021 &bull; [diff](https://github.com/groue/GRDB.swift/compare/v5.3.0...v5.4.0)
- **Breaking Change**: The query interface was refactored and some types such as `SQLExpression` are no longer a protocol.
This may break some applications that rely on Swift type inference, such as in the following example:
```swift
// No longer compiles
let values = [Column("score"), Column("score") + Column("bonus")]
```
The fix is to add an explicit declaration of the desired type:
```swift
// A possible fix
let values: [SQLExpressible] = [Column("score"), Column("score") + Column("bonus")]
```
Occurrences of such code breakage should be very rare.
- **New**: [SQL Interpolation](Documentation/SQLInterpolation.md) supports embedding collations into SQL literals:
```swift
let request: SQLRequest<Player> = "SELECT * FROM player ORDER BY email COLLATION \(.nocase)"
let request: SQLRequest<Player> = "SELECT * FROM player ORDER BY name COLLATION \(.localizedCompare)"
```
- **Documentation update**: [Adding support for missing SQL functions or operators](README.md#adding-support-for-missing-sql-functions-or-operators) explains how to extend the query interface when needed.
- **Documentation update**: The [Demo Applications](Documentation/DemoApps/) now provide tests for the database access layer.
## 5.3.0
@@ -133,7 +492,7 @@ Released September 27, 2020 &bull; [diff](https://github.com/groue/GRDB.swift/co
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.
- **Fixed**: [#838](https://github.com/groue/GRDB.swift/issues/838): Have indexed columns inherit the `ifNotExists` flag from table creation.
## 5.0.0-beta.11
@@ -5595,7 +5954,7 @@ Record ([documentation](https://github.com/groue/GRDB.swift#record-class)):
- `Record.reload()` has been removed. You have to provide your own implementation, should you need reloading.
- `Record.init(row: Row)` has been renamed `Record.init(_ row: Row)` (unlabelled row argument).
- `Record.updateFromRow()` has been removed. Override `init(_ row: Row)` instead.
- `Record.didInsertWithRowID(_:forColumn:)` should be overriden by Record subclasses that are interested in their row ids.
- `Record.didInsertWithRowID(_:forColumn:)` should be overridden by Record subclasses that are interested in their row ids.
- `Record.databaseEdited` has been renamed `hasPersistentChangedValues`.
- `Record.databaseChanges` has been renamed `persistentChangedValues` and now returns `[String: DatabaseValue?]`, the dictionary of old values for changed columns.
+99 -328
View File
@@ -1,328 +1,99 @@
Contributing to GRDB
====================
**Thank you for coming!**
This guide is a set of tips and guidelines for contributing to the GitHub repository [groue/GRDB.swift](https://github.com/groue/GRDB.swift).
- [Report Bugs]
- [Ask Questions]
- [Suggest an Enhancement]
- [Submit a Pull Request]
- [Sponsoring and Professional Support]
- [Suggested Contributions]
- [Non-Goals]
### Report Bugs
Please make sure the bug is not already reported by searching existing [issues](https://github.com/groue/GRDB.swift/issues).
If you're unable to find an existing issue addressing the problem, [open a new one](https://github.com/groue/GRDB.swift/issues/new). Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
### Ask Questions
The information you are looking for is maybe already available. Check out:
- the [FAQ](README.md#faq)
- the [general documentation](README.md#documentation)
- the [answered questions](https://github.com/groue/GRDB.swift/issues?utf8=✓&q=label%3Aquestion+)
If not, your questions are welcome in the [GRDB forums](https://forums.swift.org/c/related-projects/grdb), or in a new [GitHub issue](https://github.com/groue/GRDB.swift/issues/new).
### Suggest an Enhancement
Your idea may already be listed in [Suggested Contributions], waiting for someone to pick it up.
If not, contact [@groue](http://twitter.com/groue) on Twitter, or [open a new issue](https://github.com/groue/GRDB.swift/issues/new).
### Submit a Pull Request
Discuss your idea first, so that your changes have a good chance of being merged in.
Submit your pull request against the `development` branch.
Pull requests that include tests for modified and new functionalities, inline documentation, and relevant updates to the main README.md are merged faster, because you won't have to wait for somebody else to complete your contribution.
### Sponsoring and Professional Support
GRDB is free. It is openly developed by its contributors, on their free time, according to their will, needs, and availability. It is not controlled by any company.
When you have specific development or support needs, and are willing to financially contribute to GRDB, please send an email to [Gwendal Roué](mailto:gr@pierlis.com) so that we can enter a regular business relationship through the [Pierlis](http://pierlis.com/) company, based in Paris, France.
## Suggested Contributions
You'll find below various ideas for enhancing and extending GRDB, in various areas. Your ideas can be added to this list: [Suggest an Enhancement].
Legend:
- :baby: **Starter Task**: get familiar with GRDB internals
- :muscle: **Hard**: there are implementation challenges
- :pencil: **Documentation**
- :fire: **Experimental**: let's invent the future!
- :bowtie: **Public API Challenge**: we'll need a very good public API
- :hammer: **Tooling**: GRDB and its environment
- :question: **Unknown Difficulty**
The ideas, in alphabetical order:
- [Associations]
- [CloudKit]
- [Concurrency]
- [Custom FTS5 Auxiliary Functions]
- [Date and Time Functions]
- [Decode NSDecimalNumber from Text Columns]
- [Documentation]
- [Full Text Search Demo Application]
- [JSON]
- [Linux]
- [More SQL Generation]
- [SQL Console in the Debugger]
- [SQLCipher in a Shared App Container]
- [Typed Expressions]
### Associations
:bowtie: Public API Challenge :muscle: Hard :fire: Experimental
Associations can be enhanced in several ways. See the "Known Issues" chapter of the [Associations Guide](Documentation/AssociationsBasics.md)
### CloudKit
:bowtie: Public API Challenge :question: Unknown Difficulty :fire: Experimental
Integration with [CloudKit](https://developer.apple.com/icloud/cloudkit/) is a rich, interesting, and useful topic.
It is likely that CloudKit support would exist in a separate companion library.
Starting points:
- [caiyue1993/IceCream](https://github.com/caiyue1993/IceCream)
- [mentrena/SyncKit](https://github.com/mentrena/SyncKit)
- [nofelmahmood/Seam](https://github.com/nofelmahmood/Seam)
- [Sorix/CloudCore](https://github.com/Sorix/CloudCore)
- [Synchronizing data with CloudKit](https://medium.com/@guilhermerambo/synchronizing-data-with-cloudkit-94c6246a3fda)
- WWDC CloudKit sessions, including [CloudKit Best Practices](https://developer.apple.com/videos/play/wwdc2016/231/)
### Concurrency
:bowtie: Public API Challenge :muscle: Hard :pencil: Documentation
GRDB has a strong focus on safe concurrency. Not only safe as "does not crash", but safe as "actively protects your application data". The topic is discussed in (too) many places:
- [Concurrency Guide](README.md#concurrency)
- [Why Adopt GRDB?](https://github.com/groue/GRDB.swift/blob/master/Documentation/WhyAdoptGRDB.md#strong-and-clear-multi-threading-guarantees)
- [Four different ways to handle SQLite concurrency](https://medium.com/@gwendal.roue/four-different-ways-to-handle-sqlite-concurrency-db3bcc74d00e)
- [Good Practices for Designing Record Types](https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md#fetch-in-time)
- [Comparison between GRDB and Core Data concurrency](https://github.com/groue/GRDB.swift/issues/405)
Despite this abundant documention, I regularly meet developers who don't think about eventual multi-threading gotchas, and don't design their application against them.
This can be explained:
- Some developers disregard potential multi-threading bugs such as data races, even if the fix is "easy". Such bugs may never happen during the development of an application. They may only impact a few users in production. It is always easier not to think about them.
- Databases are often seen as plain CRUD tools, and some developers are not familiar with topics like isolation or transactions. This is especially true for developers who have experience in a managed ORM such as Core Data or Realm, or web frameworks like Rails or Django: switching to an unmanaged relational database is not an easy task.
- Not all applications need to be multi-threaded.
And this creates improvement opportunities:
- Better documentation of GRDB concurrency
- The introduction of an "ultra-safe" concurrency mode. Maybe something that restricts all database accesses to the main thread, like [FCModel](https://github.com/marcoarment/FCModel). Maybe in a separate companion library.
### Custom FTS5 Auxiliary Functions
:question: Unknown Difficulty
The SQLite documentation provides [this description](https://www.sqlite.org/fts5.html) of FTS5 auxiliary functions:
> An application may use FTS5 auxiliary functions to retrieve extra information regarding the matched row. For example, an auxiliary function may be used to retrieve a copy of a column value for a matched row with all instances of the matched term surrounded by html <b></b> tags.
Applications can define their own [custom FTS5 auxiliary functions](https://www.sqlite.org/fts5.html#custom_auxiliary_functions) with SQLite, but GRDB does not yet provide any Swift API for that.
See issue [#421](https://github.com/groue/GRDB.swift/issues/421) for more information.
### Date and Time Functions
:baby: Starter Task
Believe it or not, no one has ever asked support for SQLite [Date And Time Functions](https://www.sqlite.org/lang_datefunc.html). There is surely room for a nice Swift API that makes them available.
For more ideas, see:
- [SQLite Core Functions](https://www.sqlite.org/lang_corefunc.html)
- [SQLite Aggregate Functions](https://www.sqlite.org/lang_aggfunc.html)
- [SQLite JSON functions](https://www.sqlite.org/json1.html) and [JSON], below.
Functions are defined in [GRDB/QueryInterface/Support/SQLFunctions.swift](https://github.com/groue/GRDB.swift/blob/master/GRDB/QueryInterface/Support/SQLFunctions.swift).
### Decode NSDecimalNumber from Text Columns
:baby: Starter Task
NSDecimalNumber currently only decodes integer and float decimal values. It would be nice if NSDecimalNumber would decode text values as well:
```swift
let number = try NSDecimalNumber.fetchOne(db, "SELECT '12.3'")!
print(number) // prints 12.3
```
NSNumber and NSDecimalNumber support is found in [GRDB/Core/Support/Foundation/NSNumber.swift](https://github.com/groue/GRDB.swift/blob/master/GRDB/Core/Support/Foundation/NSNumber.swift)
### Documentation
:baby: Starter Task :pencil: Documentation
General documentation can always be improved so that it reaches its goal: helping developers building applications.
- English: the documentation has mostly been written by [@groue](http://github.com/groue) who is not a native English speaker.
- Clarity: any chapter that is not crystal clear should be enhanced.
- Audience: documentation should talk to several populations of developers, from beginners who need positive guidance, to SQLite experts who need to build trust.
- Typos
- Inaccuracies
- etc.
Inline documentation, the one which is embedded right into the source code and is displayed by Xcode when one alt-clicks an identifier, deserves the same care.
If you are a good writer, your help will be very warmly welcomed.
### Full Text Search Demo Application
:baby: Starter Task :pencil: Documentation
There exists a GRDB demo app for the FTS5 full-text engine: [WWDCCompanion](https://github.com/groue/WWDCCompanion).
This application downloads the transcripts of WWDC sessions, and lets its user type keywords and find matching sessions, sorted by relevance.
The problem is that this demo app breaks every year :sweat_smile:
We'd need instead to index a stable corpus, in order to ease the maintenance of this demo app.
### JSON
:bowtie: Public API Challenge :baby: Starter Task
[Codable Records] are granted with automatic JSON encoding and decoding of their complex properties. But there is still room for improvements. For example, could we put the [SQLite JSON1 extension](https://www.sqlite.org/json1.html) to some good use?
### Linux
:muscle: Hard :hammer: Tooling
Swift on Linux is currently focused on the server (Vapor, Perfect, Kitura). While general server support is a [non-goal](#non-goals) of GRDB, there exists read-only servers, and Linux GUI applications, too. Linux is thus a desired platform.
### More SQL Generation
:bowtie: Public API Challenge :question: Unknown Difficulty
There are several SQLite features that GRDB could natively support:
- [ALTER TABLE ... RENAME COLUMN ... TO ...](https://www.sqlite.org/lang_altertable.html)
- [ATTACH DATABASE](https://www.sqlite.org/lang_attach.html)
- [UPSERT](https://www.sqlite.org/lang_UPSERT.html)
- [INSERT INTO ... SELECT ...](https://www.sqlite.org/lang_insert.html)
- [WITH RECURSIVE ...](https://www.sqlite.org/lang_with.html)
- [RTree](https://sqlite.org/rtree.html)
- [Windows Functions](https://www.sqlite.org/windowfunctions.html)
- [More ideas](https://www.sqlite.org/lang.html)
See [issue #575](https://github.com/groue/GRDB.swift/issues/575) for more information and guidance about the implementation of extra table alterations.
### SQL Console in the Debugger
:question: Unknown Difficulty :hammer: Tooling
Sometimes one needs, in lldb, a console similar to the [Command Line Shell For SQLite](https://www.sqlite.org/cli.html).
### SQLCipher in a Shared App Container
:question: Unknown Difficulty
See issue [#302](https://github.com/groue/GRDB.swift/issues/302).
### Typed Expressions
:bowtie: Public API Challenge :muscle: Hard :fire: Experimental
The compiler currently does not spot type mistakes in query interface requests:
```swift
Player.filter(Column("name") == "Arthur") // OK
Player.filter(Column("name") == 1) // Sure
Player.filter(Column("name") == Date()) // Legit
```
This weak typing also prevents natural-looking Swift code from producing the expected results:
```swift
// Performs arithmetic additions instead of string concatenation
Player.select(Column("firstName") + " " + Column("lastName"))
```
It would be interesting to see what typed expressions could bring to GRDB.
## Non-Goals
GRDB is a "toolkit for SQLite databases, with a focus on application development".
This definition is the reason why GRDB can provide key features such as sharp multi-threading, database observation, and first-class support for raw SQL.
Features that blur this focus are non-goals:
- Support for MySQL, PostgreSQL, or other database engines
- Support for Servers
[Ask Questions]: #ask-questions
[Associations]: #associations
[CloudKit]: #cloudkit
[Codable Records]: README.md#codable-records
[Custom FTS5 Auxiliary Functions]: #custom-fts5-auxiliary-functions
[Database Observation]: #database-observation
[Date and Time Functions]: #date-and-time-functions
[Decode NSDecimalNumber from Text Columns]: #decode-nsdecimalnumber-from-text-columns
[Documentation]: #documentation
[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
[Records: Splitting Database Encoding from Ability to Write in the Database]: #records-splitting-database-encoding-from-ability-to-write-in-the-database
[Non-Goals]: #non-goals
[Report Bugs]: #report-bugs
[RxGRDB]: http://github.com/RxSwiftCommunity/RxGRDB
[Concurrency]: #concurrency
[Sponsoring and Professional Support]: #sponsoring-and-professional-support
[SQL Console in the Debugger]: #sql-console-in-the-debugger
[SQLCipher in a Shared App Container]: #sqlcipher-in-a-shared-app-container
[Submit a Pull Request]: #submit-a-pull-request
[Suggest an Enhancement]: #suggest-an-enhancement
[Suggested Contributions]: #suggested-contributions
[Typed Expressions]: #typed-expressions
[persistence methods]: README.md#persistence-methods
[PersistableRecord]: README.md#persistablerecord-protocol
[Record Comparison]: README.md#record-comparison
[Requesting Associated Records]: Documentation/AssociationsBasics.md#requesting-associated-records
[ValueObservation]: README.md#valueobservation
How you can Contribute
======================
- [Contribute to the GRDB codebase]
- [Answer issues and contribute to discussions]
- [Financial support and sponsoring]
## Contribute to the GRDB codebase
1. **Install** the following tools:
- For running tests:
- Ruby
- [CocoaPods](https://cocoapods.org) (gem)
- [xcpretty](https://github.com/xcpretty/xcpretty) (gem)
- For contributing code:
- [Swiftlint](https://github.com/realm/SwiftLint) (present in the `$PATH` or in `/opt/homebrew/bin/`)
- For generating documentation:
- [Jazzy](https://github.com/realm/jazzy) (gem)
2. **Clone the `development` branch on your machine.**
3. **Run `make SQLiteCustom` in the terminal**, at the root of the repository.
This step is not strictly necessary if you do not plan to work on custom SQLite builds. But it will avoid a lot of warnings in Xcode.
4. **Open `GRDB.xcworkspace`.** This workspace contains six projects:
- `GRDB.xcodeproj`: the project which contains the GRDB framework and test targets. The sources are organized in two groups:
- `GRDB`: GRDB sources
- `Tests`: GRDB tests
- `GRDBCustom.xcodeproj`: the project which builds GRDB with a custom SQLite build.
- `GRDBProfiling.xcodeproj`: a project which helps profiling GRDB with Instruments. No code here is really precious.
- `GRDBDemoiOS.xcodeproj`, `GRDBCombineDemo.xcodeproj`, `GRDBAsyncDemo.xcodeproj`: the demo apps.
To work with `GRDBCustom.xcodeproj`:
- Make sure Xcode is installed in `/Applications`.
- Run `make SQLiteCustom` in the terminal so that SQLite sources are present.
5. **Run tests**
You can run tests from `GRDB.xcworkspace`, after selecting your target (GRDBOSX, GRDBiOS, GRDBtvOS, from `GRDB.xcodeproj` or `GRDBCustom.xcodeproj`).
Before submitting a pull request, please run in the terminal:
```sh
make smokeTest
```
The "smoke tests" perform minimal testing of the system SQLite, SQLCipher, custom SQLite builds, as well as SPM integration.
Before a release, the full test suite must pass:
```sh
make test
```
The full test suite performs many more checks, such as the ability to archive an XCFramework, various installation methods, the demo apps, etc.
6. **Please respect the existing coding style**
- Get familiar with the [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/).
- Spaces, not tabs.
- Whitespace-only lines are not trimmed.
- Documentation comments are hard-wrapped at column 80 (Xcode > Preferences > Text Editing > Display > [X] Page guide at column: 80).
- No Swiftlint warning after a build.
7. **Please provide documentation for your changes**
GRDB documentation is provided as reference (inline doc comments starting with `///`, see [Documentation Comment Syntax](https://github.com/apple/swift/blob/main/docs/DocumentationComments.md)), and guides ([README.md](README.md) and the [Documentation](Documentation) folder).
GRDB is "documentation-driven", which means that nothing ships until it is supported by documentation that makes sense. Documentation makes sense when someone who is not you is able to figure out what is the purpose of your contribution, how to use it, and what are its eventual caveats and corner cases. When the documentation is hard to write, or reveals too many caveats, it is the sign that the api needs to be fixed.
8. **Open a pull request with your changes (targeting the `development` branch)!**
9. **If you are granted a push access to the repository**, check [ReleaseProcess.md](Documentation/ReleaseProcess.md) in order to publish a new GRDB version.
## Answer issues and contribute to discussions
Answering [issues](https://github.com/groue/GRDB.swift/issues), participating in [discussions](https://github.com/groue/GRDB.swift/discussions) and in the [forum](https://forums.swift.org/c/related-projects/grdb/36) is a great way to help, get familiar with the library, and shape its direction.
## Financial support and sponsoring
GRDB is free, and openly developed by its contributors, on their free time, according to their will, needs, and availability. It is not controlled by any company.
Support is free as well, as long as it happens publicly, and is available to everyone as well as internet search engines. This excludes the private channels of social networks, closed environments such as Slack, etc.
When you have specific development or support needs, please send an email to [Gwendal Roué](mailto:gr@pierlis.com) so that we can enter a regular business relationship through the [Pierlis](http://pierlis.com/) company, based in Paris, France.
You can also [sponsor @groue via GitHub](https://github.com/sponsors/groue).
[Contribute to the GRDB codebase]: #contribute-to-the-grdb-codebase
[Answer issues and contribute to discussions]: #answer-issues-and-contribute-to-discussions
[Financial support and sponsoring]: #financial-support-and-sponsoring
+622 -84
View File
@@ -26,6 +26,7 @@ GRDB Associations
- [Sorting Associations]
- [Ordered Associations]
- [Columns Selected by an Association]
- [Further Refinements to Associations]
- [Table Aliases]
- [Refining Association Requests]
- [Fetching Values from Associations]
@@ -88,7 +89,7 @@ struct BookInfo {
let books = try Book.fetchAll(db)
let bookInfos = books.map { book -> BookInfo in
let author = try Author.fetchOne(db, key: book.authorId)
let author = try Author.fetchOne(db, id: book.authorId)
return BookInfo(book: book, author: author)
}
```
@@ -781,6 +782,7 @@ Fetch requests do not visit the database until you fetch values from them. This
- [Sorting Associations]
- [Ordered Associations]
- [Columns Selected by an Association]
- [Further Refinements to Associations]
- [Table Aliases]
- [Refining Association Requests]
@@ -840,108 +842,513 @@ let novels = try author
## Joining And Prefetching Associated Records
**You build requests that involve several records with the following "joining methods":**
You build requests that involve associations with one of the following "joining methods":
- `joining(optional: association)`
- `joining(required: association)`
- `including(optional: association)`
- `including(required: association)`
- `including(all: associationToMany)`
- Prefetch associated records:
- [`including(required:)`]
- [`including(optional:)`]
- [`including(all:)`]
- Prefetch only a few columns of an associated record:
- [`annotated(withRequired:)`]
- [`annotated(withOptional:)`]
- [`including(all:)`]
- Join associated records without prefetching:
- [`joining(required:)`]
- [`joining(optional:)`]
- [Choosing a Joining Method Given the Shape of the Decoded Type]
Before we describe them in detail, let's see a few requests they can build:
### `including(required:)`
For example, fetch books along with their author:
```swift
/// All authors with their respective books
let request = Author
.including(all: Author.books)
/// All books with their respective author
let request = Book
.including(required: Book.author)
/// All books with their respective author, sorted by title
let request = Book
.order(Column("title"))
.including(required: Book.author)
/// All books written by a French author
let request = Book
.joining(required: Book.author.filter(Column("countryCode") == "FR"))
// SELECT book.*, author.*
// FROM book
// JOIN author ON author.id = book.authorId
let request = Book.including(required: Book.author)
```
The pattern is always the same: you start from a base request, that you extend with one of the joining methods.
This method accepts any association. It has the base record fetched along with one associated record, which is "included" in the fetched results. When the associated record does not exist, records are not present in the fetched results: the associated record is "required".
**To choose the joining method you need, you ask yourself two questions:**
**To fetch results from such a request**, you define a dedicated record type:
```swift
// Fetch all books along with their author
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var author: Author // The required associated record
}
let bookInfos = try Book
.including(required: Book.author)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
**The CodingKey for the `BookInfo.author` property must match the association key of the `Book.author` association.** The association key is, by default, the name of the associated database table. This can be configured with the association `forKey(_:)` method:
```swift
struct Author: TableRecord {
static let databaseTableName = "writer"
}
struct Book: TableRecord {
// Replace the default "writer" association key with "author"
static let author = belongsTo(Author.self).forKey("author")
}
// Fetch all books along with their author
struct BookInfo: Decodable, FetchableRecord {
var book: Book
var author: Author // Matches the "author" association key
}
let bookInfos = try Book
.including(required: Book.author)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
**When you only need a few columns of the associated record**, you can define a partial type with one property per selected column of the associated record:
```swift
// Fetch all books along with the name and country of their author
struct BookInfo: Decodable, FetchableRecord {
struct PartialAuthor: Decodable {
var name: String
var country: String
}
var book: Book
var author: PartialAuthor
}
let bookInfos = try Book
.including(required: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
But if you'd rather avoid this extra partial type, prefer [`annotated(withRequired:)`]:
```swift
// Fetch all books along with the country of their author
struct BookInfo: Decodable, FetchableRecord {
var book: Book
var country: String
}
let bookInfos = try Book
.annotated(withRequired: Book.author.select(Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
### `including(optional:)`
For example, fetch books along with their eventual author:
```swift
// SELECT book.*, author.*
// FROM book
// LEFT JOIN author ON author.id = book.authorId
let request = Book.including(optional: Book.author)
```
This method accepts any association. It has the base record fetched along with one associated record, which is "included" in the fetched results. The associated record can be missing: it is "optional".
**To fetch results from such a request**, you define a dedicated record type:
```swift
// Fetch all books along with their eventual author
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var author: Author? // The optional associated record
}
let bookInfos = try Book
.including(optional: Book.author)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
**The CodingKey for the `BookInfo.author` property must match the association key of the `Book.author` association.** See [`including(required:)`] for more information.
**When you only need a few columns of the associated record**, you can define a partial type with one property per selected column of the associated record:
```swift
// Fetch all books along with the name and country of their eventual author
struct BookInfo: Decodable, FetchableRecord {
struct PartialAuthor: Decodable {
var name: String
var country: String
}
var book: Book
var author: PartialAuthor?
}
let bookInfos = try Book
.including(optional: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
But if you'd rather avoid this extra partial type, prefer [`annotated(withOptional:)`]:
```swift
// Fetch all books along with the country of their eventual author
struct BookInfo: Decodable, FetchableRecord {
var book: Book
var country: String?
}
let bookInfos = try Book
.annotated(withOptional: Book.author.select(Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
### `including(all:)`
For example, fetch authors along with their books:
```swift
// SELECT author.* FROM author
// SELECT book.* FROM book WHERE authorId IN (...)
let request = Author.including(all: Author.books)
```
This method accepts any to-many association ([HasMany] or [HasManyThrough]). It has the base record fetched along with all its associated records, which are "included" in the fetched results.
**To fetch results from such a request**, you define a dedicated record type:
```swift
// Fetch all authors along with their books
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author // The base record
var books: [Book] // A collection of associated records
}
let authorInfos = try Author
.including(all: Author.books)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
The associated records can be stored into an Array as in the above example, but also a Set, and generally speaking any decodable Swift collection.
**The CodingKey for the `AuthorInfo.books` property must match the association key of the `Author.books` association.** The association key is, by default, the pluralized name of the associated database table. This can be configured with the association `forKey(_:)` method:
```swift
struct Book: TableRecord {
static let databaseTableName = "publication"
}
struct Author: TableRecord {
// Replace the default "publications" association key with "books"
static let books = hasMany(Book.self).forKey("books")
}
// Fetch all authors along with their books
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var books: [Book] // Matches the "books" association key
}
let authorInfos = try Author
.including(all: Author.books)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
**When you only need a few columns of the associated records**, you can define a partial type with one property per selected column of the associated record:
```swift
// Fetch all authors along with the titles and years of their books
struct AuthorInfo: Decodable, FetchableRecord {
struct PartialBook: Decodable {
var title: String
var year: Int
}
var author: Author
var books: [PartialBook]
}
let authorInfos = try Author
.including(all: Author.books.select(Column("title"), Column("year")))
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
When you need a single column of the associated records, avoid the extra partial type, and instead use the association `forKey(_:)` method in order to match the name of the decoded property:
```swift
// Fetch all authors along with the titles of their books
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var bookTitles: [String]
}
let authorInfos = try Author
.including(all: Author.books
.select(Column("title"))
.forKey("bookTitles"))
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
### `annotated(withRequired:)`
For example, fetch books along with the name and country of their author:
```swift
// SELECT book.*, author.name, author.country
// FROM book
// JOIN author ON author.id = book.authorId
let request = Book.annotated(withRequired: Book.author.select(Column("name"), Column("country")))
```
This method accepts any association. The base record is annotated with the selected columns of one associated record. When the associated record does not exist, records are not present in the fetched results: the associated record is "required".
**To fetch results from such a request**, you define a dedicated record type:
```swift
// Fetch all books along with the name and country of their author
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var name: String // A column of the required associated record
var country: String // A column of the required associated record
}
let bookInfos = try Book
.annotated(withRequired: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
If the name of a column of the associated record is also the name of a column of the base record, rename the associated column with the column `forKey(_:)` method, and accordingly rename the property of the decoded record type:
```swift
// Fetch all books along with the name of their author
struct BookInfo: Decodable, FetchableRecord {
var book: Book
var authorName: String
}
let bookInfos = try Book
.annotated(withRequired: Book.author.select(Column("name").forKey("authorName")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
### `annotated(withOptional:)`
For example, fetch books along with the name and country of their eventual author:
```swift
// SELECT book.*, author.name, author.country
// FROM book
// LEFT JOIN author ON author.id = book.authorId
let request = Book.annotated(withOptional: Book.author.select(Column("name"), Column("country")))
```
This method accepts any association. The base record is annotated with the selected columns of one associated record. When the associated record does not exist, the columns of the associated record are NULL: the associated record is "optional".
**To fetch results from such a request**, you define a dedicated record type:
```swift
// Fetch all books along with the name of their eventual author
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var name: String? // A column of the optional associated record
var country: String? // A column of the optional associated record
}
let bookInfos = try Book
.annotated(withOptional: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
If the name of a column of the associated record is also the name of a column of the base record, rename the associated column with the column `forKey(_:)` method, and accordingly rename the property of the decoded record type:
```swift
// Fetch all books along with the name of their eventual author
struct BookInfo: Decodable, FetchableRecord {
var book: Book
var authorName: String?
}
let bookInfos = try Book
.annotated(withOptional: Book.author.select(Column("name").forKey("authorName")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
### `joining(required:)`
For example, fetch books by French authors:
```swift
// SELECT book.*
// FROM book
// JOIN author ON author.id = book.authorId
// AND author.country = 'France'
let request = Book.joining(required: Book.author.filter(Column("country") == "France"))
```
This method accepts any association. It has the base record "joined" with one associated record, which is not included in the fetched results. When the associated record does not exist, the base record is not present in the fetched results: the associated record is "required".
To fetch results from such a request, you do not need to define a dedicated record type:
```swift
// Fetch all books by French authors
let books = try Book
.joining(required: Book.author.filter(Column("country") == "France"))
.fetchAll(db)
```
### `joining(optional:)`
```swift
// SELECT book.*
// FROM book
// LEFT JOIN author ON author.id = book.authorId
let request = Book.joining(optional: Book.author)
```
This method accepts any association. It has the base record "joined" with one associated record, which is not included in the fetched results. The associated record can be missing: it is "optional".
This method has no observable effect unless the associated record is used in a way or another. We'll see examples later in this documentation.
### Choosing a Joining Method Given the Shape of the Decoded Type
In the description of the [joining methods] above, we have seen that you need to define dedicated record types in order to prefetch associated records. Each joining method needs a dedicated record type that has a specific shape.
In this chapter, we take the reversed perspective. We list various shapes of decoded record types. When you find the type you want, you'll know the joining method you need.
> :point_up: **Note**: If you don't find the type you want, chances are that you are fighting the framework, and should reconsider your position. Your escape hatch is the low-level apis described in [Decoding a Joined Request with FetchableRecord].
- [`including(required:)`]
1. Should the associated records be fetched along with the base records?
If yes, use `including(...)`. Otherwise, use `joining(...)`.
For example, to load books with their respective author, you use `including(required:)`:
```swift
// All books with their respective author
let request = Book
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var author: Author // The associated record
}
let bookInfos = try Book
.including(required: Book.author)
// This request can feed the following record:
struct BookInfo: FetchableRecord, Decodable {
var book: Book
var author: Author // the required associated author
}
let bookInfos: [BookInfo] = try BookInfo.fetchAll(db, request)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
And to load authors with their respective books, you use `including(all:)`:
```swift
// All authors with their respective books
let request = Author
.including(all: Author.books)
// This request can feed the following record:
struct AuthorInfo: FetchableRecord, Decodable {
var author: Author
var books: [Book] // all associated books
struct BookInfo: Decodable, FetchableRecord {
struct PartialAuthor: Decodable {
var name: String
var country: String
}
var book: Book // The base record
var author: PartialAuthor // The partial associated record
}
let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request)
```
On the other side, to load all books written by a French author, you sure need to filter authors, but you don't need them to be present in the fetched results. You prefer `joining`:
```swift
// All books written by a French author
let request = Book
.joining(required: Book.author.filter(Column("countryCode") == "FR"))
// This request feeds the Book record:
let books: [Book] = try request.fetchAll(db)
let bookInfos = try Book
.including(required: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
2. For to-one associations, should the request allow missing associated records?
If yes, choose the `optional` variant. Otherwise, choose `required`.
For example, to load all books with their respective authors, even if the book has no recorded author, you'd use `including(optional:)`:
- [`annotated(withRequired:)`]
```swift
// All books with their respective (eventual) authors
let request = Book
.including(optional: Book.author)
// This request can feed the following record:
struct BookInfo: FetchableRecord, Decodable {
var book: Book
var author: Author? // the optional associated author
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var authorName: String // A column of the associated record
var country: String // A column of the associated record
}
let bookInfos: [BookInfo] = try BookInfo.fetchAll(db, request)
let bookInfos = try Book
.annotated(withRequired: Book.author.select(
Column("name").forKey("authorName"),
Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
- [`including(optional:)`]
```swift
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var author: Author? // The eventual associated record
}
let bookInfos = try Book
.including(optional: Book.author)
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
You can remember to use `optional` when the fetched associated records should feed optional Swift values, of type `Author?`. Conversely, when the fetched results feed non-optional values of type `Author`, prefer `required`.
```swift
struct BookInfo: Decodable, FetchableRecord {
struct PartialAuthor: Decodable {
var name: String
var country: String
}
var book: Book // The base record
var author: PartialAuthor? // The eventual partial associated record
}
Another way to describe the difference is that `required` filters the fetched results in order to discard missing associated records, when `optional` does not filter anything, and lets missing values pass through.
let bookInfos = try Book
.including(optional: Book.author.select(Column("name"), Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
- [`annotated(withOptional:)`]
Finally, readers who speak SQL may compare `optional` with left joins, and `required` with inner joins.
```swift
struct BookInfo: Decodable, FetchableRecord {
var book: Book // The base record
var authorName: String? // A column of the eventual associated record
var country: String? // A column of the eventual associated record
}
let bookInfos = try Book
.annotated(withOptional: Book.author.select(
Column("name").forKey("authorName"),
Column("country")))
.asRequest(of: BookInfo.self)
.fetchAll(db)
```
- [`including(all:)`]
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author // The base record
var books: [Book] // A collection of associated records
}
let authorInfos = try Author
.including(all: Author.books)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
```swift
struct AuthorInfo: Decodable, FetchableRecord {
struct PartialBook: Decodable {
var title: String
var year: Int
}
var author: Author // The base record
var books: [PartialBook] // A collection of partial associated records
}
let authorInfos = try Author
.including(all: Author.books.select(Column("title"), Column("year")))
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author // The base record
var bookTitles: [String] // A collection of one column of the associated records
}
let authorInfos = try Author
.including(all: Author.books
.select(Column("title"))
.forKey("bookTitles"))
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
## Combining Associations
@@ -1044,7 +1451,7 @@ let bookInfos: [BookInfo] = try BookInfo.fetchAll(db, request)
**You can filter associated records.**
The `filter(_:)`, `filter(key:)` and `filter(keys:)` methods, that you already know for [filtering simple requests](../README.md#requests), can filter associated records as well:
The `filter(_:)`, `filter(id:)`, `filter(ids:)`, `filter(key:)` and `filter(keys:)` methods, that you already know for [filtering simple requests](../README.md#requests), can filter associated records as well:
```swift
// SELECT book.*
@@ -1221,10 +1628,9 @@ let teamInfos = try Team
.fetchAll(db)
```
## Columns Selected by an Association
By default, associated records include all their columns:
By default, associated records, like all records, include all their columns:
```swift
// SELECT book.*, author.*
@@ -1235,7 +1641,9 @@ let request = Book.including(required: Book.author)
**The selection can be changed for each individual request, or for all requests including a given type.**
To specify the selection of an associated record in a specific request, use the `select` method:
To specify the default selection for a given record type, see [Columns Selected by a Request](../README.md#columns-selected-by-a-request).
To specify the selection in a specific request, use the `select` method:
```swift
// SELECT book.*, author.id, author.name
@@ -1245,7 +1653,105 @@ let restrictedAuthor = Book.author.select(Column("id"), Column("name"))
let request = Book.including(required: restrictedAuthor)
```
To specify the default selection for all inclusions of a given type, see [Columns Selected by a Request](../README.md#columns-selected-by-a-request).
In order to fetch from such requests of partial records, see the documentation of the [joining methods].
## Further Refinements to Associations
Associations support more refinements:
- `distinct`
Fetch all authors with the kinds of books they write (novels, poems, plays, etc):
```swift
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var bookKinds: Set<Book.Kind>
}
let distinctBookKinds = Author.books
.select(Column("kind"))
.distinct()
.forKey("bookKinds")
let authorInfos: [AuthorInfo] = try Author
.including(all: distinctBookKinds)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
- `group`, `having`
Fetch all authors with the year of their latest book for each kind (novels, poems, plays, etc):
```swift
struct BookKindInfo: Decodable {
var kind: Book.Kind
var maxYear: Int
}
struct AuthorInfo: Decodable, FetchableRecord {
var author: Author
var bookKindInfos: [BookKindInfo]
}
let bookKindInfos = Author.books
.select(
Column("kind"),
max(Column("year")).forKey("maxYear"))
.group(Column("kind"))
.forKey("bookKindInfos")
let authorInfos: [AuthorInfo] = try Author
.including(all: bookKindInfos)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
- [Association Aggregates]
Fetch all authors with their awarded books:
```swift
struct AuthorInfo: FetchableRecord, Decodable {
var author: Author
var awardedBooks: [Book]
}
let awardedBooks = Author.books
.having(Book.awards.isEmpty == false)
.forKey("awardedBooks")
let authorInfos: [AuthorInfo] = try Author
.including(all: awardedBooks)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
- [Common Table Expressions]
Association can use their own CTEs:
```swift
struct AuthorInfo: FetchableRecord, Decodable {
var author: Author
var specialBooks: [Book]
}
let specialCTE = CommonTableExpression(...)
let specialBooks = Author.books
.with(specialCTE)
... // use the CTE in the book association
.forKey("specialBooks")
let authorInfos = try Author
.including(all: specialBooks)
.asRequest(of: AuthorInfo.self)
.fetchAll(db)
```
> :warning: **Warning**: associations refined with `limit`, `distinct`, `group`, `having`, or association aggregates can only be used with `including(all:)`. You will get a fatal error if you use them with other joining methods: `including(required:)`, etc.
## Table Aliases
@@ -1825,6 +2331,7 @@ for info in authorInfos {
- `books.max(column)`
- `books.average(column)`
- `books.sum(column)`
- `books.total(column)`
### Annotating a Request with Aggregates
@@ -1873,6 +2380,9 @@ The default name is built from the aggregating method, the **[association key](#
| `Author.books.max(Column("year"))` | `books` | `year` | `maxBookYear` |
| `Author.books.average(Column("price"))` | `books` | `price` | `averageBookPrice` |
| `Author.books.sum(Column("awards"))` | `books` | `awards` | `bookAwardsSum` |
| `Author.books.total(Column("awards"))` | `books` | `awards` | `bookAwardsSum` ¹ |
¹ The default name of the `total` aggregate has a `Sum` suffix, just like the `sum` aggregate. Both compute sums, one with the `SUM` SQL function, the other with `TOTAL`. See [SQLite documentation](https://www.sqlite.org/lang_aggfunc.html#sumunc) for the difference between these aggregate functions.
Those default names are lost whenever an aggregate is modified (negated, added, multiplied, whatever).
@@ -2147,6 +2657,23 @@ Aggregates can be modified and combined with Swift operators:
let request = Team.annotated(with: Team.players.min(Column("score")) ?? 0)
```
- SQL functions `ABS` and `LENGTH` are available as the `abs` and `length` Swift functions:
<details>
<summary>SQL</summary>
```sql
SELECT "team".*, ABS(MAX("player"."score"))
FROM "team"
LEFT JOIN "player" ON ("player"."teamId" = "team"."id")
GROUP BY "team"."id"
```
</details>
```swift
let request = Team.annotated(with: abs(Team.players.max(Column("score"))))
```
### Isolation of Multiple Aggregates
@@ -2433,6 +2960,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[Choosing Between BelongsTo and HasOne]: #choosing-between-belongsto-and-hasone
[Self Joins]: #self-joins
[Ordered Associations]: #ordered-associations
[Further Refinements to Associations]: #further-refinements-to-associations
[The Types of Associations]: #the-types-of-associations
[FetchableRecord]: ../README.md#fetchablerecord-protocols
[migration]: Migrations.md
@@ -2450,6 +2978,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[Requesting Associated Records]: #requesting-associated-records
[requests for associated records]: #requesting-associated-records
[Joining And Prefetching Associated Records]: #joining-and-prefetching-associated-records
[joining methods]: #joining-and-prefetching-associated-records
[Filtering Associations]: #filtering-associations
[Sorting Associations]: #sorting-associations
[Columns Selected by an Association]: #columns-selected-by-an-association
@@ -2483,4 +3012,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[ValueObservation]: ../README.md#valueobservation
[FAQ]: ../README.md#faq-associations
[common table expressions]: CommonTableExpressions.md
[Common Table Expressions]: CommonTableExpressions.md
[Associations to Common Table Expressions]: CommonTableExpressions.md#associations-to-common-table-expressions
[`including(required:)`]: #includingrequired
[`including(optional:)`]: #includingoptional
[`including(all:)`]: #includingall
[`annotated(withRequired:)`]: #annotatedwithrequired
[`annotated(withOptional:)`]: #annotatedwithoptional
[`joining(required:)`]: #joiningrequired
[`joining(optional:)`]: #joiningoptional
[Choosing a Joining Method Given the Shape of the Decoded Type]: #choosing-a-joining-method-given-the-shape-of-the-decoded-type
+106 -28
View File
@@ -7,6 +7,7 @@ GRDB ❤️ Combine
- [Demo Application]
- [Asynchronous Database Access]
- [Database Observation]
- [Combine and Data Consistency]: take care when you combine database publishers together
## Usage
@@ -46,6 +47,19 @@ let newPlayerCount = dbQueue.writePublisher { db -> Int in
</details>
<details>
<summary><strong>Asynchronously migrate the database</strong></summary>
This publisher migrates a database:
```swift
// DatabasePublishers.Migrate
let migrator: DatabaseMigrator = ...
let publisher = migrator.migratePublisher(dbQueue)
```
</details>
<details>
<summary><strong>Observe changes in database values</strong></summary>
@@ -99,11 +113,12 @@ let cancellable = publisher.sink(
# Asynchronous Database Access
GRDB provide publishers that perform asynchronous database accesses.
GRDB provide publishers that perform asynchronous database accesses:
- [`readPublisher(receiveOn:value:)`]
- [`writePublisher(receiveOn:updates:)`]
- [`writePublisher(receiveOn:updates:thenRead:)`]
- [`migratePublisher(_:receiveOn:)`]
#### `DatabaseReader.readPublisher(receiveOn:value:)`
@@ -125,7 +140,7 @@ When you use a [database pool], reads are generally non-blocking, unless the max
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.
The fetched value is published on the main queue, unless you provide a specific [scheduler] to the `receiveOn` argument.
#### `DatabaseWriter.writePublisher(receiveOn:updates:)`
@@ -176,7 +191,7 @@ let newPlayerCount = dbQueue.writePublisher { db -> Int in
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 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](Concurrency.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.
@@ -190,6 +205,7 @@ It completes on the main queue, unless you provide a specific [scheduler] to the
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:)`]
- [`SharedValueObservation.publisher()`]
- [`DatabaseRegionObservation.publisher(in:)`]
@@ -211,7 +227,7 @@ 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.
- It only completes when it is cancelled.
- 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).
@@ -234,36 +250,21 @@ This publisher has the same behavior as ValueObservation:
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)).
#### `SharedValueObservation.publisher()`
Instead, compose requests together into **one single** ValueObservation, as below:
[SharedValueObservation] tracks changes in database values. You can turn it into a Combine publisher:
```swift
struct HallOfFame {
var totalPlayerCount: Int
var bestPlayers: [Player]
}
let sharedObservation = ValueObservation
.tracking { db in try Player.fetchAll(db) }
.shared(in: dbQueue)
// 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)
// A publisher with output [Player] and failure Error
let publisher = sharedObservation.publisher()
```
See [ValueObservation] for more information.
This publisher has the same behavior as SharedValueObservation.
#### `DatabaseRegionObservation.publisher(in:)`
@@ -306,23 +307,100 @@ try dbQueue.write { db in
See [DatabaseRegionObservation] for more information.
## Combine and Data Consistency
When you compose database publishers together with Combine operators such as `combineLatest` or `zip`, you lose all guarantees of [data consistency](https://en.wikipedia.org/wiki/Consistency_(database_systems)).
This is because each database publisher is isolated from others: each one of them sees its own state of the database. Whenever some database change is interleaved between publisher operations, publishers will process or publish values that may not fit well together.
In other words, whenever you need to perform some database access or observation that depends on some database invariant, make sure you define one and only one database publisher instead of combining several publishers. This is how you will prevent eventual concurrent database writes from messing with your app, and introduce bugs.
To this end, remember that *all database publishers can perform several requests*.
In the example below, we are totally sure that the published `HallOfFame` values will never contain inconsistent values, because it is produced by one and only one publisher:
```swift
struct HallOfFame {
// Invariant: bestPlayers.count <= totalPlayerCount
var totalPlayerCount: Int
var bestPlayers: [Player]
}
// CORRECT: DATA CONSISTENCY GUARANTEED
let hallOfFamePublisher = ValueObservation
.tracking { db -> HallOfFame in
// 1st request
let totalPlayerCount = try Player.fetchCount(db)
// 2nd request
let bestPlayers = try Player
.order(Column("score").desc)
.limit(10)
.fetchAll(db)
// 100% guaranteed
assert(bestPlayers.count <= totalPlayerCount)
// Merge results together
return HallOfFame(
totalPlayerCount: totalPlayerCount,
bestPlayers: bestPlayers)
}
.publisher(in: dbQueue)
```
Compare with the incorrect version that combines two database publishers together:
```swift
// OK
let totalPlayerCountPublisher = ValueObservation
.tracking(Player.fetchCount)
.publisher(in: dbQueue)
// OK
let bestPlayerPublisher = ValueObservation
.tracking(Player
.order(Column("score").desc)
.limit(10)
.fetchAll)
.publisher(in: dbQueue)
// NOT OK: DATA CONSISTENCY NOT GUARANTEED
let hallOfFamePublisher = totalPlayerCountPublisher
.combineLatest(bestPlayerPublisher)
.map(HallOfFame.init(totalPlayerCount:bestPlayers))
let cancellable = hallOfFamePublisher.sink(
receiveCompletion: { completion in ... },
receiveValue: { hallOfFame in
// ASSERTION MAY FAIL if some players are deleted
// at the wrong time
assert(hallOfFame.bestPlayers.count <= hallOfFame.totalPlayerCount)
})
```
[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
[Combine and Data Consistency]: #combine-and-data-consistency
[DatabaseRegionObservation]: ../README.md#databaseregionobservation
[Demo Application]: DemoApps/GRDBCombineDemo/README.md
[SQLite]: http://sqlite.org
[ValueObservation]: ../README.md#valueobservation
[SharedValueObservation]: ../README.md#valueobservation-sharing
[`DatabaseRegionObservation.publisher(in:)`]: #databaseregionobservationpublisherin
[`ValueObservation.publisher(in:scheduling:)`]: #valueobservationpublisherinscheduling
[`SharedValueObservation.publisher()`]: #sharedvalueobservationpublisher
[`readPublisher(receiveOn:value:)`]: #databasereaderreadpublisherreceiveonvalue
[`writePublisher(receiveOn:updates:)`]: #databasewriterwritepublisherreceiveonupdates
[`writePublisher(receiveOn:updates:thenRead:)`]: #databasewriterwritepublisherreceiveonupdatesthenread
[`migratePublisher(_:receiveOn:)`]: Migrations.md#asynchronous-migrations
[configured]: ../README.md#databasepool-configuration
[database pool]: ../README.md#database-pools
[database queue]: ../README.md#database-queues
[database snapshot]: ../README.md#database-snapshots
[database snapshot]: Concurrency.md#database-snapshots
[scheduler]: https://developer.apple.com/documentation/combine/scheduler
+44 -55
View File
@@ -29,7 +29,7 @@ The CTE request can be provided as a [query interface request]:
```swift
// WITH playerName AS (SELECT name FROM player) ...
let playerNameCTE = CommonTableExpression<Void>(
let playerNameCTE = CommonTableExpression(
named: "playerName",
request: Player.select(Column("name")))
```
@@ -40,27 +40,27 @@ You can feed a CTE with raw SQL as well (second and third examples use [SQL Inte
let name = "O'Brien"
// WITH playerName AS (SELECT 'O''Brien') ...
let playerNameCTE = CommonTableExpression<Void>(
let playerNameCTE = CommonTableExpression(
named: "playerName",
sql: "SELECT ?", arguments: [name])
// WITH playerName AS (SELECT 'O''Brien') ...
let playerNameCTE = CommonTableExpression<Void>(
let playerNameCTE = CommonTableExpression(
named: "playerName",
literal: "SELECT \(name)")
// WITH playerName AS (SELECT 'O''Brien') ...
let request: SQLRequest<String> = "SELECT \(name)"
let playerNameCTE = CommonTableExpression<Void>(
let request = SQLRequest("SELECT \(name)")
let playerNameCTE = CommonTableExpression(
named: "playerName",
request: requests)
request: request)
```
All CTEs can be provided with explicit column names:
```swift
// WITH pair(a, b) AS (SELECT 1, 2) ...
let pairCTE = CommonTableExpression<Void>(
let pairCTE = CommonTableExpression(
named: "pair",
columns: ["a", "b"],
sql: "SELECT 1, 2")
@@ -71,7 +71,7 @@ Recursive CTEs need the `recursive` flag. The example below selects all integers
```swift
// WITH RECURSIVE counter(x) AS
// (VALUES(1) UNION ALL SELECT x+1 FROM counter WHERE x<1000)
let counterCTE = CommonTableExpression<Int>(
let counterCTE = CommonTableExpression(
recursive: true,
named: "counter",
columns: ["x"],
@@ -84,8 +84,6 @@ let counterCTE = CommonTableExpression<Int>(
> :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
@@ -103,7 +101,7 @@ We first build a `CommonTableExpression`:
```swift
let name = "O'Brien"
let playerNameCTE = CommonTableExpression<Void>(
let playerNameCTE = CommonTableExpression(
named: "playerName",
literal: "SELECT \(name)")
```
@@ -184,48 +182,37 @@ try Player
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.
`cte.all()` builds a regular [query interface request] that you can filter, sort, etc, like all query interface requests.
This will generally give requests of the form `cte.all().with(cte)`. In SQL, this would give: `WITH cte AS (...) SELECT * FROM cte`.
You can also fetch from `cte.all()`, as long as the request is given the definition of the CTE: `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:
This request, of type `QueryInterfaceRequest<Row>`, can fetch raw database [rows](../README.md#row-queries):
```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]"
let cte = CommonTableExpression(...)
let request = cte.all().with(cte)
let rows = try request.fetchAll(db) // [Row]
```
When you have to fetch from a `CommonTableExpression` which does not have the desired generic type, you can still use the `asRequest(of:)` method:
In order to fetch something else, such as simple [values](../README.md#value-queries), or custom [records](../README.md#records), you have two possible options:
```swift
let cte: CommonTableExpression<Void> = ...
let rows: [Row] = try dbQueue.read { db in
try cte.all().with(cte)
.asRequest(of: Row.self)
.fetchAll(db)
}
```
1. Use the `asRequest(of:)` method:
```swift
let cte = CommonTableExpression(...)
let request = cte.all().with(cte).asRequest(of: Player.self)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
let players = try request.fetchAll(db) // [Player]
```
2. Provide the fetched type to the cte itself:
```swift
let cte = CommonTableExpression<Player>(...)
// ~~~~~~~~
let request = cte.all().with(cte)
let players = try request.fetchAll(db) // [Player]
```
## Associations to Common Table Expressions
@@ -337,7 +324,7 @@ 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>(
let latestMessageCTE = CommonTableExpression(
named: "latestMessage",
request: latestMessageRequest)
```
@@ -378,9 +365,9 @@ And we can fetch the data that feeds our application screen:
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`.
> :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, anonymous `CommonTableExpression` CTEs can work against type safety. When you want to define associations between several CTEs, and make sure the compiler will notice wrong uses of those associations, tag your common table expressions with an explicit type: `CommonTableExpression<SomeType>`.
>
> You can use an existing record type, or an ad-hoc enum. For example:
> To do so, you can use an existing record type, or an ad-hoc enum. For example:
>
> ```swift
> enum CTE1 { }
@@ -389,9 +376,9 @@ let chatInfos: [ChatInfos] = try dbQueue.read(request.fetchAll)
> 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: ...)
> let assoc1 = BaseRecord.association(to: cte1, on: ...) // from BaseRecord to CTE1
> let assoc2 = cte1.association(to: cte2, on: ...) // from CTE1 to CTE2
> let assoc3 = cte2.association(to: FarRecord.self, on: ...) // from CTE2 to FarRecord
>
> // WITH ...
> // SELECT base.* FROM base
@@ -400,12 +387,14 @@ let chatInfos: [ChatInfos] = try dbQueue.read(request.fetchAll)
> // JOIN far ON ...
> let request = BaseRecord
> .with(cte1).with(cte2)
> .joining(required: assoc1
> .joining(required: assoc2
> .joining(required: assoc3)))
> .joining(required: assoc1. // OK
> .joining(required: assoc2. // OK
> .joining(required: assoc3))) // OK
>
> // Compiler error
> let request = BaseRecord.joining(required: assoc2)
> let request = BaseRecord
> .joining(required: assoc2) // Not OK
> .joining(required: assoc3) // Not OK
> ```
[query interface request]: ../README.md#requests
+537
View File
@@ -0,0 +1,537 @@
:twisted_rightwards_arrows: Concurrency
=======================================
**GRDB helps your app deal with SQLite concurrency.**
If your app moves slow database jobs off the main thread, so that the user interface remains responsive, then this guide is for you. In the case of apps that share a database with other processes, such as an iOS app and its extensions, don't miss the dedicated [Sharing a Database] guide after this one.
**In all cases, and first and foremost, follow the [Concurrency Rules] right from the start.**
The other chapters cover, with more details, the fundamentals of SQLite concurrency, and how GRDB makes it manageable from your Swift code.
- [Concurrency Rules]
- [Synchronous and Asynchronous Database Accesses]
- [Safe and Unsafe Database Accesses]
- [Differences between Database Queues and Pools]
- [Concurrent Thinking]
- [Advanced DatabasePool]
- [Database Snapshots]
- [Sharing a Database]
## Concurrency Rules
**The two concurrency rules are strongly recommended practices.** They are all about SQLite, a robust and reliable database that takes great care of your data: don't miss an opportunity to put it on your side!
<a id="rule-1"></a>:point_up: **[Rule 1](#rule-1): Connect to any database file only once**
Open one single [DatabaseQueue] or [DatabasePool] per database file, for the whole duration of your use of the database. Not for the duration of _each_ database access, but really for the duration of _all_ database accesses to this file.
> *Why does this rule exist?* - Since SQLite does not support parallel writes, each [DatabaseQueue] and [DatabasePool] makes sure application threads perform writes one by one, without overlap.
>
> *Practical advice* - An app that uses a single database will connect only once. A document-based app will connect each time a document is opened, and disconnect when the document is closed. See the [demo apps] in order to see how to setup a UIKit or SwiftUI application for a single database.
>
> *What if you do not follow this rule?*
>
> - You will not be able to use the [Database Observation] features.
> - You will see SQLite errors with code 5 ([SQLITE_BUSY]).
<a id="rule-2"></a>:point_up: **[Rule 2](#rule-2): Mind your transactions**
Database operations that are grouped in an SQLite transaction are guaranteed to be either fully saved on disk, or not at all. Read-only transactions have an interesting property as well: they guarantee a stable and immutable view of the database[^1], and do not see changes performed by eventual concurrent writes. In other words, transactions are the one and single tool that helps you enforce and rely on the important invariants of your database (such as "all credits have a matching debit", or "all books have an author").
**You are responsible**, in your Swift code, for delimiting transactions. You do so by grouping database accesses inside a pair of `{ db in ... }` brackets:
```swift
try dbQueue.write { db in /* Inside a transaction */ }
try dbQueue.read { db in /* Inside a transaction */ }
let observation = ValueObservation.tracking { db in /* Inside a transaction */ }`
```
> *Why does this rule exist?* - Because GRDB and SQLite can not guess where to insert the transaction boundaries that protect the invariants of your database. This is your task.
>
> *Practical advice* - See below a correct example, as well as frequent mistakes you should avoid:
>
> <details><summary>Sample code</summary>
>
> In order to insert a money transfer in the database, in a way that enforces the "all credits have a matching debit" invariant, you can write:
>
> ```swift
> // CORRECT: the "all credits have a matching debit" invariant is preserved.
> do {
> try dbQueue.write { db in
> try credit.insert(db)
> try debit.insert(db)
> }
> } catch {
> print("An error occurred: \(error)")
> }
> ```
>
> A frequent mistake is to forget about grouping inside a pair of `{ db in ... }` brackets:
>
> ```swift
> // INCORRECT. Related database operations are not grouped inside
> // one transaction. The invariant is not enforced.
> do {
> try dbQueue.write { db in try credit.insert(db) }
> try dbQueue.write { db in try debit.insert(db) }
> } catch {
> print("An error occurred: \(error)")
> }
> ```
>
> Another frequent mistake is to catch database errors at the wrong place:
>
> ```swift
> // INCORRECT. Related database operations are not grouped inside
> // one transaction, and a failed operation does not prevent
> // subsequent operations from being performed. The invariant is
> // not enforced.
> do {
> try dbQueue.write { db in try credit.insert(db) }
> } catch {
> print("An error occurred: \(error)")
> }
>
> do {
> try dbQueue.write { db in try debit.insert(db) }
> } catch {
> print("An error occurred: \(error)")
> }
> ```
>
> </details>
>
> *What if you do not follow this rule?* - You will see broken database invariants, at runtime, and when your apps wakes up after a crash. You may have a hard time fixing this mess.
## Synchronous and Asynchronous Database Accesses
**You can access the database from any thread, in a synchronous or asynchronous way.**
:arrow_right: **A sync access blocks the current thread** until the database operations are completed:
```swift
let playerCount = try dbQueue.read { db in
try Player.fetchCount(db)
}
let newPlayerCount = try dbQueue.write { db -> Int in
try Player(id: 12, name: "Arthur").insert(db)
return try Player.fetchCount(db)
}
```
It is a programmer error to perform a sync access from any other database access (this restriction can be lifted: see [Safe and Unsafe Database Accesses]):
```swift
try dbQueue.write { db in
// Fatal Error: Database methods are not reentrant.
try dbQueue.write { db in ... }
}
```
:twisted_rightwards_arrows: **An async access does not block the current thread.** Instead, it notifies you when the database operations are completed. There are four ways to access the database asynchronously:
<details>
<summary><b>Swift concurrency</b> (async/await)</summary>
[**:fire: EXPERIMENTAL**](../README.md#what-are-experimental-features) GRDB support for Swift concurrency requires Xcode 13.2+.
```swift
let playerCount = try await dbQueue.read { db in
try Player.fetchCount(db)
}
let newPlayerCount = try await dbQueue.write { db -> Int in
try Player(id: 12, name: "Arthur").insert(db)
return try Player.fetchCount(db)
}
```
Note the identical method names: `read`, `write`. The async version is only available in async Swift functions.
</details>
<details>
<summary><b>Combine publishers</b></summary>
```swift
let playerCountPublisher = dbQueue.readPublisher { db in
try Player.fetchCount(db)
}
let newPlayerCountPublisher = dbQueue.writePublisher { db -> Int in
try Player(id: 12, name: "Arthur").insert(db)
return try Player.fetchCount(db)
}
```
Those publishers do not access the database until they are subscribed. They complete on the main dispatch queue by default. See [GRDB ❤️ Combine].
</details>
<details>
<summary><b>RxSwift observables</b></summary>
```swift
let playerCountObservable = dbQueue.rx.read { db in
try Player.fetchCount(db)
}
let newPlayerCountObservable = dbQueue.rx.write { db -> Int in
try Player(id: 12, name: "Arthur").insert(db)
return try Player.fetchCount(db)
}
```
Those observables do not access the database until they are subscribed. They complete on the main dispatch queue by default. See the companion library [RxGRDB].
</details>
<details>
<summary><b>Completion blocks</b></summary>
```swift
dbQueue.asyncRead { (dbResult: Result<Database, Error>) in
do {
// Maybe read access could not be established
let db = try dbResult.get()
let playerCount = try Player.fetchCount(db)
... // Handle playerCount
} catch {
... // Handle error
}
}
dbQueue.asyncWrite({ (db: Database) -> Int in
try Player(id: 12, name: "Arthur").insert(db)
return try Player.fetchCount(db)
}, completion: { (db: Database, result: Result<Int, Error>) in
// Handle write transaction result:
switch result {
case let .success(newPlayerCount):
... // Handle newPlayerCount
case let .failure(error):
... // Handle error
}
})
```
</details>
During one async access, all individual database operations grouped inside (fetch, insert, etc.) are synchronous:
```swift
// One asynchronous access...
try await dbQueue.write { db in
// ... always performs synchronous database operations:
try Player(...).insert(db)
try Player(...).insert(db)
let players = try Player.fetchAll(db)
}
```
This is true for all async techniques.
This prevents the database operations from various concurrent accesses from being interleaved, with disastrous consequences. For example, one access must not be able to issue a `COMMIT` statement in the middle of an unfinished concurrent write!
## Safe and Unsafe Database Accesses
**You will generally use the safe database access methods `read` and `write`.** In this context, "safe" means that a database access is concurrency-friendly, because GRDB provides the following guarantees:
- <a id="guarantee-serialized-writes"></a>**[Serialized Writes]** - All writes performed by one [DatabaseQueue] or [DatabasePool] instance are serialized. *Why is it important?* - this guarantee prevents [SQLITE_BUSY] errors during concurrent writes.
- <a id="guarantee-write-transactions"></a>**[Write Transactions]** - All writes are wrapped in a transaction. *Why is it important?* - concurrent reads can not see partial database updates (even reads performed by other processes).
- <a id="guarantee-isolated-reads"></a>**[Isolated Reads]** - All reads are wrapped in a transaction. *Why is it important?* - an isolated read sees a stable and immutable state of the database[^1], and does not see changes performed by eventual concurrent writes (even writes performed by other processes).
- <a id="guarantee-forbidden-writes"></a>**[Forbidden Writes]** - Inside a read access, all attempts to write raise an error. *Why is it important?* - this enforces the immutability of the database during a read.
- <a id="guarantee-non-reentrancy"></a>**[Non-Reentrancy]** - Database accesses are not reentrant. *Why is it important?* - this reduces the opportunities for deadlocks, and fosters the clear transaction boundaries of the [second concurrency rule](#rule-2).
Some applications need to relax this safety net, in order to achieve specific SQLite operations. In this case, replace `read` and `write` with one of the methods below:
- **Write outside of any transaction**
(Lifted guarantee: [Write Transactions])
```swift
try dbQueue.writeWithoutTransaction { db in ... }
```
`writeWithoutTransaction` is also available as an `async` function. You can also use `asyncWriteWithoutTransaction`.
- **Write outside of any transaction, and prevents concurrent reads**
(Lifted guarantee: [Write Transactions])
```swift
try dbQueue.barrierWriteWithoutTransaction { db in ... }
```
The barrier write guarantees an exclusive access to the database: the method blocks until all concurrent database accesses are completed, reads and writes, and postpones all other accesses until it completes.
There is a known limitation: database accesses performed by other processes, and reads performed by [DatabaseSnapshot] are out of scope of this barrier, and can run concurrently with the barrier.
You will use this method, for example, when you [change the password](../README.md#changing-the-passphrase-of-an-encrypted-database) of an encrypted database.
`barrierWriteWithoutTransaction` is also available as an `async` function. You can also use `asyncBarrierWriteWithoutTransaction`.
- **Reentrant write outside of any transaction**
(Lifted guarantees: [Write Transactions], [Non-Reentrancy])
```swift
try dbQueue.unsafeReentrantWrite { db in ... }
```
Reentrant writes can be performed from any other database access:
```swift
try dbQueue.write { db in
// No fatal error
try dbQueue.unsafeReentrantWrite { db in ... }
}
```
`unsafeReentrantWrite` has no async version.
- **Read outside of any transaction**
(Lifted guarantees: [Isolated Reads], [Forbidden Writes])
```swift
try dbQueue.unsafeRead { db in ... }
```
`unsafeRead` is also available as an `async` function.
- **Reentrant read, outside of any transaction**
(Lifted guarantees: [Isolated Reads], [Forbidden Writes], [Non-Reentrancy])
```swift
try dbQueue.unsafeReentrantRead { db in ... }
```
Reentrant reads can be performed from any other database access:
```swift
try dbQueue.write { db in
// No fatal error
try dbQueue.unsafeReentrantRead { db in ... }
}
```
`unsafeReentrantRead` has no async version.
:point_up: **By using one of the methods above, you become responsible of the thread-safety of your application.** Please understand the consequences of lifting each concurrency guarantee. Some guarantees can also be restored at your convenience:
- The [Write Transactions] and [Isolated Reads] guarantees can be restored at any point, by opening an [explicit transaction](../README.md#transactions-and-savepoints). For example:
```swift
try dbQueue.writeWithoutTransaction { db in
try db.inTransaction {
...
return .commit
}
}
```
- The [Forbidden Writes] guarantee can only be lifted with [DatabaseQueue]. It can be restored with [`PRAGMA query_only`](https://www.sqlite.org/pragma.html#pragma_query_only).
## Differences between Database Queues and Pools
Despite the common [guarantees](#safe-and-unsafe-database-accesses) and [rules](#concurrency-rules) shared by database queues and pools, those two database accessors don't have the same behavior.
[DatabaseQueue] opens a single database connection, and serializes all database accesses, reads, and writes. There is never more than one thread that uses the database. In the image below, we see how three threads can see the database as time passes:
![DatabaseQueueScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabaseQueueScheduling.svg)
[DatabasePool] manages a pool of several database connections, and allows concurrent reads and writes thanks to the [WAL mode](https://www.sqlite.org/wal.html). A database pool serializes all writes (the [Serialized Writes] guarantee). Reads are isolated so that they don't see changes performed by other threads (the [Isolated Reads] guarantee). This gives a very different picture:
![DatabasePoolScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolScheduling.svg)
See how, with database pools, two reads can see different database states at the same time. This may look scary! Please see the next [Concurrent Thinking] chapter below for a relief.
## Concurrent Thinking
Despite their [differences](#differences-between-database-queues-and-pools), you can write robust code that works equally well with both database queues and pools.
This allows your app to switch between queues and pools, at your convenience:
- The [demo applications] share the same database code for the on-disk pool that feeds the app, and the in-memory queue that feeds tests and SwiftUI previews. This makes sure tests and previews run fast, without any temporary file, with the same behavior as the app.
- Applications that perform slow write transactions (when saving a lot of data from a remote server, for example) may want to replace their queue with a pool so that the reads that feed their user interface can run in parallel.
All you need is a little "concurrent thinking", based on those two basic facts:
- You are sure, when you perform a write access, that you deal with the latest database state on disk. This is enforced by SQLite, which simply can't perform parallel writes, and by GRDB database queues and pools, which make sure [only one thread can write](#guarantee-serialized-writes). As for writes performed by other processes, they can only trigger [SQLITE_BUSY] errors [that you can handle](SharingADatabase.md).
- Whenever you extract some data from a database access, immediately consider it as _stale_. It is stale, whether you use a database queue or a database pool. It is stale because nothing prevents other application threads or processes from overwriting the value you have just fetched:
<img align="right" src="https://github.com/groue/GRDB.swift/raw/master/Documentation/Images/TwoCookiesLeft.jpg" width="50%">
```swift
// or dbQueue.write, for that matter
let cookieCount = dbPool.read { db in
try Cookie.fetchCount(db)
}
// At this point, the number of cookies on disk
// may have already changed.
print("We have \(cookieCount) cookies left")
```
Does this mean you can't rely on anything? Of course not:
- If you intend to display the database content on screen, use [ValueObservation]: it always eventually notifies the latest state of the database. You won't display stale values for a long time [^2].
- As said above, the moment of truth is the next write access!
## Advanced DatabasePool
[DatabasePool] is very concurrent, since all reads can run in parallel, and can even run during write operations. But writes are still serialized: at any given point in time, there is no more than a single thread that is writing into the database.
When your application modifies the database, and then reads some value that depends on those modifications, you may want to avoid blocking concurrent writes longer than necessary:
```swift
try dbPool.write { db in
// Increment the number of players
try Player(...).insert(db)
try Player(...).insert(db)
// Read the number of players. Concurrent writes are blocked :-(
let newPlayerCount = try Player.fetchCount(db)
}
```
:arrow_right: The solution is the `concurrentRead` method. It must be called from within a write access, outside of any transaction. It returns a *future value* which you consume any time later, with the `wait()` method.
```swift
let future: DatabaseFuture<Int> = try dbPool.writeWithoutTransaction { db in
// Increment the number of players
try db.inTransaction {
try Player(...).insert(db)
try Player(...).insert(db)
return .commit
}
// <- Not in a transaction here
let future = dbPool.concurrentRead { db
try Player.fetchCount(db)
}
return future
}
// <- Concurrent writes can be performed :-)
// Wait and handle newPlayerCount
let newPlayerCount = try future.wait()
```
:twisted_rightwards_arrows: The async version of `concurrentRead` is `asyncConcurrentRead`:
```swift
try dbPool.writeWithoutTransaction { db in
// Increment the number of players
try db.inTransaction {
try Player(...).insert(db)
try Player(...).insert(db)
return .commit
}
// <- Not in a transaction here
dbPool.asyncConcurrentRead { dbResult in
do {
// Maybe read access could not be established
let db = try dbResult.get()
let newPlayerCount = try Player.fetchCount(db)
// Handle newPlayerCount
} catch {
// Handle error
}
}
}
```
`concurrentRead` and `asyncConcurrentRead` block until they can guarantee their closure argument an isolated access to the database, in the exact state left by the last transaction. It then asynchronously executes this closure.
In the illustration below, the striped band shows the delay needed for the reading thread to acquire isolation. Until then, no other thread can write:
![DatabasePoolConcurrentRead](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolConcurrentRead.svg)
[Transaction Observers](../README.md#transactionobserver-protocol) can also use those methods in their `databaseDidCommit` method, in order to process database changes without blocking other threads that want to write into the database.
## Database Snapshots
**[DatabasePool] can take snapshots.** A database snapshot sees an unchanging database content, as it existed at the moment it was created.
"Unchanging" means that a snapshot never sees any database modifications during all its lifetime. And yet it doesn't prevent database updates. This "magic" is made possible by SQLite's WAL mode (see [Isolation In SQLite](https://sqlite.org/isolation.html)).
```swift
let snapshot = try dbPool.makeSnapshot()
```
You can create as many snapshots as you need, regardless of the [maximum number of readers](../README.md#database-configuration) in the pool. A snapshot database connection is closed when the snapshot is deinitialized.
**A snapshot can be used from any thread.** It has the same [synchronous and asynchronous reading methods](#synchronous-and-asynchronous-database-accesses) as database queues and pools:
```swift
let playerCount = try snapshot.read { db in
try Player.fetchCount(db)
}
```
When you want to control the latest committed changes seen by a snapshot, create the snapshot from within a write, outside of any transaction:
```swift
let snapshot1 = try dbPool.writeWithoutTransaction { db -> DatabaseSnapshot in
try db.inTransaction {
// delete all players
try Player.deleteAll()
return .commit
}
// <- not in a transaction here
return dbPool.makeSnapshot()
}
// <- Other threads may modify the database here
let snapshot2 = try dbPool.makeSnapshot()
try snapshot1.read { db in
// Guaranteed to be zero
try Player.fetchCount(db)
}
try snapshot2.read { db in
// Could be anything
try Player.fetchCount(db)
}
```
> :point_up: **Note**: snapshots currently serialize all database accesses. In the future, snapshots may allow concurrent reads.
[^1]: This immutable view of the database is called [snapshot isolation](https://www.sqlite.org/isolation.html).
[^2]: After the database has been changed on disk, GRDB has to fetch the fresh value, and then hop to the main thread. Only then your screen can be updated.
[Concurrency Rules]: #concurrency-rules
[Synchronous and Asynchronous Database Accesses]: #synchronous-and-asynchronous-database-accesses
[Safe and Unsafe Database Accesses]: #safe-and-unsafe-database-accesses
[Differences between Database Queues and Pools]: #differences-between-database-queues-and-pools
[Concurrent Thinking]: #concurrent-thinking
[Advanced DatabasePool]: #advanced-databasepool
[Database Snapshots]: #database-snapshots
[DatabaseQueue]: ../README.md#database-queues
[DatabasePool]: ../README.md#database-pools
[DatabaseSnapshot]: #database-snapshots
[demo apps]: DemoApps
[Database Observation]: ../README.md#database-changes-observation
[SQLITE_BUSY]: https://www.sqlite.org/rescode.html#busy
[Sharing a Database]: SharingADatabase.md
[ValueObservation]: ../README.md#valueobservation
[GRDB ❤️ Combine]: Combine.md
[RxGRDB]: https://github.com/RxSwiftCommunity/RxGRDB
[Serialized Writes]: #guarantee-serialized-writes
[Write Transactions]: #guarantee-write-transactions
[Isolated Reads]: #guarantee-isolated-reads
[Forbidden Writes]: #guarantee-forbidden-writes
[Non-Reentrancy]: #guarantee-non-reentrancy
[demo applications]: DemoApps
+1 -1
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.33.0](https://www.sqlite.org/changes.html).**
**You can build GRDB with a custom build of [SQLite 3.37.2](https://www.sqlite.org/changes.html).**
A custom SQLite build can activate extra SQLite features, and extra GRDB features as well, such as support for the [FTS5 full-text search engine](../../../#full-text-search), and [SQLite Pre-Update Hooks](../../../#support-for-sqlite-pre-update-hooks).
@@ -0,0 +1,727 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
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 */; };
56519DCA274FC8E900ED16D8 /* GRDBQuery in Frameworks */ = {isa = PBXBuildFile; productRef = 56519DC9274FC8E900ED16D8 /* GRDBQuery */; };
5671723A261B23C800423B6F /* PlayerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56717239261B23C800423B6F /* PlayerList.swift */; };
56717252261B334D00423B6F /* PlayerRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56717251261B334D00423B6F /* PlayerRequestTests.swift */; };
567C3E1A2520B6DE0011F6E9 /* GRDBAsyncDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E192520B6DE0011F6E9 /* GRDBAsyncDemoApp.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 */; };
567C3E5D2520B75C0011F6E9 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E532520B75C0011F6E9 /* Player.swift */; };
567C3E5E2520B75C0011F6E9 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E542520B75C0011F6E9 /* Persistence.swift */; };
567C3E612520B75D0011F6E9 /* PlayerFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E592520B75C0011F6E9 /* PlayerFormView.swift */; };
567C3E622520B75D0011F6E9 /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5A2520B75C0011F6E9 /* AppView.swift */; };
567C3E632520B75D0011F6E9 /* PlayerCreationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5B2520B75C0011F6E9 /* PlayerCreationView.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 */; };
56B6D1092619EC1B003CC455 /* PlayerRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B6D1082619EC1B003CC455 /* PlayerRequest.swift */; };
56F8A13527359A5A0011ACBE /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 56F8A13427359A5A0011ACBE /* GRDB */; };
78E2F9E6261EEC22005D1F7F /* GRDBAsyncDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78E2F9E5261EEC22005D1F7F /* GRDBAsyncDemoUITests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
56026C9D25B8A7D000D1DF3F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E0E2520B6DE0011F6E9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 567C3E152520B6DE0011F6E9;
remoteInfo = GRDBAsyncDemo;
};
78E2F9E8261EEC22005D1F7F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 567C3E0E2520B6DE0011F6E9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 567C3E152520B6DE0011F6E9;
remoteInfo = GRDBAsyncDemo;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
567C3E502520B70E0011F6E9 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
56026C9825B8A7D000D1DF3F /* GRDBAsyncDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBAsyncDemoTests.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>"; };
56717239261B23C800423B6F /* PlayerList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerList.swift; sourceTree = "<group>"; };
56717251261B334D00423B6F /* PlayerRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRequestTests.swift; sourceTree = "<group>"; };
567C3E162520B6DE0011F6E9 /* GRDBAsyncDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBAsyncDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
567C3E192520B6DE0011F6E9 /* GRDBAsyncDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRDBAsyncDemoApp.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>"; };
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>"; };
567C3E592520B75C0011F6E9 /* PlayerFormView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerFormView.swift; sourceTree = "<group>"; };
567C3E5A2520B75C0011F6E9 /* AppView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
567C3E5B2520B75C0011F6E9 /* PlayerCreationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerCreationView.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>"; };
56B6D1082619EC1B003CC455 /* PlayerRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRequest.swift; sourceTree = "<group>"; };
56F8A12E27359A350011ACBE /* GRDB.swift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = GRDB.swift; path = ../../..; sourceTree = "<group>"; };
78E2F9E3261EEC22005D1F7F /* GRDBAsyncDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBAsyncDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
78E2F9E5261EEC22005D1F7F /* GRDBAsyncDemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRDBAsyncDemoUITests.swift; sourceTree = "<group>"; };
78E2F9E7261EEC22005D1F7F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
56026C9525B8A7D000D1DF3F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
567C3E132520B6DE0011F6E9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
56519DCA274FC8E900ED16D8 /* GRDBQuery in Frameworks */,
56F8A13527359A5A0011ACBE /* GRDB in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
78E2F9E0261EEC22005D1F7F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
56026C9925B8A7D000D1DF3F /* GRDBAsyncDemoTests */ = {
isa = PBXGroup;
children = (
56026C9C25B8A7D000D1DF3F /* Info.plist */,
56026CAB25B8A7EF00D1DF3F /* AppDatabaseTests.swift */,
56717251261B334D00423B6F /* PlayerRequestTests.swift */,
56026CAA25B8A7EF00D1DF3F /* PlayerTests.swift */,
);
path = GRDBAsyncDemoTests;
sourceTree = "<group>";
};
56185BC125B8047D00B9C30F /* Resources */ = {
isa = PBXGroup;
children = (
567C3E1D2520B6DF0011F6E9 /* Assets.xcassets */,
567C3E772520BB650011F6E9 /* LaunchScreen.storyboard */,
567C3E752520BB650011F6E9 /* Localizable.stringsdict */,
);
path = Resources;
sourceTree = "<group>";
};
567C3E0D2520B6DE0011F6E9 = {
isa = PBXGroup;
children = (
567C3E182520B6DE0011F6E9 /* GRDBAsyncDemo */,
56026C9925B8A7D000D1DF3F /* GRDBAsyncDemoTests */,
78E2F9E4261EEC22005D1F7F /* GRDBAsyncDemoUITests */,
567C3E172520B6DE0011F6E9 /* Products */,
567C3E4D2520B70E0011F6E9 /* Frameworks */,
56F8A12E27359A350011ACBE /* GRDB.swift */,
);
sourceTree = "<group>";
};
567C3E172520B6DE0011F6E9 /* Products */ = {
isa = PBXGroup;
children = (
567C3E162520B6DE0011F6E9 /* GRDBAsyncDemo.app */,
56026C9825B8A7D000D1DF3F /* GRDBAsyncDemoTests.xctest */,
78E2F9E3261EEC22005D1F7F /* GRDBAsyncDemoUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
567C3E182520B6DE0011F6E9 /* GRDBAsyncDemo */ = {
isa = PBXGroup;
children = (
567C3E222520B6DF0011F6E9 /* Info.plist */,
567C3E652520B7880011F6E9 /* AppDatabase.swift */,
567C3E192520B6DE0011F6E9 /* GRDBAsyncDemoApp.swift */,
567C3E542520B75C0011F6E9 /* Persistence.swift */,
567C3E532520B75C0011F6E9 /* Player.swift */,
56B6D1082619EC1B003CC455 /* PlayerRequest.swift */,
567C3E1F2520B6DF0011F6E9 /* Preview Content */,
56185BC125B8047D00B9C30F /* Resources */,
567C3E582520B75C0011F6E9 /* Views */,
);
path = GRDBAsyncDemo;
sourceTree = "<group>";
};
567C3E1F2520B6DF0011F6E9 /* Preview Content */ = {
isa = PBXGroup;
children = (
567C3E202520B6DF0011F6E9 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
567C3E4D2520B70E0011F6E9 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
567C3E582520B75C0011F6E9 /* Views */ = {
isa = PBXGroup;
children = (
567C3E5A2520B75C0011F6E9 /* AppView.swift */,
567C3E5B2520B75C0011F6E9 /* PlayerCreationView.swift */,
567C3E5C2520B75C0011F6E9 /* PlayerEditionView.swift */,
567C3E592520B75C0011F6E9 /* PlayerFormView.swift */,
56717239261B23C800423B6F /* PlayerList.swift */,
);
path = Views;
sourceTree = "<group>";
};
78E2F9E4261EEC22005D1F7F /* GRDBAsyncDemoUITests */ = {
isa = PBXGroup;
children = (
78E2F9E5261EEC22005D1F7F /* GRDBAsyncDemoUITests.swift */,
78E2F9E7261EEC22005D1F7F /* Info.plist */,
);
path = GRDBAsyncDemoUITests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
56026C9725B8A7D000D1DF3F /* GRDBAsyncDemoTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56026CA825B8A7D000D1DF3F /* Build configuration list for PBXNativeTarget "GRDBAsyncDemoTests" */;
buildPhases = (
56026C9425B8A7D000D1DF3F /* Sources */,
56026C9525B8A7D000D1DF3F /* Frameworks */,
56026C9625B8A7D000D1DF3F /* Resources */,
);
buildRules = (
);
dependencies = (
56026C9E25B8A7D000D1DF3F /* PBXTargetDependency */,
);
name = GRDBAsyncDemoTests;
productName = GRDBAsyncDemoTests;
productReference = 56026C9825B8A7D000D1DF3F /* GRDBAsyncDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
567C3E152520B6DE0011F6E9 /* GRDBAsyncDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 567C3E252520B6DF0011F6E9 /* Build configuration list for PBXNativeTarget "GRDBAsyncDemo" */;
buildPhases = (
567C3E122520B6DE0011F6E9 /* Sources */,
567C3E132520B6DE0011F6E9 /* Frameworks */,
567C3E142520B6DE0011F6E9 /* Resources */,
567C3E502520B70E0011F6E9 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
56F8A13127359A540011ACBE /* PBXTargetDependency */,
);
name = GRDBAsyncDemo;
packageProductDependencies = (
56F8A13427359A5A0011ACBE /* GRDB */,
56519DC9274FC8E900ED16D8 /* GRDBQuery */,
);
productName = GRBCombineDemo;
productReference = 567C3E162520B6DE0011F6E9 /* GRDBAsyncDemo.app */;
productType = "com.apple.product-type.application";
};
78E2F9E2261EEC22005D1F7F /* GRDBAsyncDemoUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 78E2F9F3261EEC22005D1F7F /* Build configuration list for PBXNativeTarget "GRDBAsyncDemoUITests" */;
buildPhases = (
78E2F9DF261EEC22005D1F7F /* Sources */,
78E2F9E0261EEC22005D1F7F /* Frameworks */,
78E2F9E1261EEC22005D1F7F /* Resources */,
);
buildRules = (
);
dependencies = (
78E2F9E9261EEC22005D1F7F /* PBXTargetDependency */,
);
name = GRDBAsyncDemoUITests;
productName = GRDBAsyncDemoUITests;
productReference = 78E2F9E3261EEC22005D1F7F /* GRDBAsyncDemoUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
567C3E0E2520B6DE0011F6E9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1200;
TargetAttributes = {
56026C9725B8A7D000D1DF3F = {
CreatedOnToolsVersion = 12.3;
TestTargetID = 567C3E152520B6DE0011F6E9;
};
567C3E152520B6DE0011F6E9 = {
CreatedOnToolsVersion = 12.0;
};
78E2F9E2261EEC22005D1F7F = {
CreatedOnToolsVersion = 12.5;
TestTargetID = 567C3E152520B6DE0011F6E9;
};
};
};
buildConfigurationList = 567C3E112520B6DE0011F6E9 /* Build configuration list for PBXProject "GRDBAsyncDemo" */;
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 567C3E0D2520B6DE0011F6E9;
packageReferences = (
56519DC8274FC8E900ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */,
);
productRefGroup = 567C3E172520B6DE0011F6E9 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
567C3E152520B6DE0011F6E9 /* GRDBAsyncDemo */,
56026C9725B8A7D000D1DF3F /* GRDBAsyncDemoTests */,
78E2F9E2261EEC22005D1F7F /* GRDBAsyncDemoUITests */,
);
};
/* End PBXProject 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;
};
78E2F9E1261EEC22005D1F7F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
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 */,
56717252261B334D00423B6F /* PlayerRequestTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
567C3E122520B6DE0011F6E9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
567C3E5E2520B75C0011F6E9 /* Persistence.swift in Sources */,
567C3E5D2520B75C0011F6E9 /* Player.swift in Sources */,
56B6D1092619EC1B003CC455 /* PlayerRequest.swift in Sources */,
5671723A261B23C800423B6F /* PlayerList.swift in Sources */,
567C3E612520B75D0011F6E9 /* PlayerFormView.swift in Sources */,
567C3E632520B75D0011F6E9 /* PlayerCreationView.swift in Sources */,
567C3E662520B7880011F6E9 /* AppDatabase.swift in Sources */,
567C3E622520B75D0011F6E9 /* AppView.swift in Sources */,
567C3E642520B75D0011F6E9 /* PlayerEditionView.swift in Sources */,
567C3E1A2520B6DE0011F6E9 /* GRDBAsyncDemoApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
78E2F9DF261EEC22005D1F7F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
78E2F9E6261EEC22005D1F7F /* GRDBAsyncDemoUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
56026C9E25B8A7D000D1DF3F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 567C3E152520B6DE0011F6E9 /* GRDBAsyncDemo */;
targetProxy = 56026C9D25B8A7D000D1DF3F /* PBXContainerItemProxy */;
};
56F8A13127359A540011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 56F8A13027359A540011ACBE /* GRDB */;
};
78E2F9E9261EEC22005D1F7F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 567C3E152520B6DE0011F6E9 /* GRDBAsyncDemo */;
targetProxy = 78E2F9E8261EEC22005D1F7F /* 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 = GRDBAsyncDemoTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBAsyncDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBAsyncDemo.app/GRDBAsyncDemo";
};
name = Debug;
};
56026CA025B8A7D000D1DF3F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = GRDBAsyncDemoTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBAsyncDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GRDBAsyncDemo.app/GRDBAsyncDemo";
};
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 = 15.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 = 15.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 = "\"GRDBAsyncDemo/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBAsyncDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBAsyncDemo;
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 = "\"GRDBAsyncDemo/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBAsyncDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBAsyncDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
78E2F9EA261EEC22005D1F7F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GRDBAsyncDemoUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.groue.GRDBAsyncDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = GRDBAsyncDemo;
};
name = Debug;
};
78E2F9EB261EEC22005D1F7F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GRDBAsyncDemoUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.groue.GRDBAsyncDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = GRDBAsyncDemo;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56026CA825B8A7D000D1DF3F /* Build configuration list for PBXNativeTarget "GRDBAsyncDemoTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56026C9F25B8A7D000D1DF3F /* Debug */,
56026CA025B8A7D000D1DF3F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
567C3E112520B6DE0011F6E9 /* Build configuration list for PBXProject "GRDBAsyncDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
567C3E232520B6DF0011F6E9 /* Debug */,
567C3E242520B6DF0011F6E9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
567C3E252520B6DF0011F6E9 /* Build configuration list for PBXNativeTarget "GRDBAsyncDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
567C3E262520B6DF0011F6E9 /* Debug */,
567C3E272520B6DF0011F6E9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
78E2F9F3261EEC22005D1F7F /* Build configuration list for PBXNativeTarget "GRDBAsyncDemoUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
78E2F9EA261EEC22005D1F7F /* Debug */,
78E2F9EB261EEC22005D1F7F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
56519DC8274FC8E900ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/groue/GRDBQuery";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.1.0;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
56519DC9274FC8E900ED16D8 /* GRDBQuery */ = {
isa = XCSwiftPackageProductDependency;
package = 56519DC8274FC8E900ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */;
productName = GRDBQuery;
};
56F8A13027359A540011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
56F8A13427359A5A0011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 567C3E0E2520B6DE0011F6E9 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -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>
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "GRDBQuery",
"repositoryURL": "https://github.com/groue/GRDBQuery",
"state": {
"branch": null,
"revision": "4301166cd2aee9ce37b4057c9a58f5cc3bbeae06",
"version": "0.1.0"
}
}
]
},
"version": 1
}
@@ -0,0 +1,98 @@
<?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 = "GRDBAsyncDemo.app"
BlueprintName = "GRDBAsyncDemo"
ReferencedContainer = "container:GRDBAsyncDemo.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 = "GRDBAsyncDemoTests.xctest"
BlueprintName = "GRDBAsyncDemoTests"
ReferencedContainer = "container:GRDBAsyncDemo.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "78E2F9E2261EEC22005D1F7F"
BuildableName = "GRDBAsyncDemoUITests.xctest"
BlueprintName = "GRDBAsyncDemoUITests"
ReferencedContainer = "container:GRDBAsyncDemo.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 = "GRDBAsyncDemo.app"
BlueprintName = "GRDBAsyncDemo"
ReferencedContainer = "container:GRDBAsyncDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "567C3E152520B6DE0011F6E9"
BuildableName = "GRDBAsyncDemo.app"
BlueprintName = "GRDBAsyncDemo"
ReferencedContainer = "container:GRDBAsyncDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,168 @@
import Foundation
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 {
/// A validation error that prevents some players from being saved into
/// the database.
enum ValidationError: LocalizedError {
case missingName
var errorDescription: String? {
switch self {
case .missingName:
return "Please provide a name"
}
}
}
/// 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) async throws {
if player.name.isEmpty {
throw ValidationError.missingName
}
player = try await dbWriter.write { [player] db in
try player.saved(db)
}
}
/// Delete the specified players
func deletePlayers(ids: [Int64]) async throws {
try await dbWriter.write { db in
_ = try Player.deleteAll(db, ids: ids)
}
}
/// Delete all players
func deleteAllPlayers() async throws {
try await dbWriter.write { db in
_ = try Player.deleteAll(db)
}
}
/// Refresh all players (by performing some random changes, for demo purpose).
func refreshPlayers() async throws {
try await dbWriter.write { db in
if try Player.all().isEmpty(db) {
// When database is empty, insert new random players
try createRandomPlayers(db)
} else {
// Insert a player
if Bool.random() {
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
// 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.all().isEmpty(db) {
try createRandomPlayers(db)
}
}
}
static let uiTestPlayers = [
Player(id: nil, name: "Arthur", score: 5),
Player(id: nil, name: "Barbara", score: 6),
Player(id: nil, name: "Craig", score: 8),
Player(id: nil, name: "David", score: 4),
Player(id: nil, name: "Elena", score: 1),
Player(id: nil, name: "Frederik", score: 2),
Player(id: nil, name: "Gilbert", score: 7),
Player(id: nil, name: "Henriette", score: 3)]
func createPlayersForUITests() throws {
try dbWriter.write { db in
try AppDatabase.uiTestPlayers.forEach { player in
_ = try player.inserted(db) // insert but ignore inserted id
}
}
}
/// Support for `createRandomPlayersIfEmpty()` and `refreshPlayers()`.
private func createRandomPlayers(_ db: Database) throws {
for _ in 0..<8 {
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
}
}
// MARK: - Database Access: Reads
// This demo app does not provide any specific reading method, and instead
// gives an unrestricted read-only access to the rest of the application.
// In your app, you are free to choose another path, and define focused
// reading methods.
extension AppDatabase {
/// Provides a read-only access to the database
var databaseReader: DatabaseReader {
dbWriter
}
}
@@ -0,0 +1,40 @@
import GRDBQuery
import SwiftUI
@main
struct GRDBAsyncDemoApp: App {
var body: some Scene {
WindowGroup {
AppView().environment(\.appDatabase, .shared)
}
}
}
// MARK: - Give SwiftUI access to the database
//
// Define a new environment key that grants access to an AppDatabase.
//
// The technique is documented at
// <https://developer.apple.com/documentation/swiftui/environmentkey>.
private struct AppDatabaseKey: EnvironmentKey {
static var defaultValue: AppDatabase { .empty() }
}
extension EnvironmentValues {
var appDatabase: AppDatabase {
get { self[AppDatabaseKey.self] }
set { self[AppDatabaseKey.self] = newValue }
}
}
// In this demo app, views observe the database with the @Query property
// wrapper, defined in the GRDBQuery package. Its documentation recommends to
// define a dedicated initializer for `appDatabase` access, so we comply:
extension Query where Request.DatabaseContext == AppDatabase {
/// Convenience initializer for requests that feed from `AppDatabase`.
init(_ request: Request) {
self.init(request, in: \.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,72 @@
import Foundation
import GRDB
extension AppDatabase {
/// The database for the application
static let shared = makeShared()
private static func makeShared() -> AppDatabase {
do {
// Pick 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)
// Support for tests: delete the database if requested
if CommandLine.arguments.contains("-reset") {
try? fileManager.removeItem(at: folderURL)
}
// Create the database folder if needed
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)
// Prepare the database with test fixtures if requested
if CommandLine.arguments.contains("-fixedTestData") {
try appDatabase.createPlayersForUITests()
} else {
// Otherwise, 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,106 @@
import GRDB
/// The Player struct.
///
/// Identifiable conformance supports SwiftUI list animations, and type-safe
/// GRDB primary key methods.
/// 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 makeRandom() -> 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,55 @@
import Combine
import GRDB
import GRDBQuery
/// A player request can be used with the `@Query` property wrapper in order to
/// feed a view with a list of players.
///
/// For example:
///
/// struct MyView: View {
/// @Query(PlayerRequest(ordering: .byName)) private var players: [Player]
///
/// var body: some View {
/// List(players) { player in ... )
/// }
/// }
struct PlayerRequest: Queryable {
enum Ordering {
case byScore
case byName
}
/// The ordering used by the player request.
var ordering: Ordering
// MARK: - Queryable Implementation
static var defaultValue: [Player] { [] }
func publisher(in appDatabase: AppDatabase) -> AnyPublisher<[Player], Error> {
// Build the publisher from the general-purpose read-only access
// granted by `appDatabase.databaseReader`.
// Some apps will prefer to call a dedicated method of `appDatabase`.
ValueObservation
.tracking(fetchValue(_:))
.publisher(
in: appDatabase.databaseReader,
// The `.immediate` scheduling feeds the view right on
// subscription, and avoids an undesired animation when the
// application starts.
scheduling: .immediate)
.eraseToAnyPublisher()
}
// This method is not required by Queryable, but it makes it easier
// to test PlayerRequest.
func fetchValue(_ db: Database) throws -> [Player] {
switch ordering {
case .byScore:
return try Player.all().orderedByScore().fetchAll(db)
case .byName:
return try Player.all().orderedByName().fetchAll(db)
}
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -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: 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: 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 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,154 @@
import GRDBQuery
import SwiftUI
/// The main application view
struct AppView: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
/// The `players` property is automatically updated when the database changes
@Query(PlayerRequest(ordering: .byScore)) private var players: [Player]
/// We'll need to leave edit mode in several occasions.
@State private var editMode = EditMode.inactive
/// Tracks the presentation of the player creation sheet.
@State private var newPlayerIsPresented = false
// If you want to define the query on initialization, you will prefer:
//
// @Query<PlayerRequest> private var players: [Player]
//
// init(initialOrdering: PlayerRequest.Ordering) {
// _players = Query(PlayerRequest(ordering: initialOrdering))
// }
var body: some View {
NavigationView {
PlayerList(players: players)
.navigationBarTitle(Text("\(players.count) Players"))
.navigationBarItems(
leading: HStack {
EditButton()
newPlayerButton
},
trailing: ToggleOrderingButton(
ordering: $players.ordering,
willChange: {
// onChange(of: $players.wrappedValue.ordering)
// is not able to leave the editing mode during
// the animation of the list content.
// Workaround: stop editing before the ordering
// is changed, and the list content is updated.
stopEditing()
}))
.toolbar { toolbarContent }
.onChange(of: players) { players in
if players.isEmpty {
stopEditing()
}
}
.environment(\.editMode, $editMode)
}
}
private var toolbarContent: some ToolbarContent {
ToolbarItemGroup(placement: .bottomBar) {
Button {
// Don't stopEditing() here because this is
// performed `onChange(of: players)`
Task {
try? await appDatabase.deleteAllPlayers()
}
} label: {
Image(systemName: "trash").imageScale(.large)
}
Spacer()
Button {
stopEditing()
Task {
try? await appDatabase.refreshPlayers()
}
} label: {
Image(systemName: "arrow.clockwise").imageScale(.large)
}
Spacer()
Button {
stopEditing()
// Perform 50 refreshes in parallel
Task {
try? await withThrowingTaskGroup(of: Void.self) { group in
for _ in 0..<50 {
_ = group.addTaskUnlessCancelled {
try await appDatabase.refreshPlayers()
}
}
try await group.waitForAll()
}
}
} label: {
Image(systemName: "tornado").imageScale(.large)
}
}
}
/// The button that presents the player creation sheet.
private var newPlayerButton: some View {
Button {
stopEditing()
newPlayerIsPresented = true
} label: {
Image(systemName: "plus")
}
.accessibility(label: Text("New Player"))
.sheet(isPresented: $newPlayerIsPresented) {
PlayerCreationView()
}
}
private func stopEditing() {
withAnimation {
editMode = .inactive
}
}
}
private struct ToggleOrderingButton: View {
@Binding var ordering: PlayerRequest.Ordering
let willChange: () -> Void
var body: some View {
switch ordering {
case .byName:
Button {
willChange()
ordering = .byScore
} label: {
Label("Name", systemImage: "arrowtriangle.up.fill").labelStyle(.titleAndIcon)
}
case .byScore:
Button {
willChange()
ordering = .byName
} label: {
Label("Score", systemImage: "arrowtriangle.down.fill").labelStyle(.titleAndIcon)
}
}
}
}
struct AppView_Previews: PreviewProvider {
static var previews: some View {
Group {
// Preview the default, empty database
AppView()
// Preview a database of random players
AppView().environment(\.appDatabase, .random())
}
}
}
@@ -0,0 +1,50 @@
import SwiftUI
/// The view that creates a new player.
struct PlayerCreationView: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
@Environment(\.dismiss) private var dismiss
@State private var form = PlayerForm(name: "", score: "")
@State private var errorAlertIsPresented = false
@State private var errorAlertTitle = ""
var body: some View {
NavigationView {
PlayerFormView(form: $form)
.alert(
isPresented: $errorAlertIsPresented,
content: { Alert(title: Text(errorAlertTitle)) })
.navigationBarTitle("New Player")
.navigationBarItems(
leading: Button(role: .cancel) {
dismiss()
} label: {
Text("Cancel")
},
trailing: Button {
Task { await save() }
} label: {
Text("Save")
})
}
}
private func save() async {
do {
var player = Player(id: nil, name: "", score: 0)
form.apply(to: &player)
try await appDatabase.savePlayer(&player)
dismiss()
} catch {
errorAlertTitle = (error as? LocalizedError)?.errorDescription ?? "An error occurred"
errorAlertIsPresented = true
}
}
}
struct PlayerCreationSheet_Previews: PreviewProvider {
static var previews: some View {
PlayerCreationView()
}
}
@@ -0,0 +1,40 @@
import SwiftUI
/// The view that edits an existing player.
struct PlayerEditionView: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
@Environment(\.isPresented) private var isPresented
private let player: Player
@State private var form: PlayerForm
init(player: Player) {
self.player = player
self.form = PlayerForm(player)
}
var body: some View {
PlayerFormView(form: $form)
.onChange(of: isPresented) { isPresented in
// Save when back button is pressed
if !isPresented {
Task {
var savedPlayer = player
form.apply(to: &savedPlayer)
// Ignore error because I don't know how to cancel the
// back button and present the error
try? await appDatabase.savePlayer(&savedPlayer)
}
}
}
}
}
struct PlayerEditionView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
PlayerEditionView(player: Player.makeRandom())
.navigationBarTitle("Player Edition")
}
}
}
@@ -0,0 +1,47 @@
import SwiftUI
/// The Player editing form, embedded in both
/// `PlayerCreationView` and `PlayerEditionView`.
struct PlayerFormView: View {
@Binding var form: PlayerForm
var body: some View {
List {
TextField("Name", text: $form.name)
.accessibility(label: Text("Player Name"))
TextField("Score", text: $form.score).keyboardType(.numberPad)
.accessibility(label: Text("Player Score"))
}
.listStyle(InsetGroupedListStyle())
}
}
struct PlayerForm {
var name: String
var score: String
}
extension PlayerForm {
init(_ player: Player) {
self.name = player.name
self.score = "\(player.score)"
}
func apply(to player: inout Player) {
player.name = name
player.score = Int(score) ?? 0
}
}
struct PlayerFormView_Previews: PreviewProvider {
static var previews: some View {
Group {
PlayerFormView(form: .constant(PlayerForm(
name: "",
score: "")))
PlayerFormView(form: .constant(PlayerForm(
name: Player.randomName(),
score: "\(Player.randomScore())")))
}
}
}
@@ -0,0 +1,59 @@
import SwiftUI
struct PlayerList: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
/// The players in the list
var players: [Player]
var body: some View {
List {
ForEach(players) { player in
NavigationLink(destination: editionView(for: player)) {
PlayerRow(player: player)
// Don't animate player update
.animation(nil, value: player)
}
}
.onDelete { offsets in
let playerIds = offsets.compactMap { players[$0].id }
Task {
try? await appDatabase.deletePlayers(ids: playerIds)
}
}
}
// Animate list updates
.animation(.default, value: players)
.listStyle(.plain)
}
/// The view that edits a player in the list.
private func editionView(for player: Player) -> some View {
PlayerEditionView(player: player).navigationBarTitle(player.name)
}
}
private struct PlayerRow: View {
var player: Player
var body: some View {
HStack {
Text(player.name)
Spacer()
Text("\(player.score) points").foregroundColor(.gray)
}
}
}
struct PlayerList_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
PlayerList(players: [
Player(id: 1, name: "Arthur", score: 100),
Player(id: 2, name: "Barbara", score: 1000),
])
.navigationTitle("Preview")
}
}
}
@@ -0,0 +1,140 @@
import XCTest
import GRDB
@testable import GRDBAsyncDemo
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() async 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 await appDatabase.savePlayer(&player)
// Then the player exists in the database
try XCTAssertTrue(dbQueue.read(player.exists))
}
func test_savePlayer_updates() async throws {
// Given a players database that contains a player
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
var player = try await dbQueue.write { db in
try Player(id: nil, name: "Arthur", score: 100).inserted(db)
}
// When we modify and save the player
player.name = "Barbara"
player.score = 1000
try await appDatabase.savePlayer(&player)
// Then the player has been updated in the database
let fetchedPlayer = try await dbQueue.read { [player] db in
try XCTUnwrap(Player.fetchOne(db, key: player.id))
}
XCTAssertEqual(fetchedPlayer, player)
}
func test_deletePlayers() async throws {
// Given a players database that contains four players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
let playerIds: [Int64] = try await dbQueue.write { db in
_ = try Player(id: nil, name: "Arthur", score: 100).inserted(db)
_ = try Player(id: nil, name: "Barbara", score: 200).inserted(db)
_ = try Player(id: nil, name: "Craig", score: 150).inserted(db)
_ = try Player(id: nil, name: "David", score: 120).inserted(db)
return try Player.selectID().fetchAll(db)
}
// When we delete two players
let deletedId1 = playerIds[0]
let deletedId2 = playerIds[2]
try await appDatabase.deletePlayers(ids: [deletedId1, deletedId2])
// Then the deleted players no longer exist
try await dbQueue.read { db in
try XCTAssertFalse(Player.exists(db, id: deletedId1))
try XCTAssertFalse(Player.exists(db, id: deletedId2))
}
// Then the database still contains two players
try XCTAssertEqual(dbQueue.read(Player.fetchCount), 2)
}
func test_deleteAllPlayers() async throws {
// Given a players database that contains players
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
try await dbQueue.write { db in
_ = try Player(id: nil, name: "Arthur", score: 100).inserted(db)
_ = try Player(id: nil, name: "Barbara", score: 200).inserted(db)
_ = try Player(id: nil, name: "Craig", score: 150).inserted(db)
_ = try Player(id: nil, name: "David", score: 120).inserted(db)
}
// When we delete all players
try await appDatabase.deleteAllPlayers()
// Then the database does not contain any player
try XCTAssertEqual(dbQueue.read(Player.fetchCount), 0)
}
func test_refreshPlayers_populates_an_empty_database() async throws {
// Given an empty players database
let dbQueue = DatabaseQueue()
let appDatabase = try AppDatabase(dbQueue)
// When we refresh players
try await 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])
}
}
@@ -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,43 @@
import XCTest
import GRDB
@testable import GRDBAsyncDemo
class PlayerRequestTests: XCTestCase {
func test_PlayerRequest_byName_fetches_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
_ = 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 fetch players ordered by name
let playerRequest = PlayerRequest(ordering: .byName)
let players = try dbQueue.read(playerRequest.fetchValue)
// Then the players are the two players ordered by name
XCTAssertEqual(players, [player1, player2])
}
func test_PlayerRequest_byScore_fetches_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
_ = 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 fetch players ordered by score
let playerRequest = PlayerRequest(ordering: .byScore)
let players = try dbQueue.read(playerRequest.fetchValue)
// Then the players are the two players ordered by score descending
XCTAssertEqual(players, [player2, player1])
}
}
@@ -0,0 +1,108 @@
import XCTest
import GRDB
@testable import GRDBAsyncDemo
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,81 @@
//
// GRDBAsyncDemoUITests.swift
// GRDBAsyncDemoUITests
//
// Created by Peter Steinberger on 08.04.21.
//
import XCTest
class GRDBAsyncDemoUITests: XCTestCase {
override func setUpWithError() throws {
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
}
override func tearDownWithError() throws {
}
func runApp() -> XCUIApplication {
// UI tests must launch the application that they test.
let app = XCUIApplication()
// We enforce a fresh database to ensure 8 random players.
app.launchArguments = ["-reset", "-fixedTestData"]
app.launch()
return app
}
// This test, introduced in 481f6e93, tests the @Query fix added in
// 68874412. The fix expresses itself when a view defines an @Query
// property that is replaced in the view initializer, as in 481f6e93.
//
// It happens that I did not find that this particular view setup was suited
// for a demo app. The demo has to find a delicate balance, not too trivial,
// but without gratuitous complexity.
//
// I simplified the demo app in a5ffc52d, and we no longer have any view
// that defines an @Query property which is replaced in the view
// initializer. This means that this test no longer checks against
// 68874412 regressions!
//
// Whenever the @Query property wrapper ships with GRDB itself, make sure
// we test for those regressions!
func testInitialSortingIsByScore() throws {
let app = runApp()
let getFirstCell = { () -> XCUIElement in
app.tables.element(boundBy: 0).cells.element(boundBy: 0)
}
// Given default sorting, Henriette must be on top
XCTAssertEqual(getFirstCell().label, "Craig, 8 points")
// Reverse sorting will bring Arthur on top (sort by name)
app.buttons["Score"].tap()
XCTAssertEqual(getFirstCell().label, "Arthur, 5 points")
}
func testListAndAddPlayer() throws {
let app = runApp()
// Ensure we have 8 players visible
XCTAssert(app.tables.cells.count == 8)
// add a player
app.buttons["New Player"].tap()
let playerNameField = app.textFields["Player Name"]
playerNameField.tap()
playerNameField.typeText("Tim Apple")
app.buttons["Save"].tap()
// This is suboptimal, but we need to wait for the animation to finish
// A better way could be to disable animations globally,
// and/or a hook to detect when the async fetch completes.
sleep(2)
XCTAssert(app.tables.cells.count == 9)
}
}
@@ -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,51 @@
Async/Await + 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 an Async/Await + SwiftUI application.** For a demo application that uses UIKit, see [GRDBDemoiOS](../GRDBDemoiOS/README.md), and for Combine + SwiftUI, see [GRDBCombineDemo](../GRDBCombineDemo/README.md).
**Requirements**: iOS 15.0+ / Xcode 13.1+
> :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 an async sequence built from [ValueObservation](../../../README.md#valueobservation).
- 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:**
- [GRDBAsyncDemoApp.swift](GRDBAsyncDemo/GRDBAsyncDemoApp.swift)
`GRDBAsyncDemoApp` feeds the app views with a database, through the SwiftUI environment.
- [AppDatabase.swift](GRDBAsyncDemo/AppDatabase.swift)
`AppDatabase` is the type that grants database access. It uses [DatabaseMigrator](../../Migrations.md) in order to setup the database schema.
- [Persistence.swift](GRDBAsyncDemo/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](GRDBAsyncDemo/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).
- [PlayerRequest.swift](GRDBAsyncDemo/PlayerRequest.swift), [AppView.swift](GRDBAsyncDemo/Views/AppView.swift)
`PlayerRequest` defines the player requests used by the app (sorted by score, or by name).
`PlayerRequest` feeds the `@Query` property wrapper (`@Query`, defined in [GRDBQuery](https://github.com/groue/GRDBQuery), allows SwiftUI views to display up-to-date database content).
`AppView` is the SwiftUI view that uses `@Query` in order to feed its player list.
- [GRDBAsyncDemoTests](GRDBAsyncDemoTests)
- Test the database schema
- Test the `Player` record and its requests
- Test the `PlayerRequest` methods that feed the list of players.
- Test the `AppDatabase` methods that let the app access the database.
Binary file not shown.

After

Width:  |  Height:  |  Size: 799 KiB

@@ -3,28 +3,30 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
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 */; };
56519DC7274FC85600ED16D8 /* GRDBQuery in Frameworks */ = {isa = PBXBuildFile; productRef = 56519DC6274FC85600ED16D8 /* GRDBQuery */; };
5671723A261B23C800423B6F /* PlayerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56717239261B23C800423B6F /* PlayerList.swift */; };
56717252261B334D00423B6F /* PlayerRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56717251261B334D00423B6F /* PlayerRequestTests.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 */; };
567C3E612520B75D0011F6E9 /* PlayerFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E592520B75C0011F6E9 /* PlayerFormView.swift */; };
567C3E622520B75D0011F6E9 /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5A2520B75C0011F6E9 /* AppView.swift */; };
567C3E632520B75D0011F6E9 /* PlayerCreationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567C3E5B2520B75C0011F6E9 /* PlayerCreationView.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 */; };
56B6D1092619EC1B003CC455 /* PlayerRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B6D1082619EC1B003CC455 /* PlayerRequest.swift */; };
56F8A1202735989D0011ACBE /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 56F8A11F2735989D0011ACBE /* GRDB */; };
78E2F9E6261EEC22005D1F7F /* GRDBCombineDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78E2F9E5261EEC22005D1F7F /* GRDBCombineDemoUITests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -35,68 +37,12 @@
remoteGlobalIDString = 567C3E152520B6DE0011F6E9;
remoteInfo = GRDBCombineDemo;
};
567C3E342520B7000011F6E9 /* PBXContainerItemProxy */ = {
78E2F9E8261EEC22005D1F7F /* 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 */;
containerPortal = 567C3E0E2520B6DE0011F6E9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 56E5D7C91B4D3FED00430942;
remoteInfo = GRDBiOS;
remoteGlobalIDString = 567C3E152520B6DE0011F6E9;
remoteInfo = GRDBCombineDemo;
};
/* End PBXContainerItemProxy section */
@@ -107,7 +53,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
567C3E4F2520B70E0011F6E9 /* GRDB.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -119,23 +64,27 @@
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>"; };
56717239261B23C800423B6F /* PlayerList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerList.swift; sourceTree = "<group>"; };
56717251261B334D00423B6F /* PlayerRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRequestTests.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>"; };
567C3E592520B75C0011F6E9 /* PlayerFormView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerFormView.swift; sourceTree = "<group>"; };
567C3E5A2520B75C0011F6E9 /* AppView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
567C3E5B2520B75C0011F6E9 /* PlayerCreationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerCreationView.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>"; };
56B6D1082619EC1B003CC455 /* PlayerRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRequest.swift; sourceTree = "<group>"; };
56F8A11C2735988F0011ACBE /* GRDB.swift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = GRDB.swift; path = ../../..; sourceTree = "<group>"; };
78E2F9E3261EEC22005D1F7F /* GRDBCombineDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCombineDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
78E2F9E5261EEC22005D1F7F /* GRDBCombineDemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRDBCombineDemoUITests.swift; sourceTree = "<group>"; };
78E2F9E7261EEC22005D1F7F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -150,7 +99,15 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
567C3E4E2520B70E0011F6E9 /* GRDB.framework in Frameworks */,
56519DC7274FC85600ED16D8 /* GRDBQuery in Frameworks */,
56F8A1202735989D0011ACBE /* GRDB in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
78E2F9E0261EEC22005D1F7F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -162,6 +119,7 @@
children = (
56026C9C25B8A7D000D1DF3F /* Info.plist */,
56026CAB25B8A7EF00D1DF3F /* AppDatabaseTests.swift */,
56717251261B334D00423B6F /* PlayerRequestTests.swift */,
56026CAA25B8A7EF00D1DF3F /* PlayerTests.swift */,
);
path = GRDBCombineDemoTests;
@@ -177,22 +135,15 @@
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 */,
78E2F9E4261EEC22005D1F7F /* GRDBCombineDemoUITests */,
567C3E172520B6DE0011F6E9 /* Products */,
567C3E4D2520B70E0011F6E9 /* Frameworks */,
56F8A11C2735988F0011ACBE /* GRDB.swift */,
);
sourceTree = "<group>";
};
@@ -201,6 +152,7 @@
children = (
567C3E162520B6DE0011F6E9 /* GRDBCombineDemo.app */,
56026C9825B8A7D000D1DF3F /* GRDBCombineDemoTests.xctest */,
78E2F9E3261EEC22005D1F7F /* GRDBCombineDemoUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -208,14 +160,14 @@
567C3E182520B6DE0011F6E9 /* GRDBCombineDemo */ = {
isa = PBXGroup;
children = (
567C3E222520B6DF0011F6E9 /* Info.plist */,
567C3E652520B7880011F6E9 /* AppDatabase.swift */,
567C3E192520B6DE0011F6E9 /* GRDBCombineDemoApp.swift */,
567C3E542520B75C0011F6E9 /* Persistence.swift */,
567C3E532520B75C0011F6E9 /* Player.swift */,
56B6D1082619EC1B003CC455 /* PlayerRequest.swift */,
567C3E1F2520B6DF0011F6E9 /* Preview Content */,
56185BC125B8047D00B9C30F /* Resources */,
56185BC225B8048B00B9C30F /* Support */,
567C3E552520B75C0011F6E9 /* ViewModels */,
567C3E582520B75C0011F6E9 /* Views */,
);
path = GRDBCombineDemo;
@@ -229,21 +181,6 @@
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 = (
@@ -251,26 +188,27 @@
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 */,
567C3E5A2520B75C0011F6E9 /* AppView.swift */,
567C3E5B2520B75C0011F6E9 /* PlayerCreationView.swift */,
567C3E5C2520B75C0011F6E9 /* PlayerEditionView.swift */,
567C3E592520B75C0011F6E9 /* PlayerFormView.swift */,
56717239261B23C800423B6F /* PlayerList.swift */,
);
path = Views;
sourceTree = "<group>";
};
78E2F9E4261EEC22005D1F7F /* GRDBCombineDemoUITests */ = {
isa = PBXGroup;
children = (
78E2F9E5261EEC22005D1F7F /* GRDBCombineDemoUITests.swift */,
78E2F9E7261EEC22005D1F7F /* Info.plist */,
);
path = GRDBCombineDemoUITests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -304,20 +242,42 @@
buildRules = (
);
dependencies = (
567C3E522520B71C0011F6E9 /* PBXTargetDependency */,
56F8A11E273598960011ACBE /* PBXTargetDependency */,
);
name = GRDBCombineDemo;
packageProductDependencies = (
56F8A11F2735989D0011ACBE /* GRDB */,
56519DC6274FC85600ED16D8 /* GRDBQuery */,
);
productName = GRBCombineDemo;
productReference = 567C3E162520B6DE0011F6E9 /* GRDBCombineDemo.app */;
productType = "com.apple.product-type.application";
};
78E2F9E2261EEC22005D1F7F /* GRDBCombineDemoUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 78E2F9F3261EEC22005D1F7F /* Build configuration list for PBXNativeTarget "GRDBCombineDemoUITests" */;
buildPhases = (
78E2F9DF261EEC22005D1F7F /* Sources */,
78E2F9E0261EEC22005D1F7F /* Frameworks */,
78E2F9E1261EEC22005D1F7F /* Resources */,
);
buildRules = (
);
dependencies = (
78E2F9E9261EEC22005D1F7F /* PBXTargetDependency */,
);
name = GRDBCombineDemoUITests;
productName = GRDBCombineDemoUITests;
productReference = 78E2F9E3261EEC22005D1F7F /* GRDBCombineDemoUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
567C3E0E2520B6DE0011F6E9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1230;
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1200;
TargetAttributes = {
56026C9725B8A7D000D1DF3F = {
@@ -327,10 +287,14 @@
567C3E152520B6DE0011F6E9 = {
CreatedOnToolsVersion = 12.0;
};
78E2F9E2261EEC22005D1F7F = {
CreatedOnToolsVersion = 12.5;
TestTargetID = 567C3E152520B6DE0011F6E9;
};
};
};
buildConfigurationList = 567C3E112520B6DE0011F6E9 /* Build configuration list for PBXProject "GRDBCombineDemo" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
@@ -338,81 +302,20 @@
Base,
);
mainGroup = 567C3E0D2520B6DE0011F6E9;
packageReferences = (
56519DC5274FC85600ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */,
);
productRefGroup = 567C3E172520B6DE0011F6E9 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 567C3E2A2520B7000011F6E9 /* Products */;
ProjectRef = 567C3E292520B7000011F6E9 /* GRDB.xcodeproj */;
},
);
projectRoot = "";
targets = (
567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */,
56026C9725B8A7D000D1DF3F /* GRDBCombineDemoTests */,
78E2F9E2261EEC22005D1F7F /* GRDBCombineDemoUITests */,
);
};
/* 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;
@@ -432,6 +335,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
78E2F9E1261EEC22005D1F7F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -441,6 +351,7 @@
files = (
56026CAC25B8A7EF00D1DF3F /* PlayerTests.swift in Sources */,
56026CAD25B8A7EF00D1DF3F /* AppDatabaseTests.swift in Sources */,
56717252261B334D00423B6F /* PlayerRequestTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -450,14 +361,22 @@
files = (
567C3E5E2520B75C0011F6E9 /* Persistence.swift in Sources */,
567C3E5D2520B75C0011F6E9 /* Player.swift in Sources */,
567C3E612520B75D0011F6E9 /* PlayerForm.swift in Sources */,
567C3E632520B75D0011F6E9 /* PlayerCreationSheet.swift in Sources */,
56B6D1092619EC1B003CC455 /* PlayerRequest.swift in Sources */,
5671723A261B23C800423B6F /* PlayerList.swift in Sources */,
567C3E612520B75D0011F6E9 /* PlayerFormView.swift in Sources */,
567C3E632520B75D0011F6E9 /* PlayerCreationView.swift in Sources */,
567C3E662520B7880011F6E9 /* AppDatabase.swift in Sources */,
567C3E622520B75D0011F6E9 /* PlayerList.swift in Sources */,
567C3E622520B75D0011F6E9 /* AppView.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;
};
78E2F9DF261EEC22005D1F7F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
78E2F9E6261EEC22005D1F7F /* GRDBCombineDemoUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -469,10 +388,14 @@
target = 567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */;
targetProxy = 56026C9D25B8A7D000D1DF3F /* PBXContainerItemProxy */;
};
567C3E522520B71C0011F6E9 /* PBXTargetDependency */ = {
56F8A11E273598960011ACBE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = GRDBiOS;
targetProxy = 567C3E512520B71C0011F6E9 /* PBXContainerItemProxy */;
productRef = 56F8A11D273598960011ACBE /* GRDB */;
};
78E2F9E9261EEC22005D1F7F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 567C3E152520B6DE0011F6E9 /* GRDBCombineDemo */;
targetProxy = 78E2F9E8261EEC22005D1F7F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
@@ -502,7 +425,6 @@
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",
@@ -522,7 +444,6 @@
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",
@@ -587,7 +508,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@@ -642,7 +563,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
@@ -659,10 +580,9 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"GRDBCombineDemo/Preview Content\"";
DEVELOPMENT_TEAM = AMD8W895CT;
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBCombineDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -681,10 +601,9 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"GRDBCombineDemo/Preview Content\"";
DEVELOPMENT_TEAM = AMD8W895CT;
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GRDBCombineDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -696,6 +615,44 @@
};
name = Release;
};
78E2F9EA261EEC22005D1F7F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GRDBCombineDemoUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.groue.GRDBCombineDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = GRDBCombineDemo;
};
name = Debug;
};
78E2F9EB261EEC22005D1F7F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GRDBCombineDemoUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.groue.GRDBCombineDemoUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = GRDBCombineDemo;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -726,7 +683,43 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
78E2F9F3261EEC22005D1F7F /* Build configuration list for PBXNativeTarget "GRDBCombineDemoUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
78E2F9EA261EEC22005D1F7F /* Debug */,
78E2F9EB261EEC22005D1F7F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
56519DC5274FC85600ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/groue/GRDBQuery";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.1.0;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
56519DC6274FC85600ED16D8 /* GRDBQuery */ = {
isa = XCSwiftPackageProductDependency;
package = 56519DC5274FC85600ED16D8 /* XCRemoteSwiftPackageReference "GRDBQuery" */;
productName = GRDBQuery;
};
56F8A11D273598960011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
56F8A11F2735989D0011ACBE /* GRDB */ = {
isa = XCSwiftPackageProductDependency;
productName = GRDB;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 567C3E0E2520B6DE0011F6E9 /* Project object */;
}
@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/groue/Documents/git/groue/GRDB.swift/Documentation/DemoApps/GRBCombineDemo/GRDBCombineDemo.xcodeproj">
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "GRDBQuery",
"repositoryURL": "https://github.com/groue/GRDBQuery",
"state": {
"branch": null,
"revision": "4301166cd2aee9ce37b4057c9a58f5cc3bbeae06",
"version": "0.1.0"
}
}
]
},
"version": 1
}
@@ -38,6 +38,16 @@
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "78E2F9E2261EEC22005D1F7F"
BuildableName = "GRDBCombineDemoUITests.xctest"
BlueprintName = "GRDBCombineDemoUITests"
ReferencedContainer = "container:GRDBCombineDemo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
@@ -1,10 +1,11 @@
import Combine
import Foundation
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
/// <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 {
@@ -17,12 +18,12 @@ struct AppDatabase {
/// 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
/// 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
/// See <https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md>
private var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
@@ -38,9 +39,6 @@ struct AppDatabase {
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
// Sort player names in a localized case insensitive fashion by default
// See https://github.com/groue/GRDB.swift/blob/master/README.md#unicode
.collate(.localizedCaseInsensitiveCompare)
t.column("score", .integer).notNull()
}
}
@@ -57,9 +55,25 @@ struct AppDatabase {
// MARK: - Database Access: Writes
extension AppDatabase {
/// A validation error that prevents some players from being saved into
/// the database.
enum ValidationError: LocalizedError {
case missingName
var errorDescription: String? {
switch self {
case .missingName:
return "Please provide a name"
}
}
}
/// Saves (inserts or updates) a player. When the method returns, the
/// player id is not nil.
/// player is present in the database, and its id is not nil.
func savePlayer(_ player: inout Player) throws {
if player.name.isEmpty {
throw ValidationError.missingName
}
try dbWriter.write { db in
try player.save(db)
}
@@ -68,7 +82,7 @@ extension AppDatabase {
/// Delete the specified players
func deletePlayers(ids: [Int64]) throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db, keys: ids)
_ = try Player.deleteAll(db, ids: ids)
}
}
@@ -82,14 +96,13 @@ extension AppDatabase {
/// 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 {
// Insert new random players
if try Player.all().isEmpty(db) {
// 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)
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
// Delete a random player
@@ -110,37 +123,47 @@ extension AppDatabase {
/// Create random players if the database is empty.
func createRandomPlayersIfEmpty() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
if try Player.all().isEmpty(db) {
try createRandomPlayers(db)
}
}
}
static let uiTestPlayers = [
Player(id: nil, name: "Arthur", score: 5),
Player(id: nil, name: "Barbara", score: 6),
Player(id: nil, name: "Craig", score: 8),
Player(id: nil, name: "David", score: 4),
Player(id: nil, name: "Elena", score: 1),
Player(id: nil, name: "Frederik", score: 2),
Player(id: nil, name: "Gilbert", score: 7),
Player(id: nil, name: "Henriette", score: 3)]
func createPlayersForUITests() throws {
try dbWriter.write { db in
try AppDatabase.uiTestPlayers.forEach { player in
_ = try player.inserted(db) // insert but ignore inserted id
}
}
}
/// Support for `createRandomPlayersIfEmpty()` and `refreshPlayers()`.
private func createRandomPlayers(_ db: Database) throws {
for _ in 0..<8 {
var player = Player.newRandom()
try player.insert(db)
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
}
}
// MARK: - Database Access: Reads
// This demo app does not provide any specific reading method, and instead
// gives an unrestricted read-only access to the rest of the application.
// In your app, you are free to choose another path, and define focused
// reading methods.
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()
/// Provides a read-only access to the database
var databaseReader: DatabaseReader {
dbWriter
}
}
@@ -1,12 +1,40 @@
import GRDBQuery
import SwiftUI
@main
struct GRDBCombineDemoApp: App {
let appDatabase = AppDatabase.shared
var body: some Scene {
WindowGroup {
PlayerList(viewModel: PlayerListViewModel(database: appDatabase))
AppView().environment(\.appDatabase, .shared)
}
}
}
// MARK: - Give SwiftUI access to the database
//
// Define a new environment key that grants access to an AppDatabase.
//
// The technique is documented at
// <https://developer.apple.com/documentation/swiftui/environmentkey>.
private struct AppDatabaseKey: EnvironmentKey {
static var defaultValue: AppDatabase { .empty() }
}
extension EnvironmentValues {
var appDatabase: AppDatabase {
get { self[AppDatabaseKey.self] }
set { self[AppDatabaseKey.self] = newValue }
}
}
// In this demo app, views observe the database with the @Query property
// wrapper, defined in the GRDBQuery package. Its documentation recommends to
// define a dedicated initializer for `appDatabase` access, so we comply:
extension Query where Request.DatabaseContext == AppDatabase {
/// Convenience initializer for requests that feed from `AppDatabase`.
init(_ request: Request) {
self.init(request, in: \.appDatabase)
}
}
@@ -1,3 +1,4 @@
import Foundation
import GRDB
extension AppDatabase {
@@ -6,16 +7,38 @@ extension AppDatabase {
private static func makeShared() -> AppDatabase {
do {
// Pick 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)
// Support for tests: delete the database if requested
if CommandLine.arguments.contains("-reset") {
try? fileManager.removeItem(at: folderURL)
}
// Create the database folder if needed
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 url: URL = try FileManager.default
.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("db.sqlite")
let dbPool = try DatabasePool(path: url.path)
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()
// Prepare the database with test fixtures if requested
if CommandLine.arguments.contains("-fixedTestData") {
try appDatabase.createPlayersForUITests()
} else {
// Otherwise, populate the database if it is empty, for better
// demo purpose.
try appDatabase.createRandomPlayersIfEmpty()
}
return appDatabase
} catch {
@@ -2,7 +2,8 @@ import GRDB
/// The Player struct.
///
/// Identifiable conformance supports SwiftUI list animations.
/// Identifiable conformance supports SwiftUI list animations, and type-safe
/// GRDB primary key methods.
/// Equatable conformance supports tests.
struct Player: Identifiable, Equatable {
/// The player id.
@@ -31,7 +32,7 @@ extension Player {
}
/// Creates a new player with random name and random score
static func newRandom() -> Player {
static func makeRandom() -> Player {
Player(id: nil, name: randomName(), score: randomScore())
}
@@ -50,7 +51,7 @@ extension Player {
/// Make Player a Codable Record.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#records
/// 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 {
@@ -68,28 +69,38 @@ extension Player: Codable, FetchableRecord, MutablePersistableRecord {
/// 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
/// 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
/// A request of players ordered by name.
///
/// For example:
///
/// let players = try dbQueue.read { db in
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByName().fetchAll(db)
/// }
func orderedByName() -> Self {
order(Player.Columns.name)
// 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
/// A request of players ordered by score.
///
/// For example:
///
/// let players = try dbQueue.read { db in
/// 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 {
order(Player.Columns.score.desc, Player.Columns.name)
// 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,55 @@
import Combine
import GRDB
import GRDBQuery
/// A player request can be used with the `@Query` property wrapper in order to
/// feed a view with a list of players.
///
/// For example:
///
/// struct MyView: View {
/// @Query(PlayerRequest(ordering: .byName)) private var players: [Player]
///
/// var body: some View {
/// List(players) { player in ... )
/// }
/// }
struct PlayerRequest: Queryable {
enum Ordering {
case byScore
case byName
}
/// The ordering used by the player request.
var ordering: Ordering
// MARK: - Queryable Implementation
static var defaultValue: [Player] { [] }
func publisher(in appDatabase: AppDatabase) -> AnyPublisher<[Player], Error> {
// Build the publisher from the general-purpose read-only access
// granted by `appDatabase.databaseReader`.
// Some apps will prefer to call a dedicated method of `appDatabase`.
ValueObservation
.tracking(fetchValue(_:))
.publisher(
in: appDatabase.databaseReader,
// The `.immediate` scheduling feeds the view right on
// subscription, and avoids an undesired animation when the
// application starts.
scheduling: .immediate)
.eraseToAnyPublisher()
}
// This method is not required by Queryable, but it makes it easier
// to test PlayerRequest.
func fetchValue(_ db: Database) throws -> [Player] {
switch ordering {
case .byScore:
return try Player.all().orderedByScore().fetchAll(db)
case .byName:
return try Player.all().orderedByName().fetchAll(db)
}
}
}
@@ -1,67 +0,0 @@
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)"
}
}
}
@@ -1,118 +0,0 @@
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,145 @@
import GRDBQuery
import SwiftUI
/// The main application view
struct AppView: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
/// The `players` property is automatically updated when the database changes
@Query(PlayerRequest(ordering: .byScore)) private var players: [Player]
/// We'll need to leave edit mode in several occasions.
@State private var editMode = EditMode.inactive
/// Tracks the presentation of the player creation sheet.
@State private var newPlayerIsPresented = false
// If you want to define the query on initialization, you will prefer:
//
// @Query<PlayerRequest> private var players: [Player]
//
// init(initialOrdering: PlayerRequest.Ordering) {
// _players = Query(PlayerRequest(ordering: initialOrdering))
// }
var body: some View {
NavigationView {
PlayerList(players: players)
.navigationBarTitle(Text("\(players.count) Players"))
.navigationBarItems(
leading: HStack {
EditButton()
newPlayerButton
},
trailing: ToggleOrderingButton(
ordering: $players.ordering,
willChange: {
// onChange(of: $players.wrappedValue.ordering)
// is not able to leave the editing mode during
// the animation of the list content.
// Workaround: stop editing before the ordering
// is changed, and the list content is updated.
stopEditing()
}))
.toolbar { toolbarContent }
.onChange(of: players) { players in
if players.isEmpty {
stopEditing()
}
}
.environment(\.editMode, $editMode)
}
}
private var toolbarContent: some ToolbarContent {
ToolbarItemGroup(placement: .bottomBar) {
Button {
// Don't stopEditing() here because this is
// performed `onChange(of: players)`
try! appDatabase.deleteAllPlayers()
} label: {
Image(systemName: "trash").imageScale(.large)
}
Spacer()
Button {
stopEditing()
try! appDatabase.refreshPlayers()
} label: {
Image(systemName: "arrow.clockwise").imageScale(.large)
}
Spacer()
Button {
stopEditing()
// Perform 50 refreshes in parallel
for _ in 0..<50 {
DispatchQueue.global().async {
try! AppDatabase.shared.refreshPlayers()
}
}
} label: {
Image(systemName: "tornado").imageScale(.large)
}
}
}
/// The button that presents the player creation sheet.
private var newPlayerButton: some View {
Button {
stopEditing()
newPlayerIsPresented = true
} label: {
Image(systemName: "plus")
}
.accessibility(label: Text("New Player"))
.sheet(isPresented: $newPlayerIsPresented) {
PlayerCreationView()
}
}
private func stopEditing() {
withAnimation {
editMode = .inactive
}
}
}
private struct ToggleOrderingButton: View {
@Binding var ordering: PlayerRequest.Ordering
let willChange: () -> Void
var body: some View {
switch ordering {
case .byName:
Button {
willChange()
ordering = .byScore
} label: {
Label("Name", systemImage: "arrowtriangle.up.fill").labelStyle(.titleAndIcon)
}
case .byScore:
Button {
willChange()
ordering = .byName
} label: {
Label("Score", systemImage: "arrowtriangle.down.fill").labelStyle(.titleAndIcon)
}
}
}
}
struct AppView_Previews: PreviewProvider {
static var previews: some View {
Group {
// Preview the default, empty database
AppView()
// Preview a database of random players
AppView().environment(\.appDatabase, .random())
}
}
}
@@ -1,52 +0,0 @@
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,50 @@
import SwiftUI
/// The view that creates a new player.
struct PlayerCreationView: View {
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
@Environment(\.dismiss) private var dismiss
@State private var form = PlayerForm(name: "", score: "")
@State private var errorAlertIsPresented = false
@State private var errorAlertTitle = ""
var body: some View {
NavigationView {
PlayerFormView(form: $form)
.alert(
isPresented: $errorAlertIsPresented,
content: { Alert(title: Text(errorAlertTitle)) })
.navigationBarTitle("New Player")
.navigationBarItems(
leading: Button(role: .cancel) {
dismiss()
} label: {
Text("Cancel")
},
trailing: Button {
save()
} label: {
Text("Save")
})
}
}
private func save() {
do {
var player = Player(id: nil, name: "", score: 0)
form.apply(to: &player)
try appDatabase.savePlayer(&player)
dismiss()
} catch {
errorAlertTitle = (error as? LocalizedError)?.errorDescription ?? "An error occurred"
errorAlertIsPresented = true
}
}
}
struct PlayerCreationSheet_Previews: PreviewProvider {
static var previews: some View {
PlayerCreationView()
}
}
@@ -1,28 +1,37 @@
import SwiftUI
/// The Player edition view, designed to be the destination of
/// a NavigationLink.
/// The view that edits an existing player.
struct PlayerEditionView: View {
/// Manages the player form
let viewModel: PlayerFormViewModel
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
@Environment(\.isPresented) private var isPresented
private let player: Player
@State private var form: PlayerForm
init(player: Player) {
self.player = player
self.form = PlayerForm(player)
}
var body: some View {
PlayerForm(viewModel: viewModel)
.onDisappear(perform: {
// Ignore validation errors
try? self.viewModel.savePlayer()
})
PlayerFormView(form: $form)
.onChange(of: isPresented) { isPresented in
// Save when back button is pressed
if !isPresented {
var savedPlayer = player
form.apply(to: &savedPlayer)
// Ignore error because I don't know how to cancel the
// back button and present the error
try? appDatabase.savePlayer(&savedPlayer)
}
}
}
}
struct PlayerEditionView_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerFormViewModel(
database: .empty(),
player: .newRandom())
return NavigationView {
PlayerEditionView(viewModel: viewModel)
NavigationView {
PlayerEditionView(player: Player.makeRandom())
.navigationBarTitle("Player Edition")
}
}
@@ -1,39 +0,0 @@
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,47 @@
import SwiftUI
/// The Player editing form, embedded in both
/// `PlayerCreationView` and `PlayerEditionView`.
struct PlayerFormView: View {
@Binding var form: PlayerForm
var body: some View {
List {
TextField("Name", text: $form.name)
.accessibility(label: Text("Player Name"))
TextField("Score", text: $form.score).keyboardType(.numberPad)
.accessibility(label: Text("Player Score"))
}
.listStyle(InsetGroupedListStyle())
}
}
struct PlayerForm {
var name: String
var score: String
}
extension PlayerForm {
init(_ player: Player) {
self.name = player.name
self.score = "\(player.score)"
}
func apply(to player: inout Player) {
player.name = name
player.score = Int(score) ?? 0
}
}
struct PlayerFormView_Previews: PreviewProvider {
static var previews: some View {
Group {
PlayerFormView(form: .constant(PlayerForm(
name: "",
score: "")))
PlayerFormView(form: .constant(PlayerForm(
name: Player.randomName(),
score: "\(Player.randomScore())")))
}
}
}
@@ -1,117 +1,38 @@
import SwiftUI
/// The list of players
struct PlayerList: View {
/// Manages the list of players
@ObservedObject var viewModel: PlayerListViewModel
/// Write access to the database
@Environment(\.appDatabase) private var appDatabase
/// Controls the presentation of the player creation sheet.
@State private var newPlayerIsPresented = false
/// The players in the list
var players: [Player]
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)) {
ForEach(players) { player in
NavigationLink(destination: editionView(for: player)) {
PlayerRow(player: player)
.animation(nil)
// Don't animate player update
.animation(nil, value: player)
}
}
.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)
}
})
.onDelete { offsets in
let playerIds = offsets.compactMap { players[$0].id }
try? appDatabase.deletePlayers(ids: playerIds)
}
}
// Animate list updates
.animation(.default, value: players)
.listStyle(.plain)
}
/// 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
})
PlayerEditionView(player: player).navigationBarTitle(player.name)
}
}
struct PlayerRow: View {
private struct PlayerRow: View {
var player: Player
var body: some View {
@@ -123,9 +44,14 @@ struct PlayerRow: View {
}
}
struct PlayerListView_Previews: PreviewProvider {
struct PlayerList_Previews: PreviewProvider {
static var previews: some View {
let viewModel = PlayerListViewModel(database: .random())
return PlayerList(viewModel: viewModel)
NavigationView {
PlayerList(players: [
Player(id: 1, name: "Arthur", score: 100),
Player(id: 2, name: "Barbara", score: 1000),
])
.navigationTitle("Preview")
}
}
}
@@ -143,112 +143,4 @@ class AppDatabaseTests: XCTestCase {
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,43 @@
import XCTest
import GRDB
@testable import GRDBCombineDemo
class PlayerRequestTests: XCTestCase {
func test_PlayerRequest_byName_fetches_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
_ = 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 fetch players ordered by name
let playerRequest = PlayerRequest(ordering: .byName)
let players = try dbQueue.read(playerRequest.fetchValue)
// Then the players are the two players ordered by name
XCTAssertEqual(players, [player1, player2])
}
func test_PlayerRequest_byScore_fetches_well_ordered_players() throws {
// Given a players database that contains two players
let dbQueue = DatabaseQueue()
_ = 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 fetch players ordered by score
let playerRequest = PlayerRequest(ordering: .byScore)
let players = try dbQueue.read(playerRequest.fetchValue)
// Then the players are the two players ordered by score descending
XCTAssertEqual(players, [player2, player1])
}
}
@@ -0,0 +1,81 @@
//
// GRDBCombineDemoUITests.swift
// GRDBCombineDemoUITests
//
// Created by Peter Steinberger on 08.04.21.
//
import XCTest
class GRDBCombineDemoUITests: XCTestCase {
override func setUpWithError() throws {
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
}
override func tearDownWithError() throws {
}
func runApp() -> XCUIApplication {
// UI tests must launch the application that they test.
let app = XCUIApplication()
// We enforce a fresh database to ensure 8 random players.
app.launchArguments = ["-reset", "-fixedTestData"]
app.launch()
return app
}
// This test, introduced in 481f6e93, tests the @Query fix added in
// 68874412. The fix expresses itself when a view defines an @Query
// property that is replaced in the view initializer, as in 481f6e93.
//
// It happens that I did not find that this particular view setup was suited
// for a demo app. The demo has to find a delicate balance, not too trivial,
// but without gratuitous complexity.
//
// I simplified the demo app in a5ffc52d, and we no longer have any view
// that defines an @Query property which is replaced in the view
// initializer. This means that this test no longer checks against
// 68874412 regressions!
//
// Whenever the @Query property wrapper ships with GRDB itself, make sure
// we test for those regressions!
func testInitialSortingIsByScore() throws {
let app = runApp()
let getFirstCell = { () -> XCUIElement in
app.tables.element(boundBy: 0).cells.element(boundBy: 0)
}
// Given default sorting, Henriette must be on top
XCTAssertEqual(getFirstCell().label, "Craig, 8 points")
// Reverse sorting will bring Arthur on top (sort by name)
app.buttons["Score"].tap()
XCTAssertEqual(getFirstCell().label, "Arthur, 5 points")
}
func testListAndAddPlayer() throws {
let app = runApp()
// Ensure we have 8 players visible
XCTAssert(app.tables.cells.count == 8)
// add a player
app.buttons["New Player"].tap()
let playerNameField = app.textFields["Player Name"]
playerNameField.tap()
playerNameField.typeText("Tim Apple")
app.buttons["Save"].tap()
// This is suboptimal, but we need to wait for the animation to finish
// A better way could be to disable animations globally,
// and/or a hook to detect when the async fetch completes.
sleep(2)
XCTAssert(app.tables.cells.count == 9)
}
}
@@ -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>
@@ -3,7 +3,9 @@ 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).
**This demo application is a Combine + SwiftUI application.** For a demo application that uses UIKit, see [GRDBDemoiOS](../GRDBDemoiOS/README.md), and for Async/Await + SwiftUI, see [GRDBAsyncDemo](../GRDBAsyncDemo/README.md).
**Requirements**: iOS 15.0+ / Xcode 12+
> :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.
@@ -19,11 +21,11 @@ The topics covered in this demo are:
- [GRDBCombineDemoApp.swift](GRDBCombineDemo/GRDBCombineDemoApp.swift)
`GRDBCombineDemoApp` feeds the app views with a database.
`GRDBCombineDemoApp` feeds the app views with a database, through the SwiftUI environment.
- [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.
`AppDatabase` is the type that grants database access. It uses [DatabaseMigrator](../../Migrations.md) in order to setup the database schema.
- [Persistence.swift](GRDBCombineDemo/Persistence.swift)
@@ -31,18 +33,19 @@ The topics covered in this demo are:
- [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.
`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).
- [PlayerList.swift](GRDBCombineDemo/Views/PlayerList.swift) and [PlayerListViewModel.swift](GRDBCombineDemo/ViewModels/PlayerListViewModel.swift)
- [PlayerRequest.swift](GRDBCombineDemo/PlayerRequest.swift), [AppView.swift](GRDBCombineDemo/Views/AppView.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).
`PlayerRequest` defines the player requests used by the app (sorted by score, or by name).
`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`.
`PlayerRequest` feeds the `@Query` property wrapper (`@Query`, defined in [GRDBQuery](https://github.com/groue/GRDBQuery), allows SwiftUI views to display up-to-date database content).
`AppView` is the SwiftUI view that uses `@Query` in order to feed its player list.
- [GRDBCombineDemoTests](GRDBCombineDemoTests)
- Test the database schema
- Test the `Player` record and its requests
- Test the `PlayerRequest` methods that feed the list of players.
- Test the `AppDatabase` methods that let the app access the database.
@@ -15,7 +15,6 @@ 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 {
@@ -23,19 +22,25 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
// Be sure to complete the background task once you’re done.
backgroundTask.setTaskCompleted()
backgroundTask.setTaskCompletedWithSnapshot(false)
case let snapshotTask as WKSnapshotRefreshBackgroundTask:
// Snapshot tasks have a unique completion call, make sure to set your expiration date
snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)
case let connectivityTask as WKWatchConnectivityRefreshBackgroundTask:
// Be sure to complete the connectivity task once you’re done.
connectivityTask.setTaskCompleted()
connectivityTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
// Be sure to complete the URL session task once you’re done.
urlSessionTask.setTaskCompleted()
urlSessionTask.setTaskCompletedWithSnapshot(false)
case let relevantShortcutTask as WKRelevantShortcutRefreshBackgroundTask:
// Be sure to complete the relevant-shortcut task once you're done.
relevantShortcutTask.setTaskCompletedWithSnapshot(false)
case let intentDidRunTask as WKIntentDidRunRefreshBackgroundTask:
// Be sure to complete the intent-did-run task once you're done.
intentDidRunTask.setTaskCompletedWithSnapshot(false)
default:
// make sure to complete unhandled task types
task.setTaskCompleted()
task.setTaskCompletedWithSnapshot(false)
}
}
}
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -309,13 +309,13 @@
56B036051E8D9EBE003B6DA4 /* GRDBDemoiOS */ = {
isa = PBXGroup;
children = (
56B036121E8D9EBE003B6DA4 /* Info.plist */,
56B036191E8D9F38003B6DA4 /* AppDatabase.swift */,
56B036061E8D9EBE003B6DA4 /* AppDelegate.swift */,
56185BBE25B8036100B9C30F /* Persistence.swift */,
56B0361A1E8D9F38003B6DA4 /* Player.swift */,
56FE6F2524A90CE400711EDF /* SceneDelegate.swift */,
56FE6F4E24A9112900711EDF /* Resources */,
56FE6F5124A9118000711EDF /* Support */,
56FE6F4F24A9114200711EDF /* ViewControllers */,
);
path = GRDBDemoiOS;
@@ -340,14 +340,6 @@
path = ViewControllers;
sourceTree = "<group>";
};
56FE6F5124A9118000711EDF /* Support */ = {
isa = PBXGroup;
children = (
56B036121E8D9EBE003B6DA4 /* Info.plist */,
);
name = Support;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -462,7 +454,7 @@
};
};
buildConfigurationList = 56B035FE1E8D9EBE003B6DA4 /* Build configuration list for PBXProject "GRDBDemoiOS" */;
compatibilityVersion = "Xcode 3.2";
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
@@ -686,8 +678,11 @@
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";
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;
@@ -709,8 +704,11 @@
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";
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)";
@@ -727,7 +725,11 @@
CLANG_ENABLE_OBJC_WEAK = YES;
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
@@ -743,7 +745,11 @@
CLANG_ENABLE_OBJC_WEAK = YES;
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
@@ -837,14 +843,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
WATCHOS_DEPLOYMENT_TARGET = 8.0;
};
name = Debug;
};
@@ -893,13 +899,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
WATCHOS_DEPLOYMENT_TARGET = 8.0;
};
name = Release;
};
@@ -911,7 +918,10 @@
CLANG_ENABLE_OBJC_WEAK = YES;
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = GRDBDemoiOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -925,7 +935,10 @@
CLANG_ENABLE_OBJC_WEAK = YES;
DEVELOPMENT_TEAM = AMD8W895CT;
INFOPLIST_FILE = GRDBDemoiOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -3,7 +3,7 @@ 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
/// <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 {
@@ -16,12 +16,12 @@ final class AppDatabase {
/// 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
/// 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
/// See <https://github.com/groue/GRDB.swift/blob/master/Documentation/Migrations.md>
private var migrator: DatabaseMigrator {
var migrator = DatabaseMigrator()
@@ -37,9 +37,6 @@ final class AppDatabase {
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
// Sort player names in a localized case insensitive fashion by default
// See https://github.com/groue/GRDB.swift/blob/master/README.md#unicode
.collate(.localizedCaseInsensitiveCompare)
t.column("score", .integer).notNull()
}
}
@@ -57,7 +54,7 @@ final class AppDatabase {
extension AppDatabase {
/// Saves (inserts or updates) a player. When the method returns, the
/// player id is not nil.
/// 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)
@@ -67,7 +64,7 @@ extension AppDatabase {
/// Delete the specified players
func deletePlayers(ids: [Int64]) throws {
try dbWriter.write { db in
_ = try Player.deleteAll(db, keys: ids)
_ = try Player.deleteAll(db, ids: ids)
}
}
@@ -81,14 +78,13 @@ extension AppDatabase {
/// 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 {
// Insert new random players
if try Player.all().isEmpty(db) {
// 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)
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
// Delete a random player
@@ -109,7 +105,7 @@ extension AppDatabase {
/// Create random players if the database is empty.
func createRandomPlayersIfEmpty() throws {
try dbWriter.write { db in
if try Player.fetchCount(db) == 0 {
if try Player.all().isEmpty(db) {
try createRandomPlayers(db)
}
}
@@ -118,54 +114,20 @@ extension AppDatabase {
/// Support for `createRandomPlayersIfEmpty()` and `refreshPlayers()`.
private func createRandomPlayers(_ db: Database) throws {
for _ in 0..<8 {
var player = Player.newRandom()
try player.insert(db)
_ = try Player.makeRandom().inserted(db) // insert but ignore inserted id
}
}
}
// MARK: - Database Access: Reads
// This demo app does not provide any specific reading method, and instead
// gives an unrestricted read-only access to the rest of the application.
// In your app, you are free to choose another path, and define focused
// reading methods.
extension AppDatabase {
/// Tracks changes in the number of players
func observePlayerCount(
onError: @escaping (Error) -> Void,
onChange: @escaping (Int) -> Void)
-> DatabaseCancellable
{
ValueObservation
.tracking(Player.fetchCount)
.start(
in: dbWriter,
onError: onError,
onChange: onChange)
}
/// 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)
/// Provides a read-only access to the database
var databaseReader: DatabaseReader {
dbWriter
}
}
@@ -1,17 +1,27 @@
import Foundation
import GRDB
extension AppDatabase {
/// The shared `PlayerDatabase`
/// 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 url: URL = try FileManager.default
.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("db.sqlite")
let dbPool = try DatabasePool(path: url.path)
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.
@@ -2,8 +2,9 @@ import GRDB
/// The Player struct.
///
/// Identifiable conformance supports type-safe GRDB primary key methods.
/// Hashable conformance supports table view updates
struct Player: Hashable {
struct Player: Identifiable, Hashable {
/// The player id.
///
/// Int64 is the recommended type for auto-incremented database ids.
@@ -30,7 +31,7 @@ extension Player {
}
/// Creates a new player with random name and random score
static func newRandom() -> Player {
static func makeRandom() -> Player {
Player(id: nil, name: randomName(), score: randomScore())
}
@@ -49,7 +50,7 @@ extension Player {
/// Make Player a Codable Record.
///
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#records
/// 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 {
@@ -67,28 +68,38 @@ extension Player: Codable, FetchableRecord, MutablePersistableRecord {
/// 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
/// 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
/// A request of players ordered by name.
///
/// For example:
///
/// let players = try dbQueue.read { db in
/// let players: [Player] = try dbWriter.read { db in
/// try Player.all().orderedByName().fetchAll(db)
/// }
func orderedByName() -> Self {
order(Player.Columns.name)
// 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
/// A request of players ordered by score.
///
/// For example:
///
/// let players = try dbQueue.read { db in
/// 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 {
order(Player.Columns.score.desc, Player.Columns.name)
// 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))
}
}
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -17,14 +18,14 @@
<tableViewSection headerTitle="Name" id="Nzq-eO-jT3">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="2gb-gB-918">
<rect key="frame" x="20" y="55.5" width="374" height="44"/>
<rect key="frame" x="20" y="32" width="374" height="40.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2gb-gB-918" id="iyM-TJ-JB4">
<rect key="frame" x="0.0" y="0.0" width="374" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="374" height="40.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" adjustsFontForContentSizeCategory="YES" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="m5m-Zs-j0z">
<rect key="frame" x="20" y="11" width="334" height="22"/>
<rect key="frame" x="20" y="11" width="334" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
<connections>
@@ -36,7 +37,8 @@
<constraints>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="leading" secondItem="iyM-TJ-JB4" secondAttribute="leadingMargin" id="9cK-nj-70V"/>
<constraint firstAttribute="trailingMargin" secondItem="m5m-Zs-j0z" secondAttribute="trailing" id="JsE-8v-XAS"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="centerY" secondItem="iyM-TJ-JB4" secondAttribute="centerY" id="psG-tW-QrM"/>
<constraint firstAttribute="bottomMargin" secondItem="m5m-Zs-j0z" secondAttribute="bottom" id="KbI-Yl-Las"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="top" secondItem="iyM-TJ-JB4" secondAttribute="topMargin" id="v2S-en-21g"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
@@ -45,14 +47,14 @@
<tableViewSection headerTitle="Score" id="Urb-uF-sj1">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="vp3-Ft-Gth">
<rect key="frame" x="20" y="155" width="374" height="44"/>
<rect key="frame" x="20" y="122" width="374" height="40.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vp3-Ft-Gth" id="ccO-0O-u72">
<rect key="frame" x="0.0" y="0.0" width="374" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="374" height="40.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="0" adjustsFontForContentSizeCategory="YES" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="rZ9-Fa-cyr">
<rect key="frame" x="20" y="11" width="334" height="22"/>
<rect key="frame" x="20" y="11" width="334" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="done"/>
<connections>
@@ -61,9 +63,10 @@
</textField>
</subviews>
<constraints>
<constraint firstAttribute="bottomMargin" secondItem="rZ9-Fa-cyr" secondAttribute="bottom" id="3Ya-Po-TQ3"/>
<constraint firstAttribute="trailingMargin" secondItem="rZ9-Fa-cyr" secondAttribute="trailing" id="Gso-FU-Ct1"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="centerY" secondItem="ccO-0O-u72" secondAttribute="centerY" id="UqA-ea-emb"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="leading" secondItem="ccO-0O-u72" secondAttribute="leadingMargin" id="WrY-St-72v"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="top" secondItem="ccO-0O-u72" secondAttribute="topMargin" id="mmE-f2-e9r"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
@@ -90,10 +93,10 @@
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="cancelBarButtonItem" destination="VIN-Hi-Twt" id="dET-mF-ZXe"/>
<outlet property="commitBarButtonItem" destination="2um-u5-BhV" id="Jym-us-zdP"/>
<outlet property="cancelButtonItem" destination="VIN-Hi-Twt" id="dET-mF-ZXe"/>
<outlet property="nameCell" destination="2gb-gB-918" id="ch2-MB-uRm"/>
<outlet property="nameTextField" destination="m5m-Zs-j0z" id="A6a-pw-q8s"/>
<outlet property="saveButtonItem" destination="2um-u5-BhV" id="Jym-us-zdP"/>
<outlet property="scoreCell" destination="vp3-Ft-Gth" id="b8A-42-8Dw"/>
<outlet property="scoreTextField" destination="rZ9-Fa-cyr" id="4kw-gV-uih"/>
</connections>
@@ -112,7 +115,7 @@
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="iNr-Oe-muq" kind="relationship" relationship="rootViewController" id="e5b-3U-9Vz"/>
<segue destination="iNr-Oe-muq" kind="relationship" relationship="rootViewController" destinationCreationSelector="makePlayerCreationViewController:" id="e5b-3U-9Vz"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="kNr-vk-I5l" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -123,8 +126,8 @@
<scene sceneID="N1X-4j-Re4">
<objects>
<navigationController id="UAh-8N-CM8" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="U7d-1C-GnL">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="U7d-1C-GnL">
<rect key="frame" x="0.0" y="44" width="414" height="96"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
@@ -142,32 +145,32 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="tX0-ON-WSI">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Player" textLabel="G8y-VE-YRu" detailTextLabel="NNc-J4-xiE" style="IBUITableViewCellStyleValue1" id="bFj-Hd-fwd">
<rect key="frame" x="0.0" y="28" width="414" height="43.5"/>
<rect key="frame" x="0.0" y="44.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bFj-Hd-fwd" id="kDf-TZ-xhb">
<rect key="frame" x="0.0" y="0.0" width="383" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="384.5" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="G8y-VE-YRu">
<rect key="frame" x="20" y="12" width="33.5" height="20.5"/>
<rect key="frame" x="20" y="14" width="28.5" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="NNc-J4-xiE">
<rect key="frame" x="331" y="12" width="44" height="20.5"/>
<rect key="frame" x="339" y="14" width="37.5" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="iNr-Oe-muq" kind="show" identifier="Edit" id="Lgu-Yd-HSy"/>
<segue destination="iNr-Oe-muq" kind="show" identifier="" destinationCreationSelector="makePlayerEditionViewController:" id="Lgu-Yd-HSy"/>
</connections>
</tableViewCell>
</prototypes>
@@ -182,7 +185,7 @@
<navigationItem key="navigationItem" title="Hall Of Fame" id="QIv-M6-kT1">
<barButtonItem key="leftBarButtonItem" systemItem="add" id="2bK-Fl-55Q">
<connections>
<segue destination="ein-Sr-i8w" kind="presentation" identifier="New" id="ehP-ZN-Nt4"/>
<segue destination="ein-Sr-i8w" kind="presentation" identifier="" id="ehP-ZN-Nt4"/>
</connections>
</barButtonItem>
</navigationItem>
@@ -199,4 +202,12 @@
<inferredMetricsTieBreakers>
<segue reference="Lgu-Yd-HSy"/>
</inferredMetricsTieBreakers>
<resources>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
@@ -1,39 +1,42 @@
import UIKit
class PlayerEditionViewController: UITableViewController {
enum Presentation {
/// Modal presentation: edition ends with the "Commit" unwind segue.
case modal
enum Mode {
/// Edition ends with the "Commit" unwind segue.
case creation
/// Push presentation: edition ends when user hits the back button.
case push
/// Edition ends when user hits the back button.
case edition
}
/// The edited player
var player: Player! {
didSet {
configureForm()
}
}
private(set) var player: Player
/// The presentation mode
var presentation: Presentation! {
didSet {
configureNavigationItem()
}
}
let mode: Mode
@IBOutlet private weak var cancelBarButtonItem: UIBarButtonItem!
@IBOutlet private weak var commitBarButtonItem: UIBarButtonItem!
@IBOutlet private weak var cancelButtonItem: UIBarButtonItem!
@IBOutlet private weak var saveButtonItem: UIBarButtonItem!
@IBOutlet private weak var nameCell: UITableViewCell!
@IBOutlet private weak var nameTextField: UITextField!
@IBOutlet private weak var scoreCell: UITableViewCell!
@IBOutlet private weak var scoreTextField: UITextField!
init?(_ coder: NSCoder, mode: Mode, player: Player) {
self.mode = mode
self.player = player
super.init(coder: coder)
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
configureForm()
configureNavigationItem()
configureForm()
}
}
@@ -55,24 +58,22 @@ extension PlayerEditionViewController {
override func willMove(toParent parent: UIViewController?) {
super.willMove(toParent: parent)
if case .push = presentation, parent == nil {
if mode == .edition, parent == nil {
// Self is popping from its navigation controller
saveChanges()
}
}
private func configureNavigationItem() {
guard isViewLoaded else { return }
if let presentation = presentation {
switch presentation {
case .modal:
navigationItem.leftBarButtonItem = cancelBarButtonItem
navigationItem.rightBarButtonItem = commitBarButtonItem
case .push:
navigationItem.leftBarButtonItem = nil
navigationItem.rightBarButtonItem = nil
}
switch mode {
case .creation:
navigationItem.title = "New Player"
navigationItem.leftBarButtonItem = cancelButtonItem
navigationItem.rightBarButtonItem = saveButtonItem
case .edition:
navigationItem.title = player.name
navigationItem.leftBarButtonItem = nil
navigationItem.rightBarButtonItem = nil
}
}
}
@@ -104,14 +105,10 @@ extension PlayerEditionViewController: UITextFieldDelegate {
@IBAction func textFieldDidChange(_ textField: UITextField) {
// User has edited the player: prevent interactive dismissal
if case .modal = presentation {
isModalInPresentation = true
}
isModalInPresentation = true
}
private func configureForm() {
guard isViewLoaded else { return }
nameTextField.text = player.name
if player.score == 0 && player.id == nil {
@@ -122,9 +119,7 @@ extension PlayerEditionViewController: UITextFieldDelegate {
}
private func saveChanges() {
guard var player = self.player else {
return
}
var player = self.player
player.name = nameTextField.text ?? ""
player.score = scoreTextField.text.flatMap { Int($0) } ?? 0
try! AppDatabase.shared.savePlayer(&player)
@@ -10,13 +10,11 @@ class PlayerListViewController: UITableViewController {
@IBOutlet private weak var newPlayerButtonItem: UIBarButtonItem!
private var dataSource: PlayerDataSource!
private var animatesPlayersChange = false // Don't animate first update
private var playersCancellable: DatabaseCancellable?
private var playerCountCancellable: DatabaseCancellable?
private var playerOrdering: PlayerOrdering = .byScore {
didSet {
configureOrderingBarButtonItem()
configureDataSourceContent()
observePlayers()
}
}
@@ -25,7 +23,7 @@ class PlayerListViewController: UITableViewController {
configureToolbar()
configureNavigationItem()
configureDataSource()
configureDataSourceContent()
observePlayers()
}
override func viewWillAppear(_ animated: Bool) {
@@ -35,21 +33,31 @@ class PlayerListViewController: UITableViewController {
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(image: UIImage(systemName: "tornado"), style: .plain, target: self, action: #selector(stressTest)),
UIBarButtonItem(systemItem: .trash, primaryAction: UIAction { [unowned self] _ in
setEditing(false, animated: true)
try! AppDatabase.shared.deleteAllPlayers()
}),
UIBarButtonItem(systemItem: .flexibleSpace),
UIBarButtonItem(systemItem: .refresh, primaryAction: UIAction { [unowned self] _ in
setEditing(false, animated: true)
try! AppDatabase.shared.refreshPlayers()
}),
UIBarButtonItem(systemItem: .flexibleSpace),
UIBarButtonItem(image: UIImage(systemName: "tornado"), primaryAction: UIAction { [unowned self] _ in
setEditing(false, animated: true)
for _ in 0..<50 {
DispatchQueue.global().async {
try! AppDatabase.shared.refreshPlayers()
}
}
}),
]
}
private func configureNavigationItem() {
navigationItem.backBarButtonItem = UIBarButtonItem(
title: "Players", style: .plain,
target: nil, action: nil)
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Players")
navigationItem.leftBarButtonItems = [editButtonItem, newPlayerButtonItem]
configureOrderingBarButtonItem()
configureTitle()
}
private func configureOrderingBarButtonItem() {
@@ -57,29 +65,20 @@ class PlayerListViewController: UITableViewController {
case .byScore:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Score ▼",
style: .plain,
target: self, action: #selector(sortByName))
primaryAction: UIAction { [unowned self] _ in
setEditing(false, animated: true)
playerOrdering = .byName
})
case .byName:
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Name ▲",
style: .plain,
target: self, action: #selector(sortByScore))
primaryAction: UIAction { [unowned self] _ in
setEditing(false, animated: true)
playerOrdering = .byScore
})
}
}
private func configureTitle() {
playerCountCancellable = AppDatabase.shared.observePlayerCount(
onError: { error in fatalError("Unexpected error: \(error)") },
onChange: { [weak self] count in
guard let self = self else { return }
switch count {
case 0: self.navigationItem.title = "No Player"
case 1: self.navigationItem.title = "1 Player"
default: self.navigationItem.title = "\(count) Players"
}
})
}
private func configureDataSource() {
dataSource = PlayerDataSource(tableView: tableView) { (tableView, indexPath, player) in
let cell = tableView.dequeueReusableCell(withIdentifier: "Player", for: indexPath)
@@ -95,37 +94,60 @@ class PlayerListViewController: UITableViewController {
tableView.dataSource = dataSource
}
private func configureDataSourceContent() {
switch playerOrdering {
case .byName:
playersCancellable = AppDatabase.shared.observePlayersOrderedByName(
onError: { error in fatalError("Unexpected error: \(error)") },
onChange: { [weak self] players in
guard let self = self else { return }
self.updateDataSourceContent(with: players)
})
case .byScore:
playersCancellable = AppDatabase.shared.observePlayersOrderedByScore(
onError: { error in fatalError("Unexpected error: \(error)") },
onChange: { [weak self] players in
guard let self = self else { return }
self.updateDataSourceContent(with: players)
})
private func configureTitle(from players: [Player]) {
switch players.count {
case 0:
navigationItem.title = "No Player"
case 1:
navigationItem.title = "1 Player"
case let count:
navigationItem.title = "\(count) Players"
}
}
private func updateDataSourceContent(with players: [Player]) {
private func configureDataSource(from players: [Player]) {
var snapshot = NSDiffableDataSourceSnapshot<Int, Player>()
snapshot.appendSections([0])
snapshot.appendItems(players, toSection: 0)
if animatesPlayersChange {
dataSource.apply(snapshot, animatingDifferences: true, completion: nil)
} else {
// Future updates will be animated
animatesPlayersChange = true
dataSource.apply(snapshot, animatingDifferences: false, completion: nil)
// Remember selection
let selectedPlayerId = tableView.indexPathForSelectedRow.flatMap {
dataSource.itemIdentifier(for: $0)?.id
}
// Avoid a UIKit warning; don't animate when popping from edition
let animated = view.window != nil
dataSource.apply(snapshot, animatingDifferences: animated, completion: {
// Restore selection
if let index = players.firstIndex(where: { $0.id == selectedPlayerId }) {
self.tableView.selectRow(at: IndexPath(row: index, section: 0), animated: false, scrollPosition: .none)
}
})
}
private func observePlayers() {
let request: QueryInterfaceRequest<Player>
switch playerOrdering {
case .byName:
request = Player.all().orderedByName()
case .byScore:
request = Player.all().orderedByScore()
}
playersCancellable = ValueObservation
.tracking(request.fetchAll(_:))
.start(
in: AppDatabase.shared.databaseReader,
// Immediate scheduling feeds the data source right on subscription,
// and avoids an undesired animation when the application starts.
scheduling: .immediate,
onError: { error in fatalError("Unexpected error: \(error)") },
onChange: { [weak self] players in
guard let self = self else { return }
self.configureTitle(from: players)
self.configureDataSource(from: players)
})
}
}
@@ -133,26 +155,16 @@ class PlayerListViewController: UITableViewController {
// MARK: - Navigation
extension PlayerListViewController {
@IBSegueAction func makePlayerEditionViewController(_ coder: NSCoder) -> PlayerEditionViewController? {
guard let indexPath = tableView.indexPathForSelectedRow,
let player = dataSource.itemIdentifier(for: indexPath)
else { return nil }
return PlayerEditionViewController(coder, mode: .edition, player: player)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Edit" {
guard let controller = segue.destination as? PlayerEditionViewController,
let indexPath = tableView.indexPathForSelectedRow,
let player = dataSource.itemIdentifier(for: indexPath)
else { return }
controller.title = player.name
controller.player = player
controller.presentation = .push
}
else if segue.identifier == "New" {
guard let navigationController = segue.destination as? UINavigationController,
let controller = navigationController.viewControllers.first as? PlayerEditionViewController
else { return }
setEditing(false, animated: true)
controller.title = "New Player"
controller.player = Player(id: nil, name: "", score: 0)
controller.presentation = .modal
}
@IBSegueAction func makePlayerCreationViewController(_ coder: NSCoder) -> PlayerEditionViewController? {
let player = Player(id: nil, name: "", score: 0)
return PlayerEditionViewController(coder, mode: .creation, player: player)
}
@IBAction func cancelPlayerEdition(_ segue: UIStoryboardSegue) {
@@ -180,37 +192,3 @@ private class PlayerDataSource: UITableViewDiffableDataSource<Int, Player> {
}
}
}
// MARK: - Actions
extension PlayerListViewController {
@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! AppDatabase.shared.deleteAllPlayers()
}
@IBAction func refresh() {
setEditing(false, animated: true)
try! AppDatabase.shared.refreshPlayers()
}
@IBAction func stressTest() {
setEditing(false, animated: true)
for _ in 0..<50 {
DispatchQueue.global().async {
try! AppDatabase.shared.refreshPlayers()
}
}
}
}
@@ -143,92 +143,4 @@ class AppDatabaseTests: XCTestCase {
let players = try dbQueue.read(Player.fetchAll)
XCTAssertEqual(players, [player])
}
func test_observePlayerCount() 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 observe the player count and wait for the first value
let exp = expectation(description: "Player count")
var count: Int?
let cancellable = appDatabase.observePlayerCount(
onError: { error in
XCTFail("Unexpected error \(error)")
},
onChange: {
count = $0
exp.fulfill()
})
withExtendedLifetime(cancellable) {
waitForExpectations(timeout: 1, handler: nil)
}
// Then that first value is one
XCTAssertEqual(count, 1)
}
func test_observePlayersOrderedByName() 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.observePlayersOrderedByName(
onError: { error in
XCTFail("Unexpected error \(error)")
},
onChange: {
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_observePlayersOrderedByScore() 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.observePlayersOrderedByScore(
onError: { error in
XCTFail("Unexpected error \(error)")
},
onChange: {
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])
}
}
+3 -1
View File
@@ -3,7 +3,9 @@ UIKit Demo Application
<img align="right" src="https://github.com/groue/GRDB.swift/raw/master/Documentation/DemoApps/GRDBDemoiOS/Screenshot.png" width="50%">
**This demo application is a storyboard-based UIKit application, based on the MVC design pattern.** For a demo application that uses Combine and SwiftUI, see [GRDBCombineDemo](../GRDBCombineDemo/README.md).
**This demo application is a storyboard-based UIKit application.** For a demo application that uses Combine + SwiftUI, see [GRDBCombineDemo](../GRDBCombineDemo/README.md), and for Async/Await + SwiftUI, see [GRDBAsyncDemo](../GRDBAsyncDemo/README.md).
**Requirements**: iOS 15.0+ / Xcode 12+
> :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.
+9 -2
View File
@@ -1,6 +1,13 @@
Demo Applications
=================
- [UIKit Demo Application](GRDBDemoiOS/README.md): a storyboard-based UIKit application, based on the MVC design pattern.
- [Combine + SwiftUI Demo Application](GRDBCombineDemo/README.md): a Combine + SwiftUI application, based on the MVVM design pattern.
- [GRDBDemoiOS]: a storyboard-based UIKit application.
- [GRDBCombineDemo]: a Combine + SwiftUI application.
- [GRDBAsyncDemo]: a Async/Await + SwiftUI application.
[GRDBCombineDemo] and [GRDBAsyncDemo] use the same `@Query` property wrapper, that lets SwiftUI views automatically update their content when the database changes. It is defined in the [GRDBQuery] package.
[GRDBDemoiOS]: GRDBDemoiOS
[GRDBCombineDemo]: GRDBCombineDemo
[GRDBAsyncDemo]: GRDBAsyncDemo
[GRDBQuery]: https://github.com/groue/GRDBQuery
+70 -8
View File
@@ -31,6 +31,7 @@ let books = try Book.fetchAll(db,
- **[Enabling FTS5 Support](#enabling-fts5-support)**
- **Create Full-Text Virtual Tables**: [FTS3/4](#create-fts3-and-fts4-virtual-tables), [FTS5](#create-fts5-virtual-tables)
- **Choosing a Tokenizer**: [FTS3/4](#fts3-and-fts4-tokenizers), [FTS5](#fts5-tokenizers)
- **Tokenization**: [FTS3/4](#fts3-and-fts4-tokenization), [FTS5](#fts5-tokenization)
- **Search Patterns**: [FTS3/4](#fts3pattern), [FTS5](#fts5pattern)
- **Sorting by Relevance**: [FTS5](#fts5-sorting-by-relevance)
- **External Content Full-Text Tables**: [FTS4/5](#external-content-full-text-tables)
@@ -229,6 +230,21 @@ See below some examples of matches:
See [SQLite tokenizers](https://www.sqlite.org/fts3.html#tokenizer) for more information.
## FTS3 and FTS4 Tokenization
You can tokenize strings when needed:
```swift
// Default tokenization using the `simple` tokenizer:
FTS3.tokenize("SQLite database") // ["sqlite", "database"]
FTS3.tokenize("Gustave Doré") // ["gustave", "doré"])
// Tokenization with an explicit tokenizer:
FTS3.tokenize("SQLite database", withTokenizer: .porter) // ["sqlite", "databas"]
FTS3.tokenize("Gustave Doré", withTokenizer: .unicode61()) // ["gustave", "dore"])
```
## FTS3Pattern
**Full-text search in FTS3 and FTS4 tables is performed with search patterns:**
@@ -248,6 +264,7 @@ struct FTS3Pattern {
init(rawPattern: String) throws
init?(matchingAnyTokenIn string: String)
init?(matchingAllTokensIn string: String)
init?(matchingAllPrefixesIn string: String)
init?(matchingPhrase string: String)
}
```
@@ -257,18 +274,25 @@ The first initializer validates your raw patterns against the query grammar, and
```swift
// OK: FTS3Pattern
let pattern = try FTS3Pattern(rawPattern: "sqlite AND database")
// DatabaseError: malformed MATCH expression: [AND]
let pattern = try FTS3Pattern(rawPattern: "AND")
```
The three other initializers don't throw. They build a valid pattern from any string, **including strings provided by users of your application**. They let you find documents that match all given words, any given word, or a full phrase, depending on the needs of your application:
The other initializers don't throw. They build a valid pattern from any string, **including strings provided by users of your application**. They let you find documents that match any given word, all given words or prefixes, or a full phrase, depending on the needs of your application:
```swift
let query = "SQLite database"
// Matches documents that contain "SQLite" or "database"
let pattern = FTS3Pattern(matchingAnyTokenIn: query)
// Matches documents that contain both "SQLite" and "database"
// Matches documents that contain "SQLite" and "database"
let pattern = FTS3Pattern(matchingAllTokensIn: query)
// Matches documents that contain words that start with "SQLite" and words that start with "database"
let pattern = FTS3Pattern(matchingAllPrefixesIn: query)
// Matches documents that contain "SQLite database"
let pattern = FTS3Pattern(matchingPhrase: query)
```
@@ -280,7 +304,7 @@ let pattern = FTS3Pattern(matchingAnyTokenIn: "") // nil
let pattern = FTS3Pattern(matchingAnyTokenIn: "*") // nil
```
FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.3/Structs/StatementArguments.html):
FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.22/Structs/StatementArguments.html):
```swift
let documents = try Document.fetchAll(db,
@@ -444,7 +468,7 @@ See below some examples of matches:
```swift
try db.create(virtualTable: "book", using: FTS5()) { t in
t.tokenizer = .ascii
t.tokenizer = .ascii()
}
```
@@ -458,8 +482,8 @@ See below some examples of matches:
```swift
try db.create(virtualTable: "book", using: FTS5()) { t in
t.tokenizer = .porter() // porter wrapping unicode61 (the default)
t.tokenizer = .porter(.ascii) // porter wrapping ascii
t.tokenizer = .porter() // porter wrapping unicode61 (the default)
t.tokenizer = .porter(.ascii()) // porter wrapping ascii
t.tokenizer = .porter(.unicode61(diacritics: .keep)) // porter wrapping unicode61 without diacritics stripping
}
```
@@ -471,6 +495,29 @@ See below some examples of matches:
See [SQLite tokenizers](https://www.sqlite.org/fts5.html#tokenizers) for more information, and [custom FTS5 tokenizers](FTS5Tokenizers.md) in order to add your own tokenizers.
## FTS5 Tokenization
You can tokenize strings when needed:
```swift
let ascii = try db.makeTokenizer(.ascii())
// Tokenize an FTS5 query
for (token, flags) in try ascii.tokenize(query: "SQLite database") {
print(token) // Prints "sqlite" then "database"
}
// Tokenize an FTS5 document
for (token, flags) in try ascii.tokenize(document: "SQLite database") {
print(token) // Prints "sqlite" then "database"
}
```
Some tokenizers may produce a different output when you tokenize a query or a document (see `FTS5_TOKENIZE_QUERY` and `FTS5_TOKENIZE_DOCUMENT` in https://www.sqlite.org/fts5.html#custom_tokenizers). You should generally use `tokenize(query:)` when you intend to tokenize a string in order to compose a [raw search pattern](#fts5pattern).
See the `FTS5_TOKEN_*` flags in https://www.sqlite.org/fts5.html#custom_tokenizers for more information about token flags. In particular, tokenizers that support synonyms may output multiple tokens for a single word, along with the `.colocated` flag.
## FTS5Pattern
**Full-text search in FTS5 tables is performed with search patterns:**
@@ -493,7 +540,9 @@ extension Database {
struct FTS5Pattern {
init?(matchingAnyTokenIn string: String)
init?(matchingAllTokensIn string: String)
init?(matchingAllPrefixesIn string: String)
init?(matchingPhrase string: String)
init?(matchingPrefixPhrase string: String)
}
```
@@ -502,8 +551,10 @@ The `Database.makeFTS5Pattern(rawPattern:forTable:)` method validates your raw p
```swift
// OK: FTS5Pattern
try db.makeFTS5Pattern(rawPattern: "sqlite", forTable: "book")
// DatabaseError: syntax error near \"AND\"
try db.makeFTS5Pattern(rawPattern: "AND", forTable: "book")
// DatabaseError: no such column: missing
try db.makeFTS5Pattern(rawPattern: "missing: sqlite", forTable: "book")
```
@@ -512,12 +563,19 @@ The FTS5Pattern initializers don't throw. They build a valid pattern from any st
```swift
let query = "SQLite database"
// Matches documents that contain "SQLite" or "database"
let pattern = FTS5Pattern(matchingAnyTokenIn: query)
// Matches documents that contain both "SQLite" and "database"
// Matches documents that contain "SQLite" and "database"
let pattern = FTS5Pattern(matchingAllTokensIn: query)
// Matches documents that contain words that start with "SQLite" and words that start with "database"
let pattern = FTS5Pattern(matchingAllPrefixesIn: query)
// Matches documents that contain "SQLite database"
let pattern = FTS5Pattern(matchingPhrase: query)
// Matches documents that start with "SQLite database"
let pattern = FTS5Pattern(matchingPrefixPhrase: query)
```
@@ -529,7 +587,7 @@ let pattern = FTS5Pattern(matchingAnyTokenIn: "") // nil
let pattern = FTS5Pattern(matchingAnyTokenIn: "*") // nil
```
FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.3/Structs/StatementArguments.html):
FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.22/Structs/StatementArguments.html):
```swift
let documents = try Document.fetchAll(db,
@@ -540,7 +598,11 @@ let documents = try Document.fetchAll(db,
Use them in the [query interface](../README.md#the-query-interface):
```swift
// Search in all columns
let documents = try Document.matching(pattern).fetchAll(db)
// Search in a specific column:
let documents = try Document.filter(Column("content").match(pattern)).fetchAll(db)
```
+8 -8
View File
@@ -24,9 +24,9 @@ Your attention will be needed, though, in the area of database observation.
GRDB requirements have been bumped:
- **Swift 5.2+** (was Swift 4.2+)
- **Xcode 11.4+** (was Xcode 10.0+)
- **iOS 10.0+** (was iOS 9.0+)
- **Swift 5.3+** (was Swift 4.2+)
- **Xcode 12.0+** (was Xcode 10.0+)
- **iOS 11.0+** (was iOS 9.0+)
- **macOS 10.10+** (was macOS 10.9+)
- tvOS 9.0+ (unchanged)
- watchOS 2.0+ (unchanged)
@@ -387,16 +387,16 @@ let publisher = observation
> :question: This change makes it possible to concatenate subqueries with the UNION operator.
4. In order to extract raw SQL string from an [SQLLiteral], you now need a database connection:
4. In order to extract raw SQL string from an [SQL literal], you now need a database connection:
```swift
let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
// BEFORE: GRDB 4
let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
print(query.sql) // prints "UPDATE player SET name = ? WHERE id = ?"
print(query.arguments) // prints ["O'Brien", 42]
// NEW: GRDB 5
let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
let (sql, arguments) = try dbQueue.read(query.build)
print(sql) // prints "UPDATE player SET name = ? WHERE id = ?"
print(arguments) // prints ["O'Brien", 42]
@@ -422,7 +422,7 @@ let publisher = observation
}
```
6. The `TableRecord.selectionSQL()` method is no longer avaible. When you need to embed the columns selected by a record type in an SQL request, you now have to use [SQL Interpolation]:
6. The `TableRecord.selectionSQL()` method is no longer available. When you need to embed the columns selected by a record type in an SQL request, you now have to use [SQL Interpolation]:
```swift
// BEFORE: GRDB 4
@@ -506,7 +506,7 @@ let publisher = observation
[Custom SQL functions]: ../README.md#custom-sql-functions
[Batch updates]: ../README.md#update-requests
[SQL Interpolation]: SQLInterpolation.md
[SQLLiteral]: SQLInterpolation.md#sqlliteral
[SQL literal]: SQLInterpolation.md#sql-literal
[SQLRequest]: ../README.md#custom-requests
[QueryInterfaceRequest]: ../README.md#requests
[Combine publishers]: Combine.md
@@ -9,6 +9,8 @@ To support this guide, we'll design a simple library application that lets the u
- [Trust SQLite More Than Yourself]
- [Persistable Record Types are Responsible for Their Tables]
- [Record Types Hide Intimate Database Details]
- [Singleton Records]
- [Define Record Requests]
- [Compose Records]
- [How to Design Database Managers]
@@ -96,13 +98,13 @@ Define one record type per database table, and make it adopt a [PersistableRecor
In this sample code, we'll use Codable structs, but there are [other ways](../README.md#examples-of-record-definitions) to define records.
```swift
struct Author: Codable {
struct Author: Codable, Identifiable {
var id: Int64?
var name: String
var country: String?
}
struct Book: Codable {
struct Book: Codable, Identifiable {
var id: Int64?
var authorId: Int64
var title: String
@@ -138,12 +140,108 @@ That's it. The `Author` type can read and write in the `author` database table.
> print(author.id!) // Guaranteed non-nil id
> }
> ```
>
> :bulb: **Tip**: When the database table has a single-column primary key, have your record type adopt the standard [Identifiable] protocol. This allows GRDB to define type-safe id-related methods:
>
> ```swift
> let authorID: Int64 = ...
> let author: Author? = try dbQueue.read { db in
> try Author.fetchOne(db, id: authorID)
> }
> ```
Since `Author` and `Book` can insert, update, and delete rows in the `author` and `book` database tables, they are *responsible for modifying those database tables*.
Now that `Author` and `Book` can read and write in their own database tables, they are responsible for it. Make sure each record type deals with one database table, and only one database table!
Applying the **[Single Responsibility Principle]** has a consequence: don't even try to have an author responsible for its books. Don't add a `books: [Book]` property in Author. Don't let Author write in the `book` table. When a new fellow coworker joins your team and asks you "who is saving books in the database?", you don't want to answer "it depends." You want to confidently answer: "the Book type".
> :bulb: **Tip**: Make sure each record type deals with one database table, and only one database table.
## Record Types Hide Intimate Database Details
The application uses `Book` and `Author` as regular structs, using their properties. Each of those properties matches a column in the database (`Book.title`, `Author.id`), and is defined with a Swift type that is natively supported by SQLite (`String`, `Int`, etc.)
Sometimes, it happens that raw database column names and types are not a very good fit for the application.
Let's look at three examples:
1. Authors write books, and more specifically novels, poems, essays, or theatre plays. Let's add a `kind` column in the database. For easy debugging of the database contents, a book kind is represented as a string ("novel", "essay", etc.):
```swift
try db.create(table: "book") { t in
...
t.column("kind", .text).notNull()
}
```
In Swift, it is not a good practice to use `String` for the type of the `kind` property. We want an enum instead:
```swift
struct Book: Codable {
enum Kind: String, Codable {
case novel, poems, essay, play
}
var id: Int64?
var authorId: Int64
var title: String
var kind: Kind
}
```
In order to make it possible to use `Book.Kind` in book requests (see [Define Record Requests] below), we add this conformance:
```swift
extension Book.Kind: DatabaseValueConvertible { }
```
> :bulb: Records can pick the best suited [Value] type for their column properties (Bool, Int, String, Date, etc.) Thanks to its enum property, the `Book` record prevents unknown book kinds from entering the database.
2. GPS coordinates are usually stored in two distinct `latitude` and `longitude` columns. But the standard way to deal with such coordinate is a single `CLLocationCoordinate2D` struct.
When this happens, keep column properties private, and provide sensible accessors instead:
```swift
struct Place: Codable {
var id: Int64?
var name: String
private var latitude: CLLocationDegrees
private var longitude: CLLocationDegrees
var coordinate: CLLocationCoordinate2D {
get {
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
set {
latitude = newValue.latitude
longitude = newValue.longitude
}
}
}
```
> :bulb: Private properties make it possible to hide raw columns from the rest of the application.
3. The record below exposes a `price: Decimal` property ($12.00), backed by an integer column that stores a quantity of cents (1200). An integer column is preferred because it allows SQLite to compute exact sums of prices.
```swift
struct Product: Codable {
var id: Int64?
var name: String
private var priceCents: Int
var price: Decimal {
get { Decimal(priceCents) / 100 }
set { priceCents = NSDecimalNumber(decimal: newValue * 100).intValue }
}
}
```
> :bulb: Private properties allow records to choose both their best database representation, and at the same time, their best Swift interface.
**Generally speaking**, record types are the dedicated place, in your code, where you can transform raw database values into well-suited types that the rest of the application will enjoy. When needed, you can even [validate values](../README.md#customizing-the-persistence-methods) before they enter the database.
## Singleton Records
**Singleton Records** are records that store configuration values, user preferences, and generally some global application state. They are backed by a database table that contains a single row.
The recommended setup for such records is described in the [Single-Row Tables](SingleRowTables.md) guide. Go check it, and come back when you're done!
## Define Record Requests
@@ -166,7 +264,7 @@ extension Author {
}
```
Otherwise, declare a plain String enum that conforms to the ColumnExpression protocol:
Otherwise, declare a plain `String` enum that conforms to the `ColumnExpression` protocol:
```swift
// For a non-codable record
@@ -178,31 +276,50 @@ extension Author {
}
```
> :bulb: **Tip**: Define commonly used requests in a constrained extension of the `DerivableRequest` protocol.
The `DerivableRequest` protocol generally lets you filter, sort, and join or include associations (we'll talk about associations in the [Compose Records] chapter below).
Here is how you define those requests:
Those columns let you define requests:
```swift
// Some requests of Author --------------------v
try dbQueue.read { db in
// Order authors by name, in a localized case-insensitive fashion
let sortedAuthors: [Author] = try Author.all()
.order(Author.Columns.name.collating(.localizedCaseInsensitiveCompare))
.fetchAll(db)
// French authors
let frenchAuthors: [Author] = try Author.all()
.filter(Author.Columns.country == "France")
.fetchAll(db)
}
```
> :bulb: **Tip**: Define commonly used requests in a constrained extension of the `DerivableRequest` protocol.
When you find yourself build similar requests over and over in your application, you may want to define a reusable and composable request vocabulary. This will avoid repetition in your app, ease refactoring, and enable [testability](DemoApps/GRDBDemoiOS/GRDBDemoiOSTests/PlayerTests.swift).
To do so, extend the `DerivableRequest` protocol. It generally lets you filter, sort, leverage associations (we'll talk about associations in the [Compose Records] chapter below), etc:
```swift
// Author requests ~~~~~~~~~~~~~~~~~~~~~~~~~~
extension DerivableRequest where RowDecoder == Author {
/// Returns a request for all authors ordered by name, in a localized
/// case-insensitive fashion
/// Order authors by name, in a localized case-insensitive fashion
func orderByName() -> Self {
let name = Author.Columns.name
return order(name.collating(.localizedCaseInsensitiveCompare))
}
/// Returns a request for all authors from a country
/// Filters authors from a country
func filter(country: String) -> Self {
filter(Author.Columns.country == country)
}
/// Filters authors with at least one book
func havingBooks() -> Self {
having(Author.books.isEmpty == false)
}
}
```
Those methods defined on the `DerivableRequest` protocol hide intimate database details. They allow you to compose database requests in a fluent style:
Those methods encapsulate intimate database details, and allow you to compose database requests in a fluent and legible style:
```swift
try dbQueue.read { db in
@@ -214,72 +331,55 @@ try dbQueue.read { db in
.filter(country: "France")
.fetchAll(db)
let sortedSpanishAuthors: [Author] = try Author.all()
let sortedSpanishAuthorsHavingBooks: [Author] = try Author.all()
.filter(country: "Spain")
.havingBooks()
.orderByName()
.fetchAll(db)
}
```
Those customized request methods are also available on record associations, because associations conform to the `DerivableRequest` protocol:
Because they are defined in an extension of the `DerivableRequest` protocol, our customized methods can decorate both requests and associations. See how the implementation of `filter(authorCountry:)` for books, below, uses the `filter(country:)` for authors:
```swift
// Some requests of Book
// Book requests ~~~~~~~~~~~~~~~~~~~~~~~~
extension DerivableRequest where RowDecoder == Book {
/// Returns a request for all books from a country
/// Filters books by kind
func filter(kind: Book.Kind) -> Self {
filter(Book.Columns.kind == kind)
}
/// Filters books from a country
func filter(authorCountry: String) -> Self {
// A book is from a country if it can be
// joined with an author from that country:
// ---------------------------v
// Books do not have any country column. But their author has one.
// A book is from a country if it can be joined to an author from this country:
joining(required: Book.author.filter(country: authorCountry))
}
}
try dbQueue.read { db in
let italianBooks = try Book.all()
let italianNovels: [Book] = try Book.all()
.filter(kind: .novel)
.filter(authorCountry: "Italy")
.fetchAll(db)
}
```
Not *every requests* can be expressed on `DerivableRequest`. For example, [Association Aggregates] are out of scope. When this happens, define your requests in a constrained extension to `QueryInterfaceRequest`:
Extensions to the `DerivableRequest` protocol can not change the type of requests. This has to be expressed in an extension to `QueryInterfaceRequest`. For example:
```swift
// More requests of Author -------------------------v
// Author requests ~~~~~~~~~~~~~~~~~~~~~~~~~~
extension QueryInterfaceRequest where RowDecoder == Author {
/// Returns a request for all authors with at least one book
func havingBooks() -> QueryInterfaceRequest<Author> {
having(Author.books.isEmpty == false)
// Selects author ids
func id() -> QueryInterfaceRequest<Int64> {
select(Author.Columns.id)
}
}
// IDs of French authors
let ids: [Int64] = try Author.all().filter(country: "France").id().fetchAll(db)
```
Those requests defined on `QueryInterfaceRequest` still compose fluently:
```swift
try dbQueue.read { db in
let sortedFrenchAuthorsHavingBooks = try Author.all()
.filter(country: "France")
.havingBooks() // <-
.orderByName()
.fetchAll(db)
}
```
Finally, when it happens that a request only makes sense when defined on the Record type itself, just go ahead and define a static method or property of your Record type:
```swift
extension MySingletonRecord {
/// The one any only record stored in the database
static let shared = all().limit(1)
}
let singleton = try dbQueue.read { db
try MySingletonRecord.shared.fetchOne(db)
}
```
## Compose Records
We'd like to navigate from books to authors and vice-versa: we may want to know an author's books, or a book's author.
@@ -358,7 +458,7 @@ Granted with primitive and derived record types, your application will load the
let authorId = 123
let authorInfo: AuthorInfo? = try dbQueue.read { db in
let request = Author
.filter(key: authorId)
.filter(id: authorId)
.including(all: Author.books)
return try AuthorInfo.fetchOne(db, request)
}
@@ -374,7 +474,7 @@ Granted with primitive and derived record types, your application will load the
let bookId = 123
let bookInfo: BookInfo? = try dbQueue.read { db in
let request = Book
.filter(key: bookId)
.filter(id: bookId)
.including(required: Book.author)
return try BookInfo.fetchOne(db, request)
}
@@ -411,7 +511,7 @@ Those properties provide an alternative way to feed our application:
}
let authorId = 123
let authorInfo: AuthorInfo? = try dbQueue.read { db in
guard let author = try Author.fetchOne(db, key: authorId) else {
guard let author = try Author.fetchOne(db, id: authorId) else {
return nil
}
let books = try author.books.fetchAll(db)
@@ -430,7 +530,7 @@ Those properties provide an alternative way to feed our application:
}
let bookId = 123
let bookInfo: BookInfo? = try dbQueue.read { db in
guard let book = try Book.fetchOne(db, key: bookId) else {
guard let book = try Book.fetchOne(db, id: bookId) else {
return nil
}
guard let author = try book.author.fetchOne(db) else {
@@ -443,7 +543,7 @@ Those properties provide an alternative way to feed our application:
## How to Design Database Managers
Many developpers want to hide GRDB database queues and pools inside "database managers":
Many developers want to hide GRDB database queues and pools inside "database managers":
```swift
// LibraryManager grants access to the library database.
@@ -472,7 +572,7 @@ class NaiveLibraryManager {
func author(id: Int64) -> Author? {
do {
return try dbQueue.read { db in
try Author.fetchOne(db, key: id)
try Author.fetchOne(db, id: id)
}
} catch {
return nil
@@ -482,7 +582,7 @@ class NaiveLibraryManager {
func book(id: Int64) -> Book? {
do {
return try dbQueue.read { db in
try Book.fetchOne(db, key: id)
try Book.fetchOne(db, id: id)
}
} catch {
return nil
@@ -531,13 +631,13 @@ class ImprovedLibraryManager {
func author(id: Int64) throws -> Author? {
try dbQueue.read { db in
try Author.fetchOne(db, key: id)
try Author.fetchOne(db, id: id)
}
}
func book(id: Int64) throws -> Book? {
try dbQueue.read { db in
try Book.fetchOne(db, key: id)
try Book.fetchOne(db, id: id)
}
}
@@ -611,7 +711,7 @@ extension LibraryManager {
func bookInfo(bookId: Int64) throws -> BookInfo? {
try dbQueue.read { db in
guard let book = try Book.fetchOne(db, key: bookId) else {
guard let book = try Book.fetchOne(db, id: bookId) else {
return nil
}
guard let author = try book.author.fetchOne(db) else {
@@ -631,7 +731,7 @@ extension LibraryManager {
func authorInfo(authorId: Int64) throws -> AuthorInfo? {
try dbQueue.read { db in
guard let author = try Author.fetchOne(db, key: authorId) else {
guard let author = try Author.fetchOne(db, id: authorId) else {
return nil
}
let books = try author.books.fetchAll(db)
@@ -696,7 +796,6 @@ Instead, have a look at [Database Observation]:
[Django]: https://docs.djangoproject.com/en/2.0/topics/db/
[record protocols]: ../README.md#record-protocols-overview
[Separation of Concerns]: https://en.wikipedia.org/wiki/Separation_of_concerns
[Single Responsibility Principle]: https://en.wikipedia.org/wiki/Single_responsibility_principle
[Single Source of Truth]: https://en.wikipedia.org/wiki/Single_source_of_truth
[Divide and Conquer]: https://en.wikipedia.org/wiki/Divide_and_rule
[Why Adopt GRDB?]: WhyAdoptGRDB.md
@@ -704,8 +803,8 @@ Instead, have a look at [Database Observation]:
[migrations]: Migrations.md
[migration]: Migrations.md
[Foreign Key Actions]: https://sqlite.org/foreignkeys.html#fk_actions
[Concurrency Guide]: ../README.md#concurrency
[GRDB concurrency rules]: ../README.md#concurrency
[Concurrency Guide]: Concurrency.md
[GRDB concurrency rules]: Concurrency.md#concurrency-rules
[PersistableRecord]: ../README.md#persistablerecord-protocol
[Database Observation]: ../README.md#database-changes-observation
[ValueObservation]: ../README.md#valueobservation
@@ -713,6 +812,8 @@ Instead, have a look at [Database Observation]:
[TransactionObserver]: ../README.md#transactionobserver-protocol
[Trust SQLite More Than Yourself]: #trust-sqlite-more-than-yourself
[Persistable Record Types are Responsible for Their Tables]: #persistable-record-types-are-responsible-for-their-tables
[Record Types Hide Intimate Database Details]: #record-types-hide-intimate-database-details
[Singleton Records]: #singleton-records
[Define Record Requests]: #define-record-requests
[Compose Records]: #compose-records
[How to Design Database Managers]: #how-to-design-database-managers
@@ -727,3 +828,5 @@ Instead, have a look at [Database Observation]:
[Codable Record]: ../README.md#codable-records
[CodingKeys]: https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types
[Combine Support]: Combine.md
[Value]: ../README.md#values
[Identifiable]: https://developer.apple.com/documentation/swift/identifiable
@@ -0,0 +1,337 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="496px" height="270px" viewBox="0 0 496 270" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>DatabasePoolConcurrentRead</title>
<defs>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-1">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<linearGradient x1="50%" y1="99.532889%" x2="50%" y2="1.11022302e-14%" id="linearGradient-2">
<stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
<stop stop-color="#FFFFFF" offset="100%"></stop>
</linearGradient>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-3">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-4">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<rect id="path-5" x="0" y="0" width="449" height="40"></rect>
<filter x="-19.5%" y="-17.9%" width="139.1%" height="135.8%" filterUnits="objectBoundingBox" id="filter-7">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<linearGradient x1="50%" y1="99.532889%" x2="50%" y2="1.11022302e-14%" id="linearGradient-8">
<stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
<stop stop-color="#FFFFFF" offset="100%"></stop>
</linearGradient>
</defs>
<g id="DatabasePoolConcurrentRead" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Threads">
<g transform="translate(46.000000, 0.000000)">
<rect id="Rectangle" fill="#FFFFFF" x="0" y="1" width="450" height="269"></rect>
<rect id="Rectangle" fill-opacity="0.02" fill="#000000" x="150" y="1" width="150" height="269"></rect>
<line x1="0.5" y1="0.307517084" x2="0.5" y2="269.692483" id="Line" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="150.5" y1="0.307517084" x2="150.5" y2="269.692483" id="Line-Copy" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="299.5" y1="0.307517084" x2="299.5" y2="269.692483" id="Line-Copy-2" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="449.5" y1="0.307517084" x2="449.5" y2="269.692483" id="Line-Copy-3" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="0.584415584" y1="0.5" x2="449.415584" y2="0.5" id="Line-2" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="0.584415584" y1="269.5" x2="449.415584" y2="269.5" id="Line-3" stroke="#CCCCCC" stroke-linecap="square"></line>
<g id="Thread-1" transform="translate(47.748535, 10.705078)" fill="#000000" fill-rule="nonzero">
<polygon id="T" points="3.17871094 10.2949219 4.40917969 10.2949219 4.40917969 1.53808594 7.58789062 1.53808594 7.58789062 0.430664062 0 0.430664062 0 1.53808594 3.17871094 1.53808594"></polygon>
<path d="M9.25585938,10.2949219 L10.4453125,10.2949219 L10.4453125,5.93359375 C10.4453125,5.50065104 10.5239258,5.12923177 10.6811523,4.81933594 C10.8383789,4.5094401 11.0605469,4.27018229 11.3476562,4.1015625 C11.6347656,3.93294271 11.9742839,3.84863281 12.3662109,3.84863281 C12.9541016,3.84863281 13.3881836,4.00927734 13.668457,4.33056641 C13.9487305,4.65185547 14.0888672,5.14518229 14.0888672,5.81054688 L14.0888672,10.2949219 L15.2783203,10.2949219 L15.2783203,5.5234375 C15.2783203,4.94010417 15.1780599,4.44563802 14.9775391,4.04003906 C14.7770182,3.6344401 14.4853516,3.32568359 14.1025391,3.11376953 C13.7197266,2.90185547 13.2526042,2.79589844 12.7011719,2.79589844 C12.1588542,2.79589844 11.7122396,2.90413411 11.3613281,3.12060547 C11.0104167,3.33707682 10.7415365,3.64127604 10.5546875,4.03320312 L10.4453125,4.03320312 L10.4453125,0 L9.25585938,0 L9.25585938,10.2949219 Z" id="h"></path>
<path d="M17.2744141,10.2949219 L18.4638672,10.2949219 L18.4638672,5.72851562 C18.4638672,5.36848958 18.5470378,5.05403646 18.7133789,4.78515625 C18.8797201,4.51627604 19.108724,4.30664062 19.4003906,4.15625 C19.6920573,4.00585938 20.0270182,3.93066406 20.4052734,3.93066406 C20.5374349,3.93066406 20.6616211,3.93636068 20.777832,3.94775391 C20.894043,3.95914714 21.0136719,3.97623698 21.1367188,3.99902344 L21.1367188,2.84375 C21.077474,2.83463542 20.9920247,2.82438151 20.8803711,2.81298828 C20.7687174,2.80159505 20.6559245,2.79589844 20.5419922,2.79589844 C20.0452474,2.79589844 19.6282552,2.90299479 19.2910156,3.1171875 C18.953776,3.33138021 18.7145182,3.63216146 18.5732422,4.01953125 L18.4638672,4.01953125 L18.4638672,2.92578125 L17.2744141,2.92578125 L17.2744141,10.2949219 Z" id="r"></path>
<path d="M25.2587891,10.4248047 C25.6917318,10.4248047 26.0825195,10.3689779 26.4311523,10.2573242 C26.7797852,10.1456706 27.0817057,9.99527995 27.3369141,9.80615234 C27.5921224,9.61702474 27.8006185,9.40511068 27.9624023,9.17041016 C28.1241862,8.93570964 28.2369792,8.69303385 28.3007812,8.44238281 L28.3144531,8.38769531 L27.125,8.38769531 L27.0976562,8.44921875 C27.0338542,8.59505208 26.9222005,8.73860677 26.7626953,8.87988281 C26.6031901,9.02115885 26.4003906,9.13736979 26.1542969,9.22851562 C25.9082031,9.31966146 25.6188151,9.36523438 25.2861328,9.36523438 C24.8395182,9.36523438 24.4521484,9.26611328 24.1240234,9.06787109 C23.7958984,8.86962891 23.5429688,8.58479818 23.3652344,8.21337891 C23.1875,7.84195964 23.0986328,7.39420573 23.0986328,6.87011719 L23.0986328,6.3984375 C23.0986328,5.84700521 23.1897786,5.38216146 23.3720703,5.00390625 C23.554362,4.62565104 23.8015951,4.33968099 24.1137695,4.14599609 C24.425944,3.9523112 24.7802734,3.85546875 25.1767578,3.85546875 C25.5732422,3.85546875 25.9241536,3.94775391 26.2294922,4.13232422 C26.5348307,4.31689453 26.7740885,4.59602865 26.9472656,4.96972656 C27.1204427,5.34342448 27.2070312,5.81966146 27.2070312,6.3984375 L27.2070312,6.87011719 L27.7949219,6.00195312 L22.4970703,6.00195312 L22.4970703,6.95214844 L28.4033203,6.95214844 L28.4033203,6.48730469 C28.4033203,5.75358073 28.2745768,5.10986328 28.0170898,4.55615234 C27.7596029,4.00244141 27.3904622,3.57063802 26.909668,3.26074219 C26.4288737,2.95084635 25.8535156,2.79589844 25.1835938,2.79589844 C24.5182292,2.79589844 23.9371745,2.95768229 23.4404297,3.28125 C22.9436849,3.60481771 22.5597331,4.05371094 22.2885742,4.62792969 C22.0174154,5.20214844 21.8818359,5.86979167 21.8818359,6.63085938 L21.8818359,6.63769531 C21.8818359,7.4078776 22.0174154,8.07666016 22.2885742,8.64404297 C22.5597331,9.21142578 22.9471029,9.6500651 23.4506836,9.95996094 C23.9542643,10.2698568 24.5569661,10.4248047 25.2587891,10.4248047 Z" id="e"></path>
<path d="M32.1220703,10.4248047 C32.4547526,10.4248047 32.7600911,10.3780924 33.0380859,10.284668 C33.3160807,10.1912435 33.5655924,10.0533854 33.7866211,9.87109375 C34.0076497,9.68880208 34.195638,9.46777344 34.3505859,9.20800781 L34.4599609,9.20800781 L34.4599609,10.2949219 L35.6494141,10.2949219 L35.6494141,5.25 C35.6494141,4.73958333 35.5411784,4.30094401 35.324707,3.93408203 C35.1082357,3.56722005 34.7915039,3.28580729 34.3745117,3.08984375 C33.9575195,2.89388021 33.4482422,2.79589844 32.8466797,2.79589844 C32.3225911,2.79589844 31.8554688,2.87679036 31.4453125,3.03857422 C31.0351562,3.20035807 30.7013346,3.42594401 30.4438477,3.71533203 C30.1863607,4.00472005 30.0257161,4.34309896 29.9619141,4.73046875 L29.9550781,4.77148438 L31.1445312,4.77148438 L31.1513672,4.75097656 C31.2470703,4.46386719 31.4361979,4.24169922 31.71875,4.08447266 C32.0013021,3.92724609 32.3636068,3.84863281 32.8056641,3.84863281 C33.3570964,3.84863281 33.7706706,3.96826172 34.0463867,4.20751953 C34.3221029,4.44677734 34.4599609,4.79427083 34.4599609,5.25 L34.4599609,7.546875 C34.4599609,7.89778646 34.3699544,8.21223958 34.1899414,8.49023438 C34.0099284,8.76822917 33.7626953,8.98811849 33.4482422,9.14990234 C33.1337891,9.3116862 32.773763,9.39257812 32.3681641,9.39257812 C31.9397786,9.39257812 31.5843099,9.28889974 31.3017578,9.08154297 C31.0192057,8.8741862 30.8779297,8.58365885 30.8779297,8.20996094 L30.8779297,8.19628906 C30.8779297,7.83170573 31.0066732,7.54915365 31.2641602,7.34863281 C31.5216471,7.14811198 31.9306641,7.03190104 32.4912109,7 L35.0546875,6.8359375 L35.0546875,5.88574219 L32.3476562,6.04980469 C31.4908854,6.0999349 30.8289388,6.31070964 30.3618164,6.68212891 C29.894694,7.05354818 29.6611328,7.56738281 29.6611328,8.22363281 L29.6611328,8.23730469 C29.6611328,8.68391927 29.7693685,9.07128906 29.9858398,9.39941406 C30.2023112,9.72753906 30.4962565,9.98046875 30.8676758,10.1582031 C31.2390951,10.3359375 31.6572266,10.4248047 32.1220703,10.4248047 Z" id="a"></path>
<path d="M40.3935547,10.4248047 C40.9085286,10.4248047 41.3642578,10.3097331 41.7607422,10.0795898 C42.1572266,9.84944661 42.4671224,9.52929688 42.6904297,9.11914062 L42.7998047,9.11914062 L42.7998047,10.2949219 L43.9892578,10.2949219 L43.9892578,0 L42.7998047,0 L42.7998047,4.08789062 L42.6904297,4.08789062 C42.4899089,3.69596354 42.183431,3.38264974 41.7709961,3.14794922 C41.3585612,2.9132487 40.8994141,2.79589844 40.3935547,2.79589844 C39.7692057,2.79589844 39.2257487,2.953125 38.7631836,3.26757812 C38.3006185,3.58203125 37.9417318,4.02408854 37.6865234,4.59375 C37.4313151,5.16341146 37.3037109,5.83333333 37.3037109,6.60351562 L37.3037109,6.6171875 C37.3037109,7.3828125 37.4313151,8.05159505 37.6865234,8.62353516 C37.9417318,9.19547526 38.3017578,9.63867188 38.7666016,9.953125 C39.2314453,10.2675781 39.773763,10.4248047 40.3935547,10.4248047 Z M40.6669922,9.37207031 C40.2203776,9.37207031 39.8364258,9.26155599 39.5151367,9.04052734 C39.1938477,8.8194987 38.9477539,8.50276693 38.7768555,8.09033203 C38.605957,7.67789714 38.5205078,7.18684896 38.5205078,6.6171875 L38.5205078,6.60351562 C38.5205078,6.02929688 38.605957,5.53710938 38.7768555,5.12695312 C38.9477539,4.71679688 39.1938477,4.40120443 39.5151367,4.18017578 C39.8364258,3.95914714 40.2203776,3.84863281 40.6669922,3.84863281 C41.1136068,3.84863281 41.4986979,3.96028646 41.8222656,4.18359375 C42.1458333,4.40690104 42.3942057,4.72363281 42.5673828,5.13378906 C42.7405599,5.54394531 42.8271484,6.03385417 42.8271484,6.60351562 L42.8271484,6.6171875 C42.8271484,7.18229167 42.7405599,7.6710612 42.5673828,8.08349609 C42.3942057,8.49593099 42.1458333,8.81380208 41.8222656,9.03710938 C41.4986979,9.26041667 41.1136068,9.37207031 40.6669922,9.37207031 Z" id="d"></path>
<polygon id="1" points="52.3154297 10.2949219 53.5458984 10.2949219 53.5458984 0.430664062 52.3222656 0.430664062 49.6972656 2.31738281 49.6972656 3.61621094 52.2060547 1.79785156 52.3154297 1.79785156"></polygon>
</g>
<g id="Thread-2" transform="translate(196.770996, 10.705078)" fill="#000000" fill-rule="nonzero">
<polygon id="T" points="3.17871094 10.2949219 4.40917969 10.2949219 4.40917969 1.53808594 7.58789062 1.53808594 7.58789062 0.430664062 0 0.430664062 0 1.53808594 3.17871094 1.53808594"></polygon>
<path d="M9.25585938,10.2949219 L10.4453125,10.2949219 L10.4453125,5.93359375 C10.4453125,5.50065104 10.5239258,5.12923177 10.6811523,4.81933594 C10.8383789,4.5094401 11.0605469,4.27018229 11.3476562,4.1015625 C11.6347656,3.93294271 11.9742839,3.84863281 12.3662109,3.84863281 C12.9541016,3.84863281 13.3881836,4.00927734 13.668457,4.33056641 C13.9487305,4.65185547 14.0888672,5.14518229 14.0888672,5.81054688 L14.0888672,10.2949219 L15.2783203,10.2949219 L15.2783203,5.5234375 C15.2783203,4.94010417 15.1780599,4.44563802 14.9775391,4.04003906 C14.7770182,3.6344401 14.4853516,3.32568359 14.1025391,3.11376953 C13.7197266,2.90185547 13.2526042,2.79589844 12.7011719,2.79589844 C12.1588542,2.79589844 11.7122396,2.90413411 11.3613281,3.12060547 C11.0104167,3.33707682 10.7415365,3.64127604 10.5546875,4.03320312 L10.4453125,4.03320312 L10.4453125,0 L9.25585938,0 L9.25585938,10.2949219 Z" id="h"></path>
<path d="M17.2744141,10.2949219 L18.4638672,10.2949219 L18.4638672,5.72851562 C18.4638672,5.36848958 18.5470378,5.05403646 18.7133789,4.78515625 C18.8797201,4.51627604 19.108724,4.30664062 19.4003906,4.15625 C19.6920573,4.00585938 20.0270182,3.93066406 20.4052734,3.93066406 C20.5374349,3.93066406 20.6616211,3.93636068 20.777832,3.94775391 C20.894043,3.95914714 21.0136719,3.97623698 21.1367188,3.99902344 L21.1367188,2.84375 C21.077474,2.83463542 20.9920247,2.82438151 20.8803711,2.81298828 C20.7687174,2.80159505 20.6559245,2.79589844 20.5419922,2.79589844 C20.0452474,2.79589844 19.6282552,2.90299479 19.2910156,3.1171875 C18.953776,3.33138021 18.7145182,3.63216146 18.5732422,4.01953125 L18.4638672,4.01953125 L18.4638672,2.92578125 L17.2744141,2.92578125 L17.2744141,10.2949219 Z" id="r"></path>
<path d="M25.2587891,10.4248047 C25.6917318,10.4248047 26.0825195,10.3689779 26.4311523,10.2573242 C26.7797852,10.1456706 27.0817057,9.99527995 27.3369141,9.80615234 C27.5921224,9.61702474 27.8006185,9.40511068 27.9624023,9.17041016 C28.1241862,8.93570964 28.2369792,8.69303385 28.3007812,8.44238281 L28.3144531,8.38769531 L27.125,8.38769531 L27.0976562,8.44921875 C27.0338542,8.59505208 26.9222005,8.73860677 26.7626953,8.87988281 C26.6031901,9.02115885 26.4003906,9.13736979 26.1542969,9.22851562 C25.9082031,9.31966146 25.6188151,9.36523438 25.2861328,9.36523438 C24.8395182,9.36523438 24.4521484,9.26611328 24.1240234,9.06787109 C23.7958984,8.86962891 23.5429688,8.58479818 23.3652344,8.21337891 C23.1875,7.84195964 23.0986328,7.39420573 23.0986328,6.87011719 L23.0986328,6.3984375 C23.0986328,5.84700521 23.1897786,5.38216146 23.3720703,5.00390625 C23.554362,4.62565104 23.8015951,4.33968099 24.1137695,4.14599609 C24.425944,3.9523112 24.7802734,3.85546875 25.1767578,3.85546875 C25.5732422,3.85546875 25.9241536,3.94775391 26.2294922,4.13232422 C26.5348307,4.31689453 26.7740885,4.59602865 26.9472656,4.96972656 C27.1204427,5.34342448 27.2070312,5.81966146 27.2070312,6.3984375 L27.2070312,6.87011719 L27.7949219,6.00195312 L22.4970703,6.00195312 L22.4970703,6.95214844 L28.4033203,6.95214844 L28.4033203,6.48730469 C28.4033203,5.75358073 28.2745768,5.10986328 28.0170898,4.55615234 C27.7596029,4.00244141 27.3904622,3.57063802 26.909668,3.26074219 C26.4288737,2.95084635 25.8535156,2.79589844 25.1835938,2.79589844 C24.5182292,2.79589844 23.9371745,2.95768229 23.4404297,3.28125 C22.9436849,3.60481771 22.5597331,4.05371094 22.2885742,4.62792969 C22.0174154,5.20214844 21.8818359,5.86979167 21.8818359,6.63085938 L21.8818359,6.63769531 C21.8818359,7.4078776 22.0174154,8.07666016 22.2885742,8.64404297 C22.5597331,9.21142578 22.9471029,9.6500651 23.4506836,9.95996094 C23.9542643,10.2698568 24.5569661,10.4248047 25.2587891,10.4248047 Z" id="e"></path>
<path d="M32.1220703,10.4248047 C32.4547526,10.4248047 32.7600911,10.3780924 33.0380859,10.284668 C33.3160807,10.1912435 33.5655924,10.0533854 33.7866211,9.87109375 C34.0076497,9.68880208 34.195638,9.46777344 34.3505859,9.20800781 L34.4599609,9.20800781 L34.4599609,10.2949219 L35.6494141,10.2949219 L35.6494141,5.25 C35.6494141,4.73958333 35.5411784,4.30094401 35.324707,3.93408203 C35.1082357,3.56722005 34.7915039,3.28580729 34.3745117,3.08984375 C33.9575195,2.89388021 33.4482422,2.79589844 32.8466797,2.79589844 C32.3225911,2.79589844 31.8554688,2.87679036 31.4453125,3.03857422 C31.0351562,3.20035807 30.7013346,3.42594401 30.4438477,3.71533203 C30.1863607,4.00472005 30.0257161,4.34309896 29.9619141,4.73046875 L29.9550781,4.77148438 L31.1445312,4.77148438 L31.1513672,4.75097656 C31.2470703,4.46386719 31.4361979,4.24169922 31.71875,4.08447266 C32.0013021,3.92724609 32.3636068,3.84863281 32.8056641,3.84863281 C33.3570964,3.84863281 33.7706706,3.96826172 34.0463867,4.20751953 C34.3221029,4.44677734 34.4599609,4.79427083 34.4599609,5.25 L34.4599609,7.546875 C34.4599609,7.89778646 34.3699544,8.21223958 34.1899414,8.49023438 C34.0099284,8.76822917 33.7626953,8.98811849 33.4482422,9.14990234 C33.1337891,9.3116862 32.773763,9.39257812 32.3681641,9.39257812 C31.9397786,9.39257812 31.5843099,9.28889974 31.3017578,9.08154297 C31.0192057,8.8741862 30.8779297,8.58365885 30.8779297,8.20996094 L30.8779297,8.19628906 C30.8779297,7.83170573 31.0066732,7.54915365 31.2641602,7.34863281 C31.5216471,7.14811198 31.9306641,7.03190104 32.4912109,7 L35.0546875,6.8359375 L35.0546875,5.88574219 L32.3476562,6.04980469 C31.4908854,6.0999349 30.8289388,6.31070964 30.3618164,6.68212891 C29.894694,7.05354818 29.6611328,7.56738281 29.6611328,8.22363281 L29.6611328,8.23730469 C29.6611328,8.68391927 29.7693685,9.07128906 29.9858398,9.39941406 C30.2023112,9.72753906 30.4962565,9.98046875 30.8676758,10.1582031 C31.2390951,10.3359375 31.6572266,10.4248047 32.1220703,10.4248047 Z" id="a"></path>
<path d="M40.3935547,10.4248047 C40.9085286,10.4248047 41.3642578,10.3097331 41.7607422,10.0795898 C42.1572266,9.84944661 42.4671224,9.52929688 42.6904297,9.11914062 L42.7998047,9.11914062 L42.7998047,10.2949219 L43.9892578,10.2949219 L43.9892578,0 L42.7998047,0 L42.7998047,4.08789062 L42.6904297,4.08789062 C42.4899089,3.69596354 42.183431,3.38264974 41.7709961,3.14794922 C41.3585612,2.9132487 40.8994141,2.79589844 40.3935547,2.79589844 C39.7692057,2.79589844 39.2257487,2.953125 38.7631836,3.26757812 C38.3006185,3.58203125 37.9417318,4.02408854 37.6865234,4.59375 C37.4313151,5.16341146 37.3037109,5.83333333 37.3037109,6.60351562 L37.3037109,6.6171875 C37.3037109,7.3828125 37.4313151,8.05159505 37.6865234,8.62353516 C37.9417318,9.19547526 38.3017578,9.63867188 38.7666016,9.953125 C39.2314453,10.2675781 39.773763,10.4248047 40.3935547,10.4248047 Z M40.6669922,9.37207031 C40.2203776,9.37207031 39.8364258,9.26155599 39.5151367,9.04052734 C39.1938477,8.8194987 38.9477539,8.50276693 38.7768555,8.09033203 C38.605957,7.67789714 38.5205078,7.18684896 38.5205078,6.6171875 L38.5205078,6.60351562 C38.5205078,6.02929688 38.605957,5.53710938 38.7768555,5.12695312 C38.9477539,4.71679688 39.1938477,4.40120443 39.5151367,4.18017578 C39.8364258,3.95914714 40.2203776,3.84863281 40.6669922,3.84863281 C41.1136068,3.84863281 41.4986979,3.96028646 41.8222656,4.18359375 C42.1458333,4.40690104 42.3942057,4.72363281 42.5673828,5.13378906 C42.7405599,5.54394531 42.8271484,6.03385417 42.8271484,6.60351562 L42.8271484,6.6171875 C42.8271484,7.18229167 42.7405599,7.6710612 42.5673828,8.08349609 C42.3942057,8.49593099 42.1458333,8.81380208 41.8222656,9.03710938 C41.4986979,9.26041667 41.1136068,9.37207031 40.6669922,9.37207031 Z" id="d"></path>
<path d="M49.9023438,10.2949219 L56.2871094,10.2949219 L56.2871094,9.1875 L51.3105469,9.1875 L51.6113281,9.39257812 L51.6113281,8.82519531 L51.3037109,9.39257812 L53.8535156,6.76074219 C54.4505208,6.14550781 54.9130859,5.62711589 55.2412109,5.20556641 C55.5693359,4.78401693 55.7983398,4.4000651 55.9282227,4.05371094 C56.0581055,3.70735677 56.1230469,3.34733073 56.1230469,2.97363281 L56.1230469,2.95996094 C56.1230469,2.42675781 55.9897461,1.95279948 55.7231445,1.53808594 C55.456543,1.1233724 55.093099,0.796386719 54.6328125,0.557128906 C54.172526,0.317871094 53.6552734,0.198242188 53.0810547,0.198242188 C52.4521484,0.198242188 51.8938802,0.326985677 51.40625,0.584472656 C50.9186198,0.841959635 50.5358073,1.19742839 50.2578125,1.65087891 C49.9798177,2.10432943 49.8385417,2.62272135 49.8339844,3.20605469 L49.8476562,3.21289062 L51.0234375,3.21972656 L51.0302734,3.20605469 C51.0302734,2.8186849 51.1123047,2.48030599 51.2763672,2.19091797 C51.4404297,1.90152995 51.6705729,1.67594401 51.9667969,1.51416016 C52.2630208,1.3523763 52.6070964,1.27148438 52.9990234,1.27148438 C53.3863932,1.27148438 53.7190755,1.35123698 53.9970703,1.51074219 C54.2750651,1.6702474 54.4892578,1.88671875 54.6396484,2.16015625 C54.7900391,2.43359375 54.8652344,2.74348958 54.8652344,3.08984375 L54.8652344,3.10351562 C54.8652344,3.390625 54.8173828,3.65494792 54.7216797,3.89648438 C54.6259766,4.13802083 54.4596354,4.40804036 54.2226562,4.70654297 C53.9856771,5.00504557 53.6575521,5.38216146 53.2382812,5.83789062 L49.9023438,9.44726562 L49.9023438,10.2949219 Z" id="2"></path>
</g>
<g id="Thread-3" transform="translate(346.606934, 10.705078)" fill="#000000" fill-rule="nonzero">
<polygon id="T" points="3.17871094 10.2949219 4.40917969 10.2949219 4.40917969 1.53808594 7.58789062 1.53808594 7.58789062 0.430664062 0 0.430664062 0 1.53808594 3.17871094 1.53808594"></polygon>
<path d="M9.25585938,10.2949219 L10.4453125,10.2949219 L10.4453125,5.93359375 C10.4453125,5.50065104 10.5239258,5.12923177 10.6811523,4.81933594 C10.8383789,4.5094401 11.0605469,4.27018229 11.3476562,4.1015625 C11.6347656,3.93294271 11.9742839,3.84863281 12.3662109,3.84863281 C12.9541016,3.84863281 13.3881836,4.00927734 13.668457,4.33056641 C13.9487305,4.65185547 14.0888672,5.14518229 14.0888672,5.81054688 L14.0888672,10.2949219 L15.2783203,10.2949219 L15.2783203,5.5234375 C15.2783203,4.94010417 15.1780599,4.44563802 14.9775391,4.04003906 C14.7770182,3.6344401 14.4853516,3.32568359 14.1025391,3.11376953 C13.7197266,2.90185547 13.2526042,2.79589844 12.7011719,2.79589844 C12.1588542,2.79589844 11.7122396,2.90413411 11.3613281,3.12060547 C11.0104167,3.33707682 10.7415365,3.64127604 10.5546875,4.03320312 L10.4453125,4.03320312 L10.4453125,0 L9.25585938,0 L9.25585938,10.2949219 Z" id="h"></path>
<path d="M17.2744141,10.2949219 L18.4638672,10.2949219 L18.4638672,5.72851562 C18.4638672,5.36848958 18.5470378,5.05403646 18.7133789,4.78515625 C18.8797201,4.51627604 19.108724,4.30664062 19.4003906,4.15625 C19.6920573,4.00585938 20.0270182,3.93066406 20.4052734,3.93066406 C20.5374349,3.93066406 20.6616211,3.93636068 20.777832,3.94775391 C20.894043,3.95914714 21.0136719,3.97623698 21.1367188,3.99902344 L21.1367188,2.84375 C21.077474,2.83463542 20.9920247,2.82438151 20.8803711,2.81298828 C20.7687174,2.80159505 20.6559245,2.79589844 20.5419922,2.79589844 C20.0452474,2.79589844 19.6282552,2.90299479 19.2910156,3.1171875 C18.953776,3.33138021 18.7145182,3.63216146 18.5732422,4.01953125 L18.4638672,4.01953125 L18.4638672,2.92578125 L17.2744141,2.92578125 L17.2744141,10.2949219 Z" id="r"></path>
<path d="M25.2587891,10.4248047 C25.6917318,10.4248047 26.0825195,10.3689779 26.4311523,10.2573242 C26.7797852,10.1456706 27.0817057,9.99527995 27.3369141,9.80615234 C27.5921224,9.61702474 27.8006185,9.40511068 27.9624023,9.17041016 C28.1241862,8.93570964 28.2369792,8.69303385 28.3007812,8.44238281 L28.3144531,8.38769531 L27.125,8.38769531 L27.0976562,8.44921875 C27.0338542,8.59505208 26.9222005,8.73860677 26.7626953,8.87988281 C26.6031901,9.02115885 26.4003906,9.13736979 26.1542969,9.22851562 C25.9082031,9.31966146 25.6188151,9.36523438 25.2861328,9.36523438 C24.8395182,9.36523438 24.4521484,9.26611328 24.1240234,9.06787109 C23.7958984,8.86962891 23.5429688,8.58479818 23.3652344,8.21337891 C23.1875,7.84195964 23.0986328,7.39420573 23.0986328,6.87011719 L23.0986328,6.3984375 C23.0986328,5.84700521 23.1897786,5.38216146 23.3720703,5.00390625 C23.554362,4.62565104 23.8015951,4.33968099 24.1137695,4.14599609 C24.425944,3.9523112 24.7802734,3.85546875 25.1767578,3.85546875 C25.5732422,3.85546875 25.9241536,3.94775391 26.2294922,4.13232422 C26.5348307,4.31689453 26.7740885,4.59602865 26.9472656,4.96972656 C27.1204427,5.34342448 27.2070312,5.81966146 27.2070312,6.3984375 L27.2070312,6.87011719 L27.7949219,6.00195312 L22.4970703,6.00195312 L22.4970703,6.95214844 L28.4033203,6.95214844 L28.4033203,6.48730469 C28.4033203,5.75358073 28.2745768,5.10986328 28.0170898,4.55615234 C27.7596029,4.00244141 27.3904622,3.57063802 26.909668,3.26074219 C26.4288737,2.95084635 25.8535156,2.79589844 25.1835938,2.79589844 C24.5182292,2.79589844 23.9371745,2.95768229 23.4404297,3.28125 C22.9436849,3.60481771 22.5597331,4.05371094 22.2885742,4.62792969 C22.0174154,5.20214844 21.8818359,5.86979167 21.8818359,6.63085938 L21.8818359,6.63769531 C21.8818359,7.4078776 22.0174154,8.07666016 22.2885742,8.64404297 C22.5597331,9.21142578 22.9471029,9.6500651 23.4506836,9.95996094 C23.9542643,10.2698568 24.5569661,10.4248047 25.2587891,10.4248047 Z" id="e"></path>
<path d="M32.1220703,10.4248047 C32.4547526,10.4248047 32.7600911,10.3780924 33.0380859,10.284668 C33.3160807,10.1912435 33.5655924,10.0533854 33.7866211,9.87109375 C34.0076497,9.68880208 34.195638,9.46777344 34.3505859,9.20800781 L34.4599609,9.20800781 L34.4599609,10.2949219 L35.6494141,10.2949219 L35.6494141,5.25 C35.6494141,4.73958333 35.5411784,4.30094401 35.324707,3.93408203 C35.1082357,3.56722005 34.7915039,3.28580729 34.3745117,3.08984375 C33.9575195,2.89388021 33.4482422,2.79589844 32.8466797,2.79589844 C32.3225911,2.79589844 31.8554688,2.87679036 31.4453125,3.03857422 C31.0351562,3.20035807 30.7013346,3.42594401 30.4438477,3.71533203 C30.1863607,4.00472005 30.0257161,4.34309896 29.9619141,4.73046875 L29.9550781,4.77148438 L31.1445312,4.77148438 L31.1513672,4.75097656 C31.2470703,4.46386719 31.4361979,4.24169922 31.71875,4.08447266 C32.0013021,3.92724609 32.3636068,3.84863281 32.8056641,3.84863281 C33.3570964,3.84863281 33.7706706,3.96826172 34.0463867,4.20751953 C34.3221029,4.44677734 34.4599609,4.79427083 34.4599609,5.25 L34.4599609,7.546875 C34.4599609,7.89778646 34.3699544,8.21223958 34.1899414,8.49023438 C34.0099284,8.76822917 33.7626953,8.98811849 33.4482422,9.14990234 C33.1337891,9.3116862 32.773763,9.39257812 32.3681641,9.39257812 C31.9397786,9.39257812 31.5843099,9.28889974 31.3017578,9.08154297 C31.0192057,8.8741862 30.8779297,8.58365885 30.8779297,8.20996094 L30.8779297,8.19628906 C30.8779297,7.83170573 31.0066732,7.54915365 31.2641602,7.34863281 C31.5216471,7.14811198 31.9306641,7.03190104 32.4912109,7 L35.0546875,6.8359375 L35.0546875,5.88574219 L32.3476562,6.04980469 C31.4908854,6.0999349 30.8289388,6.31070964 30.3618164,6.68212891 C29.894694,7.05354818 29.6611328,7.56738281 29.6611328,8.22363281 L29.6611328,8.23730469 C29.6611328,8.68391927 29.7693685,9.07128906 29.9858398,9.39941406 C30.2023112,9.72753906 30.4962565,9.98046875 30.8676758,10.1582031 C31.2390951,10.3359375 31.6572266,10.4248047 32.1220703,10.4248047 Z" id="a"></path>
<path d="M40.3935547,10.4248047 C40.9085286,10.4248047 41.3642578,10.3097331 41.7607422,10.0795898 C42.1572266,9.84944661 42.4671224,9.52929688 42.6904297,9.11914062 L42.7998047,9.11914062 L42.7998047,10.2949219 L43.9892578,10.2949219 L43.9892578,0 L42.7998047,0 L42.7998047,4.08789062 L42.6904297,4.08789062 C42.4899089,3.69596354 42.183431,3.38264974 41.7709961,3.14794922 C41.3585612,2.9132487 40.8994141,2.79589844 40.3935547,2.79589844 C39.7692057,2.79589844 39.2257487,2.953125 38.7631836,3.26757812 C38.3006185,3.58203125 37.9417318,4.02408854 37.6865234,4.59375 C37.4313151,5.16341146 37.3037109,5.83333333 37.3037109,6.60351562 L37.3037109,6.6171875 C37.3037109,7.3828125 37.4313151,8.05159505 37.6865234,8.62353516 C37.9417318,9.19547526 38.3017578,9.63867188 38.7666016,9.953125 C39.2314453,10.2675781 39.773763,10.4248047 40.3935547,10.4248047 Z M40.6669922,9.37207031 C40.2203776,9.37207031 39.8364258,9.26155599 39.5151367,9.04052734 C39.1938477,8.8194987 38.9477539,8.50276693 38.7768555,8.09033203 C38.605957,7.67789714 38.5205078,7.18684896 38.5205078,6.6171875 L38.5205078,6.60351562 C38.5205078,6.02929688 38.605957,5.53710938 38.7768555,5.12695312 C38.9477539,4.71679688 39.1938477,4.40120443 39.5151367,4.18017578 C39.8364258,3.95914714 40.2203776,3.84863281 40.6669922,3.84863281 C41.1136068,3.84863281 41.4986979,3.96028646 41.8222656,4.18359375 C42.1458333,4.40690104 42.3942057,4.72363281 42.5673828,5.13378906 C42.7405599,5.54394531 42.8271484,6.03385417 42.8271484,6.60351562 L42.8271484,6.6171875 C42.8271484,7.18229167 42.7405599,7.6710612 42.5673828,8.08349609 C42.3942057,8.49593099 42.1458333,8.81380208 41.8222656,9.03710938 C41.4986979,9.26041667 41.1136068,9.37207031 40.6669922,9.37207031 Z" id="d"></path>
<path d="M53.2587891,10.4589844 C53.9195964,10.4589844 54.507487,10.3347982 55.0224609,10.0864258 C55.5374349,9.83805339 55.9430339,9.49739583 56.2392578,9.06445312 C56.5354818,8.63151042 56.6835938,8.14160156 56.6835938,7.59472656 L56.6835938,7.58105469 C56.6835938,6.87923177 56.4614258,6.31526693 56.0170898,5.88916016 C55.5727539,5.46305339 54.9905599,5.2203776 54.2705078,5.16113281 L54.2705078,5.13378906 C54.6806641,5.04720052 55.0429688,4.89908854 55.3574219,4.68945312 C55.671875,4.47981771 55.9179688,4.21777344 56.0957031,3.90332031 C56.2734375,3.58886719 56.3623047,3.22884115 56.3623047,2.82324219 L56.3623047,2.80957031 C56.3623047,2.30826823 56.2335612,1.86735026 55.9760742,1.48681641 C55.7185872,1.10628255 55.3562826,0.807779948 54.8891602,0.591308594 C54.4220378,0.37483724 53.8740234,0.266601562 53.2451172,0.266601562 C52.6298828,0.266601562 52.0864258,0.378255208 51.6147461,0.6015625 C51.1430664,0.824869792 50.7648112,1.13704427 50.4799805,1.53808594 C50.1951497,1.9391276 50.0253906,2.40852865 49.9707031,2.94628906 L49.9638672,3.01464844 L51.1464844,3.01464844 L51.1533203,2.94628906 C51.1897786,2.61360677 51.2991536,2.3264974 51.4814453,2.08496094 C51.663737,1.84342448 51.9064128,1.65771484 52.2094727,1.52783203 C52.5125326,1.39794922 52.8577474,1.33300781 53.2451172,1.33300781 C53.6461589,1.33300781 53.9868164,1.3968099 54.2670898,1.52441406 C54.5473633,1.65201823 54.7604167,1.83658854 54.90625,2.078125 C55.0520833,2.31966146 55.125,2.61360677 55.125,2.95996094 L55.125,2.97363281 C55.125,3.30175781 55.0406901,3.5945638 54.8720703,3.85205078 C54.7034505,4.10953776 54.46875,4.31233724 54.1679688,4.46044922 C53.8671875,4.6085612 53.5208333,4.68261719 53.1289062,4.68261719 L51.9462891,4.68261719 L51.9462891,5.72167969 L53.1835938,5.72167969 C53.8763021,5.72167969 54.4243164,5.88460286 54.8276367,6.21044922 C55.230957,6.53629557 55.4326172,7.00227865 55.4326172,7.60839844 L55.4326172,7.62207031 C55.4326172,7.96842448 55.3414714,8.27490234 55.1591797,8.54150391 C54.976888,8.80810547 54.722819,9.01660156 54.3969727,9.16699219 C54.0711263,9.31738281 53.6917318,9.39257812 53.2587891,9.39257812 C52.6025391,9.39257812 52.0670573,9.23990885 51.6523438,8.93457031 C51.2376302,8.62923177 51.0052083,8.23502604 50.9550781,7.75195312 L50.9482422,7.68359375 L49.765625,7.68359375 L49.7724609,7.765625 C49.8180339,8.28515625 49.987793,8.74772135 50.2817383,9.15332031 C50.5756836,9.55891927 50.9755859,9.87792969 51.4814453,10.1103516 C51.9873047,10.3427734 52.5797526,10.4589844 53.2587891,10.4589844 Z" id="3"></path>
</g>
</g>
<g id="Time" fill="#000000" fill-rule="nonzero">
<g transform="translate(7.755859, 10.568359)">
<polygon id="T" points="3.17871094 10.4316406 4.40917969 10.4316406 4.40917969 1.67480469 7.58789062 1.67480469 7.58789062 0.567382812 0 0.567382812 0 1.67480469 3.17871094 1.67480469"></polygon>
<path d="M9.078125,10.4316406 L10.2675781,10.4316406 L10.2675781,3.0625 L9.078125,3.0625 L9.078125,10.4316406 Z M9.6796875,1.640625 C9.90755208,1.640625 10.101237,1.55973307 10.2607422,1.39794922 C10.4202474,1.23616536 10.5,1.04361979 10.5,0.8203125 C10.5,0.592447917 10.4202474,0.398763021 10.2607422,0.239257813 C10.101237,0.0797526042 9.90755208,0 9.6796875,0 C9.45638021,0 9.26383464,0.0797526042 9.10205078,0.239257813 C8.94026693,0.398763021 8.859375,0.592447917 8.859375,0.8203125 C8.859375,1.04361979 8.94026693,1.23616536 9.10205078,1.39794922 C9.26383464,1.55973307 9.45638021,1.640625 9.6796875,1.640625 Z" id="i"></path>
<path d="M12.359375,10.4316406 L13.5488281,10.4316406 L13.5488281,5.86523438 C13.5488281,5.51888021 13.6228841,5.20328776 13.7709961,4.91845703 C13.9191081,4.6336263 14.1219076,4.40690104 14.3793945,4.23828125 C14.6368815,4.06966146 14.9251302,3.98535156 15.2441406,3.98535156 C15.7089844,3.98535156 16.0804036,4.1163737 16.3583984,4.37841797 C16.6363932,4.64046224 16.7753906,4.99023438 16.7753906,5.42773438 L16.7753906,10.4316406 L17.9648438,10.4316406 L17.9648438,5.69433594 C17.9648438,5.37988281 18.0354818,5.09391276 18.1767578,4.83642578 C18.3180339,4.5789388 18.516276,4.37272135 18.7714844,4.21777344 C19.0266927,4.06282552 19.3251953,3.98535156 19.6669922,3.98535156 C20.1865234,3.98535156 20.5727539,4.12093099 20.8256836,4.39208984 C21.0786133,4.6632487 21.2050781,5.06998698 21.2050781,5.61230469 L21.2050781,10.4316406 L22.3945312,10.4316406 L22.3945312,5.33886719 C22.3945312,4.82389323 22.3033854,4.38753255 22.1210938,4.02978516 C21.9388021,3.67203776 21.6733398,3.39973958 21.324707,3.21289062 C20.9760742,3.02604167 20.5511068,2.93261719 20.0498047,2.93261719 C19.7125651,2.93261719 19.3969727,2.98616536 19.1030273,3.09326172 C18.809082,3.20035807 18.5504557,3.3507487 18.3271484,3.54443359 C18.1038411,3.73811849 17.9261068,3.96484375 17.7939453,4.22460938 L17.6845703,4.22460938 C17.570638,3.96940104 17.4179688,3.74495443 17.2265625,3.55126953 C17.0351562,3.35758464 16.8072917,3.20605469 16.5429688,3.09667969 C16.2786458,2.98730469 15.9801432,2.93261719 15.6474609,2.93261719 C15.164388,2.93261719 14.7530924,3.04199219 14.4135742,3.26074219 C14.074056,3.47949219 13.8222656,3.78710938 13.6582031,4.18359375 L13.5488281,4.18359375 L13.5488281,3.0625 L12.359375,3.0625 L12.359375,10.4316406 Z" id="m"></path>
<path d="M27.3984375,10.5615234 C27.8313802,10.5615234 28.222168,10.5056966 28.5708008,10.394043 C28.9194336,10.2823893 29.2213542,10.1319987 29.4765625,9.94287109 C29.7317708,9.75374349 29.9402669,9.54182943 30.1020508,9.30712891 C30.2638346,9.07242839 30.3766276,8.8297526 30.4404297,8.57910156 L30.4541016,8.52441406 L29.2646484,8.52441406 L29.2373047,8.5859375 C29.1735026,8.73177083 29.061849,8.87532552 28.9023438,9.01660156 C28.7428385,9.1578776 28.5400391,9.27408854 28.2939453,9.36523438 C28.0478516,9.45638021 27.7584635,9.50195312 27.4257812,9.50195312 C26.9791667,9.50195312 26.5917969,9.40283203 26.2636719,9.20458984 C25.9355469,9.00634766 25.6826172,8.72151693 25.5048828,8.35009766 C25.3271484,7.97867839 25.2382812,7.53092448 25.2382812,7.00683594 L25.2382812,6.53515625 C25.2382812,5.98372396 25.3294271,5.51888021 25.5117188,5.140625 C25.6940104,4.76236979 25.9412435,4.47639974 26.253418,4.28271484 C26.5655924,4.08902995 26.9199219,3.9921875 27.3164062,3.9921875 C27.7128906,3.9921875 28.0638021,4.08447266 28.3691406,4.26904297 C28.6744792,4.45361328 28.913737,4.7327474 29.0869141,5.10644531 C29.2600911,5.48014323 29.3466797,5.95638021 29.3466797,6.53515625 L29.3466797,7.00683594 L29.9345703,6.13867188 L24.6367188,6.13867188 L24.6367188,7.08886719 L30.5429688,7.08886719 L30.5429688,6.62402344 C30.5429688,5.89029948 30.4142253,5.24658203 30.1567383,4.69287109 C29.8992513,4.13916016 29.5301107,3.70735677 29.0493164,3.39746094 C28.5685221,3.0875651 27.9931641,2.93261719 27.3232422,2.93261719 C26.6578776,2.93261719 26.0768229,3.09440104 25.5800781,3.41796875 C25.0833333,3.74153646 24.6993815,4.19042969 24.4282227,4.76464844 C24.1570638,5.33886719 24.0214844,6.00651042 24.0214844,6.76757812 L24.0214844,6.77441406 C24.0214844,7.54459635 24.1570638,8.21337891 24.4282227,8.78076172 C24.6993815,9.34814453 25.0867513,9.78678385 25.590332,10.0966797 C26.0939128,10.4065755 26.6966146,10.5615234 27.3984375,10.5615234 Z" id="e"></path>
</g>
<path id="Line-4" d="M22.9978866,32.8564159 L22.9999956,33.3564115 L23.964,261.941 L27.9641081,261.924237 L23.5021089,270.943138 L18.9641882,261.962198 L22.964,261.945 L22.0000044,33.3606294 L21.9978955,32.8606338 L22.9978866,32.8564159 Z"></path>
</g>
</g>
<g id="Write-A" transform="translate(66.000000, 50.000000)">
<g id="Background" filter="url(#filter-1)" fill="#D7E6F7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-2)" x="-0.5" y="-0.5" width="111" height="41" rx="10"></rect>
<g id="Text" transform="translate(13.843073, 14.396606)" fill="#000000" fill-rule="nonzero">
<polygon id="W" points="2.6602478 10.6033936 4.11064148 10.6033936 6.22476196 3.2358551 6.3168335 3.2358551 8.43714905 10.6033936 9.88380432 10.6033936 12.5440521 0.739135742 10.9479675 0.739135742 9.14648438 8.40296936 9.05451965 8.40296936 6.98429871 0.739135742 5.55718994 0.739135742 3.49957275 8.40296936 3.40750122 8.40296936 1.60099792 0.739135742 0 0.739135742"></polygon>
<path d="M13.6347213,10.6033936 L15.1199355,10.6033936 L15.1199355,6.16729736 C15.1199355,5.80898031 15.2001866,5.49789174 15.3606887,5.23403168 C15.5211908,4.97017161 15.7445515,4.76534271 16.0307708,4.61954498 C16.3169901,4.47374725 16.6492273,4.40084839 17.0274825,4.40084839 C17.1688298,4.40084839 17.3043024,4.40800476 17.4339004,4.4223175 C17.5634983,4.43663025 17.6944137,4.45767212 17.8266463,4.48544312 L17.8266463,3.11590576 C17.75316,3.09924316 17.6570474,3.08416494 17.5383086,3.07067108 C17.4195698,3.05717723 17.299033,3.0504303 17.1766982,3.0504303 C16.6833002,3.0504303 16.2696548,3.15962728 15.9357619,3.37802124 C15.6018691,3.5964152 15.3680587,3.90346273 15.2343307,4.29916382 L15.1199355,4.29916382 L15.1199355,3.17657471 L13.6347213,3.17657471 L13.6347213,10.6033936 Z" id="r"></path>
<path d="M19.1169329,10.6033936 L20.6021471,10.6033936 L20.6021471,3.17657471 L19.1169329,3.17657471 L19.1169329,10.6033936 Z M19.8650408,1.85243225 C20.1230262,1.85243225 20.3428443,1.76151784 20.5244951,1.57968903 C20.7061459,1.39786021 20.7969713,1.18026733 20.7969713,0.9269104 C20.7969713,0.668924967 20.7061459,0.449943542 20.5244951,0.269966125 C20.3428443,0.0899887085 20.1230262,0 19.8650408,0 C19.6116838,0 19.3930407,0.0899887085 19.2091112,0.269966125 C19.0251818,0.449943542 18.933217,0.668924967 18.933217,0.9269104 C18.933217,1.18026733 19.0251818,1.39786021 19.2091112,1.57968903 C19.3930407,1.76151784 19.6116838,1.85243225 19.8650408,1.85243225 Z" id="i"></path>
<path d="M25.412344,10.6480408 C25.5583909,10.6480408 25.6994534,10.6405818 25.8355312,10.6256638 C25.9716091,10.6107457 26.0982876,10.5933177 26.2155666,10.5733795 L26.2155666,9.38873291 C26.1112474,9.39784749 26.0198167,9.40489705 25.9412746,9.40988159 C25.8627326,9.41486613 25.7668514,9.4173584 25.6536312,9.4173584 C25.2875525,9.4173584 25.0243689,9.32863363 24.8640804,9.15118408 C24.7037919,8.97373454 24.6236477,8.68609111 24.6236477,8.28825378 L24.6236477,4.35150146 L26.2155666,4.35150146 L26.2155666,3.17657471 L24.6236477,3.17657471 L24.6236477,1.30950928 L23.1048946,1.30950928 L23.1048946,3.17657471 L21.944067,3.17657471 L21.944067,4.35150146 L23.1048946,4.35150146 L23.1048946,8.647995 C23.1048946,9.35985819 23.2859402,9.87116496 23.6480312,10.1819153 C24.0101223,10.4926656 24.5982265,10.6480408 25.412344,10.6480408 Z" id="t"></path>
<path d="M30.8317854,10.7445984 C31.3073816,10.7445984 31.7295185,10.6835378 32.0981963,10.5614166 C32.466874,10.4392955 32.7817366,10.2774048 33.042784,10.0757446 C33.3038313,9.87408447 33.5141966,9.65173848 33.6738799,9.40870667 C33.8335631,9.16567485 33.9440596,8.92175293 34.0053694,8.67694092 L34.020323,8.61595154 L32.5852034,8.61723328 L32.5604231,8.6711731 C32.5032434,8.79778035 32.4011672,8.92734273 32.2541945,9.05986023 C32.1072218,9.19237773 31.9182189,9.30315908 31.6871855,9.39220428 C31.4561522,9.48124949 31.1818068,9.52577209 30.8641493,9.52577209 C30.4492934,9.52577209 30.0901218,9.43375397 29.7866347,9.24971771 C29.4831475,9.06568146 29.2494439,8.80091349 29.0855238,8.45541382 C28.9216038,8.10991414 28.8396437,7.69349162 28.8396437,7.20614624 L28.8396437,6.61291504 C28.8396437,6.10328166 28.923473,5.67290243 29.0911314,5.32177734 C29.2587899,4.97065226 29.4870106,4.7049408 29.7757933,4.52464294 C30.0645761,4.34434509 30.3933953,4.25419617 30.7622511,4.25419617 C31.1320326,4.25419617 31.4583062,4.34062449 31.7410719,4.51348114 C32.0238376,4.68633779 32.2453469,4.94645945 32.4055998,5.29384613 C32.5658527,5.64123281 32.6459792,6.08092244 32.6459792,6.61291504 L32.6459792,7.20368958 L33.3616164,6.22016907 L28.0989058,6.22016907 L28.0989058,7.28070068 L34.0991499,7.28070068 L34.0991499,6.75946045 C34.0991499,6.01569621 33.9647632,5.36466217 33.6959898,4.80635834 C33.4272165,4.2480545 33.0428196,3.8133316 32.5427992,3.50218964 C32.0427789,3.19104767 31.446557,3.03547668 30.7541335,3.03547668 C30.0644871,3.03547668 29.4635654,3.19704692 28.9513686,3.52018738 C28.4391717,3.84332784 28.0431146,4.29451752 27.7631972,4.87375641 C27.4832798,5.4529953 27.3433211,6.13023376 27.3433211,6.9054718 L27.3433211,6.91230774 C27.3433211,7.69502258 27.4834934,8.37320455 27.7638381,8.94685364 C28.0441827,9.52050273 28.4444945,9.96353912 28.9647734,10.2759628 C29.4850523,10.5883865 30.1073897,10.7445984 30.8317854,10.7445984 Z" id="e"></path>
<path d="M42.8889222,10.8432922 C43.6544048,10.8432922 44.3193599,10.7182515 44.8837876,10.4681702 C45.4482153,10.2180888 45.8843624,9.8641154 46.1922288,9.40625 C46.5000952,8.9483846 46.6540284,8.40514119 46.6540284,7.77651978 L46.6540284,7.76968384 C46.6540284,7.03781128 46.4269471,6.45353444 45.9727845,6.01685333 C45.5186219,5.58017222 44.7736471,5.25081889 43.7378602,5.02879333 L42.662909,4.79402161 C42.0255291,4.65815735 41.567272,4.46812185 41.2881379,4.2239151 C41.0090038,3.97970835 40.8694367,3.67499288 40.8694367,3.30976868 L40.8694367,3.30293274 C40.8694367,2.99253845 40.9568798,2.72857157 41.1317658,2.5110321 C41.3066519,2.29349264 41.5445924,2.12613678 41.8455873,2.00896454 C42.1465821,1.8917923 42.4887706,1.83320618 42.8721528,1.83320618 C43.2704886,1.82950338 43.6187119,1.88830312 43.9168229,2.00960541 C44.2149339,2.13090769 44.4536398,2.29557546 44.6329408,2.5036087 C44.8122417,2.71164195 44.9233969,2.95148722 44.9664063,3.22314453 L44.9800782,3.30944824 L46.4725556,3.30944824 L46.4657197,3.21748352 C46.4296174,2.70357768 46.2604458,2.24190267 45.9582047,1.8324585 C45.6559637,1.42301432 45.2439739,1.09844971 44.7222352,0.858764648 C44.2004965,0.61907959 43.59103,0.499237061 42.8938355,0.499237061 C42.1964275,0.499237061 41.5788789,0.620646159 41.0411897,0.863464355 C40.5035005,1.10628255 40.0824494,1.44400279 39.7780366,1.87662506 C39.4736238,2.30924733 39.3195659,2.81070964 39.3158631,3.38101196 L39.3158631,3.3878479 C39.3158631,4.11587524 39.5434429,4.71264903 39.9986024,5.17816925 C40.4537619,5.64368947 41.1820741,5.9841512 42.1835389,6.19955444 L43.2584901,6.42877197 C43.9133159,6.56997681 44.3840165,6.76526388 44.6705918,7.01463318 C44.9571671,7.26400248 45.1004548,7.57788595 45.1004548,7.95628357 L45.1004548,7.96311951 C45.1004548,8.26575216 45.008134,8.53359985 44.8234925,8.7666626 C44.638851,8.99972534 44.3851558,9.18176778 44.062407,9.31278992 C43.7396582,9.44381205 43.3691824,9.50932312 42.9509797,9.50932312 C42.510489,9.50932312 42.1183127,9.44824473 41.7744508,9.32608795 C41.4305889,9.20393117 41.1567063,9.03305054 40.9528031,8.81344604 C40.7488999,8.59384155 40.6318523,8.33500163 40.6016603,8.03692627 L40.5948243,7.96546936 L39.0848298,7.96546936 L39.0916657,8.05198669 C39.1384492,8.6035614 39.3212749,9.08891296 39.6401429,9.50804138 C39.9590109,9.9271698 40.3941255,10.2544937 40.9454865,10.4900131 C41.4968476,10.7255325 42.1446595,10.8432922 42.8889222,10.8432922 Z" id="S"></path>
<path d="M51.1482117,10.6480408 C51.2942587,10.6480408 51.4353211,10.6405818 51.571399,10.6256638 C51.7074769,10.6107457 51.8341553,10.5933177 51.9514344,10.5733795 L51.9514344,9.38873291 C51.8471151,9.39784749 51.7556845,9.40489705 51.6771424,9.40988159 C51.5986003,9.41486613 51.5027192,9.4173584 51.3894989,9.4173584 C51.0234203,9.4173584 50.7602367,9.32863363 50.5999482,9.15118408 C50.4396597,8.97373454 50.3595154,8.68609111 50.3595154,8.28825378 L50.3595154,4.35150146 L51.9514344,4.35150146 L51.9514344,3.17657471 L50.3595154,3.17657471 L50.3595154,1.30950928 L48.8407624,1.30950928 L48.8407624,3.17657471 L47.6799347,3.17657471 L47.6799347,4.35150146 L48.8407624,4.35150146 L48.8407624,8.647995 C48.8407624,9.35985819 49.0218079,9.87116496 49.383899,10.1819153 C49.74599,10.4926656 50.3340943,10.6480408 51.1482117,10.6480408 Z" id="t"></path>
<path d="M55.5667207,10.729538 C55.8977652,10.729538 56.2024985,10.6836624 56.4809206,10.5919113 C56.7593426,10.5001602 57.0076082,10.3658447 57.2257173,10.1889648 C57.4438264,10.012085 57.6249076,9.79920959 57.7689607,9.55033875 L57.8833559,9.55033875 L57.8833559,10.6033936 L59.3585298,10.6033936 L59.3585298,5.52461243 C59.3585298,5.00500997 59.2454876,4.55926768 59.0194032,4.18738556 C58.7933188,3.81550344 58.463022,3.5305481 58.0285127,3.33251953 C57.5940034,3.13449097 57.0638266,3.03547668 56.4379823,3.03547668 C55.8755128,3.03547668 55.3772905,3.12012482 54.9433153,3.28942108 C54.50934,3.45871735 54.1592119,3.69494883 53.8929307,3.99811554 C53.6266496,4.30128225 53.4637086,4.65659078 53.4041078,5.06404114 L53.3972719,5.11381531 L54.8273714,5.11381531 L54.835489,5.09074402 C54.9253531,4.82706197 55.1011115,4.62308757 55.3627641,4.4788208 C55.6244167,4.33455404 55.9612113,4.26242065 56.3731477,4.26242065 C56.872812,4.26242065 57.2494295,4.37054952 57.503,4.58680725 C57.7565706,4.80306498 57.8833559,5.11566671 57.8833559,5.52461243 L57.8833559,7.85908508 C57.8833559,8.17823792 57.8006659,8.4644928 57.6352861,8.71784973 C57.4699063,8.97120667 57.2431454,9.17167409 56.9550035,9.31925201 C56.6668616,9.46682994 56.3379355,9.5406189 55.9682252,9.5406189 C55.5699607,9.5406189 55.2410346,9.44488017 54.981447,9.25340271 C54.7218594,9.06192525 54.5920656,8.79564412 54.5920656,8.45455933 L54.5920656,8.44088745 C54.5920656,8.10884603 54.7122463,7.85029093 54.9526079,7.66522217 C55.1929694,7.4801534 55.5687857,7.37295024 56.0800569,7.34361267 L58.6209962,7.1807251 L58.6209962,6.13279724 L55.8801057,6.29814148 C54.9940685,6.34990946 54.3105994,6.56422679 53.8296983,6.94109344 C53.3487972,7.3179601 53.1083467,7.83825684 53.1083467,8.50198364 L53.1083467,8.51565552 C53.1083467,8.96561686 53.2153184,9.35676066 53.4292619,9.68908691 C53.6432054,10.0214132 53.935691,10.2779032 54.3067186,10.4585571 C54.6777462,10.639211 55.0977469,10.729538 55.5667207,10.729538 Z" id="a"></path>
<path d="M64.1054292,10.6480408 C64.2514761,10.6480408 64.3925385,10.6405818 64.5286164,10.6256638 C64.6646943,10.6107457 64.7913728,10.5933177 64.9086518,10.5733795 L64.9086518,9.38873291 C64.8043326,9.39784749 64.7129019,9.40489705 64.6343598,9.40988159 C64.5558178,9.41486613 64.4599366,9.4173584 64.3467164,9.4173584 C63.9806377,9.4173584 63.7174541,9.32863363 63.5571656,9.15118408 C63.3968771,8.97373454 63.3167329,8.68609111 63.3167329,8.28825378 L63.3167329,4.35150146 L64.9086518,4.35150146 L64.9086518,3.17657471 L63.3167329,3.17657471 L63.3167329,1.30950928 L61.7979798,1.30950928 L61.7979798,3.17657471 L60.6371522,3.17657471 L60.6371522,4.35150146 L61.7979798,4.35150146 L61.7979798,8.647995 C61.7979798,9.35985819 61.9790254,9.87116496 62.3411164,10.1819153 C62.7032075,10.4926656 63.2913117,10.6480408 64.1054292,10.6480408 Z" id="t"></path>
<path d="M69.5248706,10.7445984 C70.0004667,10.7445984 70.4226037,10.6835378 70.7912815,10.5614166 C71.1599592,10.4392955 71.4748218,10.2774048 71.7358692,10.0757446 C71.9969165,9.87408447 72.2072818,9.65173848 72.3669651,9.40870667 C72.5266483,9.16567485 72.6371448,8.92175293 72.6984546,8.67694092 L72.7134082,8.61595154 L71.2782886,8.61723328 L71.2535083,8.6711731 C71.1963286,8.79778035 71.0942523,8.92734273 70.9472797,9.05986023 C70.800307,9.19237773 70.611304,9.30315908 70.3802707,9.39220428 C70.1492374,9.48124949 69.874892,9.52577209 69.5572345,9.52577209 C69.1423786,9.52577209 68.783207,9.43375397 68.4797199,9.24971771 C68.1762327,9.06568146 67.9425291,8.80091349 67.778609,8.45541382 C67.614689,8.10991414 67.5327289,7.69349162 67.5327289,7.20614624 L67.5327289,6.61291504 C67.5327289,6.10328166 67.6165582,5.67290243 67.7842166,5.32177734 C67.9518751,4.97065226 68.1800958,4.7049408 68.4688785,4.52464294 C68.7576613,4.34434509 69.0864805,4.25419617 69.4553363,4.25419617 C69.8251178,4.25419617 70.1513914,4.34062449 70.4341571,4.51348114 C70.7169228,4.68633779 70.9384321,4.94645945 71.098685,5.29384613 C71.2589379,5.64123281 71.3390644,6.08092244 71.3390644,6.61291504 L71.3390644,7.20368958 L72.0547016,6.22016907 L66.791991,6.22016907 L66.791991,7.28070068 L72.7922351,7.28070068 L72.7922351,6.75946045 C72.7922351,6.01569621 72.6578484,5.36466217 72.389075,4.80635834 C72.1203016,4.2480545 71.7359048,3.8133316 71.2358844,3.50218964 C70.7358641,3.19104767 70.1396422,3.03547668 69.4472187,3.03547668 C68.7575723,3.03547668 68.1566506,3.19704692 67.6444538,3.52018738 C67.1322569,3.84332784 66.7361998,4.29451752 66.4562824,4.87375641 C66.176365,5.4529953 66.0364063,6.13023376 66.0364063,6.9054718 L66.0364063,6.91230774 C66.0364063,7.69502258 66.1765786,8.37320455 66.4569232,8.94685364 C66.7372679,9.52050273 67.1375797,9.96353912 67.6578586,10.2759628 C68.1781375,10.5883865 68.8004749,10.7445984 69.5248706,10.7445984 Z" id="e"></path>
<path d="M77.4835424,10.6033936 L79.0975714,10.6033936 L81.8167791,2.47108459 L82.2854681,2.47108459 L82.2854681,0.739135742 L81.0437841,0.739135742 L77.4835424,10.6033936 Z M79.1998968,7.93812561 L84.5504065,7.93812561 L84.1225195,6.70915222 L79.6278906,6.70915222 L79.1998968,7.93812561 Z M84.650382,10.6033936 L86.2645178,10.6033936 L82.7042761,0.739135742 L81.9311743,0.739135742 L81.9311743,2.47108459 L84.650382,10.6033936 Z" id="A"></path>
</g>
</g>
<g id="Write-C" transform="translate(366.000000, 188.000000)">
<g id="Background" filter="url(#filter-3)" fill="#FFEEB3">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-2)" x="-0.5" y="-0.5" width="111" height="41" rx="10"></rect>
<g id="Text" transform="translate(11.800964, 14.396606)" fill="#000000" fill-rule="nonzero">
<polygon id="W" points="2.6602478 10.6033936 4.11064148 10.6033936 6.22476196 3.2358551 6.3168335 3.2358551 8.43714905 10.6033936 9.88380432 10.6033936 12.5440521 0.739135742 10.9479675 0.739135742 9.14648438 8.40296936 9.05451965 8.40296936 6.98429871 0.739135742 5.55718994 0.739135742 3.49957275 8.40296936 3.40750122 8.40296936 1.60099792 0.739135742 0 0.739135742"></polygon>
<path d="M13.6347213,10.6033936 L15.1199355,10.6033936 L15.1199355,6.16729736 C15.1199355,5.80898031 15.2001866,5.49789174 15.3606887,5.23403168 C15.5211908,4.97017161 15.7445515,4.76534271 16.0307708,4.61954498 C16.3169901,4.47374725 16.6492273,4.40084839 17.0274825,4.40084839 C17.1688298,4.40084839 17.3043024,4.40800476 17.4339004,4.4223175 C17.5634983,4.43663025 17.6944137,4.45767212 17.8266463,4.48544312 L17.8266463,3.11590576 C17.75316,3.09924316 17.6570474,3.08416494 17.5383086,3.07067108 C17.4195698,3.05717723 17.299033,3.0504303 17.1766982,3.0504303 C16.6833002,3.0504303 16.2696548,3.15962728 15.9357619,3.37802124 C15.6018691,3.5964152 15.3680587,3.90346273 15.2343307,4.29916382 L15.1199355,4.29916382 L15.1199355,3.17657471 L13.6347213,3.17657471 L13.6347213,10.6033936 Z" id="r"></path>
<path d="M19.1169329,10.6033936 L20.6021471,10.6033936 L20.6021471,3.17657471 L19.1169329,3.17657471 L19.1169329,10.6033936 Z M19.8650408,1.85243225 C20.1230262,1.85243225 20.3428443,1.76151784 20.5244951,1.57968903 C20.7061459,1.39786021 20.7969713,1.18026733 20.7969713,0.9269104 C20.7969713,0.668924967 20.7061459,0.449943542 20.5244951,0.269966125 C20.3428443,0.0899887085 20.1230262,0 19.8650408,0 C19.6116838,0 19.3930407,0.0899887085 19.2091112,0.269966125 C19.0251818,0.449943542 18.933217,0.668924967 18.933217,0.9269104 C18.933217,1.18026733 19.0251818,1.39786021 19.2091112,1.57968903 C19.3930407,1.76151784 19.6116838,1.85243225 19.8650408,1.85243225 Z" id="i"></path>
<path d="M25.412344,10.6480408 C25.5583909,10.6480408 25.6994534,10.6405818 25.8355312,10.6256638 C25.9716091,10.6107457 26.0982876,10.5933177 26.2155666,10.5733795 L26.2155666,9.38873291 C26.1112474,9.39784749 26.0198167,9.40489705 25.9412746,9.40988159 C25.8627326,9.41486613 25.7668514,9.4173584 25.6536312,9.4173584 C25.2875525,9.4173584 25.0243689,9.32863363 24.8640804,9.15118408 C24.7037919,8.97373454 24.6236477,8.68609111 24.6236477,8.28825378 L24.6236477,4.35150146 L26.2155666,4.35150146 L26.2155666,3.17657471 L24.6236477,3.17657471 L24.6236477,1.30950928 L23.1048946,1.30950928 L23.1048946,3.17657471 L21.944067,3.17657471 L21.944067,4.35150146 L23.1048946,4.35150146 L23.1048946,8.647995 C23.1048946,9.35985819 23.2859402,9.87116496 23.6480312,10.1819153 C24.0101223,10.4926656 24.5982265,10.6480408 25.412344,10.6480408 Z" id="t"></path>
<path d="M30.8317854,10.7445984 C31.3073816,10.7445984 31.7295185,10.6835378 32.0981963,10.5614166 C32.466874,10.4392955 32.7817366,10.2774048 33.042784,10.0757446 C33.3038313,9.87408447 33.5141966,9.65173848 33.6738799,9.40870667 C33.8335631,9.16567485 33.9440596,8.92175293 34.0053694,8.67694092 L34.020323,8.61595154 L32.5852034,8.61723328 L32.5604231,8.6711731 C32.5032434,8.79778035 32.4011672,8.92734273 32.2541945,9.05986023 C32.1072218,9.19237773 31.9182189,9.30315908 31.6871855,9.39220428 C31.4561522,9.48124949 31.1818068,9.52577209 30.8641493,9.52577209 C30.4492934,9.52577209 30.0901218,9.43375397 29.7866347,9.24971771 C29.4831475,9.06568146 29.2494439,8.80091349 29.0855238,8.45541382 C28.9216038,8.10991414 28.8396437,7.69349162 28.8396437,7.20614624 L28.8396437,6.61291504 C28.8396437,6.10328166 28.923473,5.67290243 29.0911314,5.32177734 C29.2587899,4.97065226 29.4870106,4.7049408 29.7757933,4.52464294 C30.0645761,4.34434509 30.3933953,4.25419617 30.7622511,4.25419617 C31.1320326,4.25419617 31.4583062,4.34062449 31.7410719,4.51348114 C32.0238376,4.68633779 32.2453469,4.94645945 32.4055998,5.29384613 C32.5658527,5.64123281 32.6459792,6.08092244 32.6459792,6.61291504 L32.6459792,7.20368958 L33.3616164,6.22016907 L28.0989058,6.22016907 L28.0989058,7.28070068 L34.0991499,7.28070068 L34.0991499,6.75946045 C34.0991499,6.01569621 33.9647632,5.36466217 33.6959898,4.80635834 C33.4272165,4.2480545 33.0428196,3.8133316 32.5427992,3.50218964 C32.0427789,3.19104767 31.446557,3.03547668 30.7541335,3.03547668 C30.0644871,3.03547668 29.4635654,3.19704692 28.9513686,3.52018738 C28.4391717,3.84332784 28.0431146,4.29451752 27.7631972,4.87375641 C27.4832798,5.4529953 27.3433211,6.13023376 27.3433211,6.9054718 L27.3433211,6.91230774 C27.3433211,7.69502258 27.4834934,8.37320455 27.7638381,8.94685364 C28.0441827,9.52050273 28.4444945,9.96353912 28.9647734,10.2759628 C29.4850523,10.5883865 30.1073897,10.7445984 30.8317854,10.7445984 Z" id="e"></path>
<path d="M42.8889222,10.8432922 C43.6544048,10.8432922 44.3193599,10.7182515 44.8837876,10.4681702 C45.4482153,10.2180888 45.8843624,9.8641154 46.1922288,9.40625 C46.5000952,8.9483846 46.6540284,8.40514119 46.6540284,7.77651978 L46.6540284,7.76968384 C46.6540284,7.03781128 46.4269471,6.45353444 45.9727845,6.01685333 C45.5186219,5.58017222 44.7736471,5.25081889 43.7378602,5.02879333 L42.662909,4.79402161 C42.0255291,4.65815735 41.567272,4.46812185 41.2881379,4.2239151 C41.0090038,3.97970835 40.8694367,3.67499288 40.8694367,3.30976868 L40.8694367,3.30293274 C40.8694367,2.99253845 40.9568798,2.72857157 41.1317658,2.5110321 C41.3066519,2.29349264 41.5445924,2.12613678 41.8455873,2.00896454 C42.1465821,1.8917923 42.4887706,1.83320618 42.8721528,1.83320618 C43.2704886,1.82950338 43.6187119,1.88830312 43.9168229,2.00960541 C44.2149339,2.13090769 44.4536398,2.29557546 44.6329408,2.5036087 C44.8122417,2.71164195 44.9233969,2.95148722 44.9664063,3.22314453 L44.9800782,3.30944824 L46.4725556,3.30944824 L46.4657197,3.21748352 C46.4296174,2.70357768 46.2604458,2.24190267 45.9582047,1.8324585 C45.6559637,1.42301432 45.2439739,1.09844971 44.7222352,0.858764648 C44.2004965,0.61907959 43.59103,0.499237061 42.8938355,0.499237061 C42.1964275,0.499237061 41.5788789,0.620646159 41.0411897,0.863464355 C40.5035005,1.10628255 40.0824494,1.44400279 39.7780366,1.87662506 C39.4736238,2.30924733 39.3195659,2.81070964 39.3158631,3.38101196 L39.3158631,3.3878479 C39.3158631,4.11587524 39.5434429,4.71264903 39.9986024,5.17816925 C40.4537619,5.64368947 41.1820741,5.9841512 42.1835389,6.19955444 L43.2584901,6.42877197 C43.9133159,6.56997681 44.3840165,6.76526388 44.6705918,7.01463318 C44.9571671,7.26400248 45.1004548,7.57788595 45.1004548,7.95628357 L45.1004548,7.96311951 C45.1004548,8.26575216 45.008134,8.53359985 44.8234925,8.7666626 C44.638851,8.99972534 44.3851558,9.18176778 44.062407,9.31278992 C43.7396582,9.44381205 43.3691824,9.50932312 42.9509797,9.50932312 C42.510489,9.50932312 42.1183127,9.44824473 41.7744508,9.32608795 C41.4305889,9.20393117 41.1567063,9.03305054 40.9528031,8.81344604 C40.7488999,8.59384155 40.6318523,8.33500163 40.6016603,8.03692627 L40.5948243,7.96546936 L39.0848298,7.96546936 L39.0916657,8.05198669 C39.1384492,8.6035614 39.3212749,9.08891296 39.6401429,9.50804138 C39.9590109,9.9271698 40.3941255,10.2544937 40.9454865,10.4900131 C41.4968476,10.7255325 42.1446595,10.8432922 42.8889222,10.8432922 Z" id="S"></path>
<path d="M51.1482117,10.6480408 C51.2942587,10.6480408 51.4353211,10.6405818 51.571399,10.6256638 C51.7074769,10.6107457 51.8341553,10.5933177 51.9514344,10.5733795 L51.9514344,9.38873291 C51.8471151,9.39784749 51.7556845,9.40489705 51.6771424,9.40988159 C51.5986003,9.41486613 51.5027192,9.4173584 51.3894989,9.4173584 C51.0234203,9.4173584 50.7602367,9.32863363 50.5999482,9.15118408 C50.4396597,8.97373454 50.3595154,8.68609111 50.3595154,8.28825378 L50.3595154,4.35150146 L51.9514344,4.35150146 L51.9514344,3.17657471 L50.3595154,3.17657471 L50.3595154,1.30950928 L48.8407624,1.30950928 L48.8407624,3.17657471 L47.6799347,3.17657471 L47.6799347,4.35150146 L48.8407624,4.35150146 L48.8407624,8.647995 C48.8407624,9.35985819 49.0218079,9.87116496 49.383899,10.1819153 C49.74599,10.4926656 50.3340943,10.6480408 51.1482117,10.6480408 Z" id="t"></path>
<path d="M55.5667207,10.729538 C55.8977652,10.729538 56.2024985,10.6836624 56.4809206,10.5919113 C56.7593426,10.5001602 57.0076082,10.3658447 57.2257173,10.1889648 C57.4438264,10.012085 57.6249076,9.79920959 57.7689607,9.55033875 L57.8833559,9.55033875 L57.8833559,10.6033936 L59.3585298,10.6033936 L59.3585298,5.52461243 C59.3585298,5.00500997 59.2454876,4.55926768 59.0194032,4.18738556 C58.7933188,3.81550344 58.463022,3.5305481 58.0285127,3.33251953 C57.5940034,3.13449097 57.0638266,3.03547668 56.4379823,3.03547668 C55.8755128,3.03547668 55.3772905,3.12012482 54.9433153,3.28942108 C54.50934,3.45871735 54.1592119,3.69494883 53.8929307,3.99811554 C53.6266496,4.30128225 53.4637086,4.65659078 53.4041078,5.06404114 L53.3972719,5.11381531 L54.8273714,5.11381531 L54.835489,5.09074402 C54.9253531,4.82706197 55.1011115,4.62308757 55.3627641,4.4788208 C55.6244167,4.33455404 55.9612113,4.26242065 56.3731477,4.26242065 C56.872812,4.26242065 57.2494295,4.37054952 57.503,4.58680725 C57.7565706,4.80306498 57.8833559,5.11566671 57.8833559,5.52461243 L57.8833559,7.85908508 C57.8833559,8.17823792 57.8006659,8.4644928 57.6352861,8.71784973 C57.4699063,8.97120667 57.2431454,9.17167409 56.9550035,9.31925201 C56.6668616,9.46682994 56.3379355,9.5406189 55.9682252,9.5406189 C55.5699607,9.5406189 55.2410346,9.44488017 54.981447,9.25340271 C54.7218594,9.06192525 54.5920656,8.79564412 54.5920656,8.45455933 L54.5920656,8.44088745 C54.5920656,8.10884603 54.7122463,7.85029093 54.9526079,7.66522217 C55.1929694,7.4801534 55.5687857,7.37295024 56.0800569,7.34361267 L58.6209962,7.1807251 L58.6209962,6.13279724 L55.8801057,6.29814148 C54.9940685,6.34990946 54.3105994,6.56422679 53.8296983,6.94109344 C53.3487972,7.3179601 53.1083467,7.83825684 53.1083467,8.50198364 L53.1083467,8.51565552 C53.1083467,8.96561686 53.2153184,9.35676066 53.4292619,9.68908691 C53.6432054,10.0214132 53.935691,10.2779032 54.3067186,10.4585571 C54.6777462,10.639211 55.0977469,10.729538 55.5667207,10.729538 Z" id="a"></path>
<path d="M64.1054292,10.6480408 C64.2514761,10.6480408 64.3925385,10.6405818 64.5286164,10.6256638 C64.6646943,10.6107457 64.7913728,10.5933177 64.9086518,10.5733795 L64.9086518,9.38873291 C64.8043326,9.39784749 64.7129019,9.40489705 64.6343598,9.40988159 C64.5558178,9.41486613 64.4599366,9.4173584 64.3467164,9.4173584 C63.9806377,9.4173584 63.7174541,9.32863363 63.5571656,9.15118408 C63.3968771,8.97373454 63.3167329,8.68609111 63.3167329,8.28825378 L63.3167329,4.35150146 L64.9086518,4.35150146 L64.9086518,3.17657471 L63.3167329,3.17657471 L63.3167329,1.30950928 L61.7979798,1.30950928 L61.7979798,3.17657471 L60.6371522,3.17657471 L60.6371522,4.35150146 L61.7979798,4.35150146 L61.7979798,8.647995 C61.7979798,9.35985819 61.9790254,9.87116496 62.3411164,10.1819153 C62.7032075,10.4926656 63.2913117,10.6480408 64.1054292,10.6480408 Z" id="t"></path>
<path d="M69.5248706,10.7445984 C70.0004667,10.7445984 70.4226037,10.6835378 70.7912815,10.5614166 C71.1599592,10.4392955 71.4748218,10.2774048 71.7358692,10.0757446 C71.9969165,9.87408447 72.2072818,9.65173848 72.3669651,9.40870667 C72.5266483,9.16567485 72.6371448,8.92175293 72.6984546,8.67694092 L72.7134082,8.61595154 L71.2782886,8.61723328 L71.2535083,8.6711731 C71.1963286,8.79778035 71.0942523,8.92734273 70.9472797,9.05986023 C70.800307,9.19237773 70.611304,9.30315908 70.3802707,9.39220428 C70.1492374,9.48124949 69.874892,9.52577209 69.5572345,9.52577209 C69.1423786,9.52577209 68.783207,9.43375397 68.4797199,9.24971771 C68.1762327,9.06568146 67.9425291,8.80091349 67.778609,8.45541382 C67.614689,8.10991414 67.5327289,7.69349162 67.5327289,7.20614624 L67.5327289,6.61291504 C67.5327289,6.10328166 67.6165582,5.67290243 67.7842166,5.32177734 C67.9518751,4.97065226 68.1800958,4.7049408 68.4688785,4.52464294 C68.7576613,4.34434509 69.0864805,4.25419617 69.4553363,4.25419617 C69.8251178,4.25419617 70.1513914,4.34062449 70.4341571,4.51348114 C70.7169228,4.68633779 70.9384321,4.94645945 71.098685,5.29384613 C71.2589379,5.64123281 71.3390644,6.08092244 71.3390644,6.61291504 L71.3390644,7.20368958 L72.0547016,6.22016907 L66.791991,6.22016907 L66.791991,7.28070068 L72.7922351,7.28070068 L72.7922351,6.75946045 C72.7922351,6.01569621 72.6578484,5.36466217 72.389075,4.80635834 C72.1203016,4.2480545 71.7359048,3.8133316 71.2358844,3.50218964 C70.7358641,3.19104767 70.1396422,3.03547668 69.4472187,3.03547668 C68.7575723,3.03547668 68.1566506,3.19704692 67.6444538,3.52018738 C67.1322569,3.84332784 66.7361998,4.29451752 66.4562824,4.87375641 C66.176365,5.4529953 66.0364063,6.13023376 66.0364063,6.9054718 L66.0364063,6.91230774 C66.0364063,7.69502258 66.1765786,8.37320455 66.4569232,8.94685364 C66.7372679,9.52050273 67.1375797,9.96353912 67.6578586,10.2759628 C68.1781375,10.5883865 68.8004749,10.7445984 69.5248706,10.7445984 Z" id="e"></path>
<path d="M82.2927313,10.8432922 C83.0288051,10.8432922 83.6864258,10.7116826 84.2655935,10.4484634 C84.8447612,10.1852442 85.319129,9.81747437 85.6886969,9.34515381 C86.0582647,8.87283325 86.2910782,8.32001241 86.3871374,7.68669128 L86.3883123,7.64920044 L84.863471,7.64920044 L84.8497992,7.67921448 C84.7603623,8.0474294 84.5970297,8.36688487 84.3598013,8.63758087 C84.1225729,8.90827688 83.8281825,9.11684418 83.4766302,9.26328278 C83.1250779,9.40972137 82.7308722,9.48294067 82.294013,9.48294067 C81.7022772,9.48294067 81.1907924,9.32808177 80.7595587,9.01836395 C80.328325,8.70864614 79.9959453,8.26908112 79.7624197,7.69966888 C79.5288941,7.13025665 79.4121313,6.45672099 79.4121313,5.67906189 L79.4121313,5.66539001 C79.4121313,4.88395691 79.5288941,4.20896149 79.7624197,3.64040375 C79.9959453,3.07184601 80.328325,2.63290405 80.7595587,2.32357788 C81.1907924,2.01425171 81.6999985,1.85958862 82.2871771,1.85958862 C82.7203334,1.85958862 83.1123851,1.94160207 83.4633322,2.10562897 C83.8142792,2.26965586 84.110432,2.50024414 84.3517904,2.7973938 C84.5931489,3.09454346 84.7610032,3.44541931 84.8553534,3.85002136 L84.8621893,3.87501526 L86.3814764,3.87501526 L86.3858557,3.83506775 C86.3018306,3.18273417 86.0725419,2.60572052 85.6979895,2.10402679 C85.3234371,1.60233307 84.8426428,1.20944468 84.2556067,0.925361633 C83.6685705,0.641278585 83.0124273,0.499237061 82.2871771,0.499237061 C81.3713751,0.499237061 80.5812368,0.708658854 79.9167624,1.12750244 C79.2522879,1.54634603 78.7396994,2.14148204 78.3789968,2.91291046 C78.0182943,3.68433889 77.8379431,4.60222371 77.8379431,5.66656494 L77.8379431,5.68023682 C77.8379431,6.74087524 78.0182943,7.65690867 78.3789968,8.4283371 C78.7396994,9.19976552 79.2534272,9.79511515 79.9201803,10.214386 C80.5869335,10.6336568 81.3777838,10.8432922 82.2927313,10.8432922 Z" id="C"></path>
</g>
</g>
<g id="Write-C" transform="translate(66.000000, 130.000000)">
<g id="Background" filter="url(#filter-4)" fill="#E6F0C7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-2)" x="-0.5" y="-0.5" width="111" height="41" rx="10"></rect>
<g id="Text" transform="translate(12.183546, 14.396606)" fill="#000000" fill-rule="nonzero">
<polygon id="W" points="2.6602478 10.6033936 4.11064148 10.6033936 6.22476196 3.2358551 6.3168335 3.2358551 8.43714905 10.6033936 9.88380432 10.6033936 12.5440521 0.739135742 10.9479675 0.739135742 9.14648438 8.40296936 9.05451965 8.40296936 6.98429871 0.739135742 5.55718994 0.739135742 3.49957275 8.40296936 3.40750122 8.40296936 1.60099792 0.739135742 0 0.739135742"></polygon>
<path d="M13.6347213,10.6033936 L15.1199355,10.6033936 L15.1199355,6.16729736 C15.1199355,5.80898031 15.2001866,5.49789174 15.3606887,5.23403168 C15.5211908,4.97017161 15.7445515,4.76534271 16.0307708,4.61954498 C16.3169901,4.47374725 16.6492273,4.40084839 17.0274825,4.40084839 C17.1688298,4.40084839 17.3043024,4.40800476 17.4339004,4.4223175 C17.5634983,4.43663025 17.6944137,4.45767212 17.8266463,4.48544312 L17.8266463,3.11590576 C17.75316,3.09924316 17.6570474,3.08416494 17.5383086,3.07067108 C17.4195698,3.05717723 17.299033,3.0504303 17.1766982,3.0504303 C16.6833002,3.0504303 16.2696548,3.15962728 15.9357619,3.37802124 C15.6018691,3.5964152 15.3680587,3.90346273 15.2343307,4.29916382 L15.1199355,4.29916382 L15.1199355,3.17657471 L13.6347213,3.17657471 L13.6347213,10.6033936 Z" id="r"></path>
<path d="M19.1169329,10.6033936 L20.6021471,10.6033936 L20.6021471,3.17657471 L19.1169329,3.17657471 L19.1169329,10.6033936 Z M19.8650408,1.85243225 C20.1230262,1.85243225 20.3428443,1.76151784 20.5244951,1.57968903 C20.7061459,1.39786021 20.7969713,1.18026733 20.7969713,0.9269104 C20.7969713,0.668924967 20.7061459,0.449943542 20.5244951,0.269966125 C20.3428443,0.0899887085 20.1230262,0 19.8650408,0 C19.6116838,0 19.3930407,0.0899887085 19.2091112,0.269966125 C19.0251818,0.449943542 18.933217,0.668924967 18.933217,0.9269104 C18.933217,1.18026733 19.0251818,1.39786021 19.2091112,1.57968903 C19.3930407,1.76151784 19.6116838,1.85243225 19.8650408,1.85243225 Z" id="i"></path>
<path d="M25.412344,10.6480408 C25.5583909,10.6480408 25.6994534,10.6405818 25.8355312,10.6256638 C25.9716091,10.6107457 26.0982876,10.5933177 26.2155666,10.5733795 L26.2155666,9.38873291 C26.1112474,9.39784749 26.0198167,9.40489705 25.9412746,9.40988159 C25.8627326,9.41486613 25.7668514,9.4173584 25.6536312,9.4173584 C25.2875525,9.4173584 25.0243689,9.32863363 24.8640804,9.15118408 C24.7037919,8.97373454 24.6236477,8.68609111 24.6236477,8.28825378 L24.6236477,4.35150146 L26.2155666,4.35150146 L26.2155666,3.17657471 L24.6236477,3.17657471 L24.6236477,1.30950928 L23.1048946,1.30950928 L23.1048946,3.17657471 L21.944067,3.17657471 L21.944067,4.35150146 L23.1048946,4.35150146 L23.1048946,8.647995 C23.1048946,9.35985819 23.2859402,9.87116496 23.6480312,10.1819153 C24.0101223,10.4926656 24.5982265,10.6480408 25.412344,10.6480408 Z" id="t"></path>
<path d="M30.8317854,10.7445984 C31.3073816,10.7445984 31.7295185,10.6835378 32.0981963,10.5614166 C32.466874,10.4392955 32.7817366,10.2774048 33.042784,10.0757446 C33.3038313,9.87408447 33.5141966,9.65173848 33.6738799,9.40870667 C33.8335631,9.16567485 33.9440596,8.92175293 34.0053694,8.67694092 L34.020323,8.61595154 L32.5852034,8.61723328 L32.5604231,8.6711731 C32.5032434,8.79778035 32.4011672,8.92734273 32.2541945,9.05986023 C32.1072218,9.19237773 31.9182189,9.30315908 31.6871855,9.39220428 C31.4561522,9.48124949 31.1818068,9.52577209 30.8641493,9.52577209 C30.4492934,9.52577209 30.0901218,9.43375397 29.7866347,9.24971771 C29.4831475,9.06568146 29.2494439,8.80091349 29.0855238,8.45541382 C28.9216038,8.10991414 28.8396437,7.69349162 28.8396437,7.20614624 L28.8396437,6.61291504 C28.8396437,6.10328166 28.923473,5.67290243 29.0911314,5.32177734 C29.2587899,4.97065226 29.4870106,4.7049408 29.7757933,4.52464294 C30.0645761,4.34434509 30.3933953,4.25419617 30.7622511,4.25419617 C31.1320326,4.25419617 31.4583062,4.34062449 31.7410719,4.51348114 C32.0238376,4.68633779 32.2453469,4.94645945 32.4055998,5.29384613 C32.5658527,5.64123281 32.6459792,6.08092244 32.6459792,6.61291504 L32.6459792,7.20368958 L33.3616164,6.22016907 L28.0989058,6.22016907 L28.0989058,7.28070068 L34.0991499,7.28070068 L34.0991499,6.75946045 C34.0991499,6.01569621 33.9647632,5.36466217 33.6959898,4.80635834 C33.4272165,4.2480545 33.0428196,3.8133316 32.5427992,3.50218964 C32.0427789,3.19104767 31.446557,3.03547668 30.7541335,3.03547668 C30.0644871,3.03547668 29.4635654,3.19704692 28.9513686,3.52018738 C28.4391717,3.84332784 28.0431146,4.29451752 27.7631972,4.87375641 C27.4832798,5.4529953 27.3433211,6.13023376 27.3433211,6.9054718 L27.3433211,6.91230774 C27.3433211,7.69502258 27.4834934,8.37320455 27.7638381,8.94685364 C28.0441827,9.52050273 28.4444945,9.96353912 28.9647734,10.2759628 C29.4850523,10.5883865 30.1073897,10.7445984 30.8317854,10.7445984 Z" id="e"></path>
<path d="M42.8889222,10.8432922 C43.6544048,10.8432922 44.3193599,10.7182515 44.8837876,10.4681702 C45.4482153,10.2180888 45.8843624,9.8641154 46.1922288,9.40625 C46.5000952,8.9483846 46.6540284,8.40514119 46.6540284,7.77651978 L46.6540284,7.76968384 C46.6540284,7.03781128 46.4269471,6.45353444 45.9727845,6.01685333 C45.5186219,5.58017222 44.7736471,5.25081889 43.7378602,5.02879333 L42.662909,4.79402161 C42.0255291,4.65815735 41.567272,4.46812185 41.2881379,4.2239151 C41.0090038,3.97970835 40.8694367,3.67499288 40.8694367,3.30976868 L40.8694367,3.30293274 C40.8694367,2.99253845 40.9568798,2.72857157 41.1317658,2.5110321 C41.3066519,2.29349264 41.5445924,2.12613678 41.8455873,2.00896454 C42.1465821,1.8917923 42.4887706,1.83320618 42.8721528,1.83320618 C43.2704886,1.82950338 43.6187119,1.88830312 43.9168229,2.00960541 C44.2149339,2.13090769 44.4536398,2.29557546 44.6329408,2.5036087 C44.8122417,2.71164195 44.9233969,2.95148722 44.9664063,3.22314453 L44.9800782,3.30944824 L46.4725556,3.30944824 L46.4657197,3.21748352 C46.4296174,2.70357768 46.2604458,2.24190267 45.9582047,1.8324585 C45.6559637,1.42301432 45.2439739,1.09844971 44.7222352,0.858764648 C44.2004965,0.61907959 43.59103,0.499237061 42.8938355,0.499237061 C42.1964275,0.499237061 41.5788789,0.620646159 41.0411897,0.863464355 C40.5035005,1.10628255 40.0824494,1.44400279 39.7780366,1.87662506 C39.4736238,2.30924733 39.3195659,2.81070964 39.3158631,3.38101196 L39.3158631,3.3878479 C39.3158631,4.11587524 39.5434429,4.71264903 39.9986024,5.17816925 C40.4537619,5.64368947 41.1820741,5.9841512 42.1835389,6.19955444 L43.2584901,6.42877197 C43.9133159,6.56997681 44.3840165,6.76526388 44.6705918,7.01463318 C44.9571671,7.26400248 45.1004548,7.57788595 45.1004548,7.95628357 L45.1004548,7.96311951 C45.1004548,8.26575216 45.008134,8.53359985 44.8234925,8.7666626 C44.638851,8.99972534 44.3851558,9.18176778 44.062407,9.31278992 C43.7396582,9.44381205 43.3691824,9.50932312 42.9509797,9.50932312 C42.510489,9.50932312 42.1183127,9.44824473 41.7744508,9.32608795 C41.4305889,9.20393117 41.1567063,9.03305054 40.9528031,8.81344604 C40.7488999,8.59384155 40.6318523,8.33500163 40.6016603,8.03692627 L40.5948243,7.96546936 L39.0848298,7.96546936 L39.0916657,8.05198669 C39.1384492,8.6035614 39.3212749,9.08891296 39.6401429,9.50804138 C39.9590109,9.9271698 40.3941255,10.2544937 40.9454865,10.4900131 C41.4968476,10.7255325 42.1446595,10.8432922 42.8889222,10.8432922 Z" id="S"></path>
<path d="M51.1482117,10.6480408 C51.2942587,10.6480408 51.4353211,10.6405818 51.571399,10.6256638 C51.7074769,10.6107457 51.8341553,10.5933177 51.9514344,10.5733795 L51.9514344,9.38873291 C51.8471151,9.39784749 51.7556845,9.40489705 51.6771424,9.40988159 C51.5986003,9.41486613 51.5027192,9.4173584 51.3894989,9.4173584 C51.0234203,9.4173584 50.7602367,9.32863363 50.5999482,9.15118408 C50.4396597,8.97373454 50.3595154,8.68609111 50.3595154,8.28825378 L50.3595154,4.35150146 L51.9514344,4.35150146 L51.9514344,3.17657471 L50.3595154,3.17657471 L50.3595154,1.30950928 L48.8407624,1.30950928 L48.8407624,3.17657471 L47.6799347,3.17657471 L47.6799347,4.35150146 L48.8407624,4.35150146 L48.8407624,8.647995 C48.8407624,9.35985819 49.0218079,9.87116496 49.383899,10.1819153 C49.74599,10.4926656 50.3340943,10.6480408 51.1482117,10.6480408 Z" id="t"></path>
<path d="M55.5667207,10.729538 C55.8977652,10.729538 56.2024985,10.6836624 56.4809206,10.5919113 C56.7593426,10.5001602 57.0076082,10.3658447 57.2257173,10.1889648 C57.4438264,10.012085 57.6249076,9.79920959 57.7689607,9.55033875 L57.8833559,9.55033875 L57.8833559,10.6033936 L59.3585298,10.6033936 L59.3585298,5.52461243 C59.3585298,5.00500997 59.2454876,4.55926768 59.0194032,4.18738556 C58.7933188,3.81550344 58.463022,3.5305481 58.0285127,3.33251953 C57.5940034,3.13449097 57.0638266,3.03547668 56.4379823,3.03547668 C55.8755128,3.03547668 55.3772905,3.12012482 54.9433153,3.28942108 C54.50934,3.45871735 54.1592119,3.69494883 53.8929307,3.99811554 C53.6266496,4.30128225 53.4637086,4.65659078 53.4041078,5.06404114 L53.3972719,5.11381531 L54.8273714,5.11381531 L54.835489,5.09074402 C54.9253531,4.82706197 55.1011115,4.62308757 55.3627641,4.4788208 C55.6244167,4.33455404 55.9612113,4.26242065 56.3731477,4.26242065 C56.872812,4.26242065 57.2494295,4.37054952 57.503,4.58680725 C57.7565706,4.80306498 57.8833559,5.11566671 57.8833559,5.52461243 L57.8833559,7.85908508 C57.8833559,8.17823792 57.8006659,8.4644928 57.6352861,8.71784973 C57.4699063,8.97120667 57.2431454,9.17167409 56.9550035,9.31925201 C56.6668616,9.46682994 56.3379355,9.5406189 55.9682252,9.5406189 C55.5699607,9.5406189 55.2410346,9.44488017 54.981447,9.25340271 C54.7218594,9.06192525 54.5920656,8.79564412 54.5920656,8.45455933 L54.5920656,8.44088745 C54.5920656,8.10884603 54.7122463,7.85029093 54.9526079,7.66522217 C55.1929694,7.4801534 55.5687857,7.37295024 56.0800569,7.34361267 L58.6209962,7.1807251 L58.6209962,6.13279724 L55.8801057,6.29814148 C54.9940685,6.34990946 54.3105994,6.56422679 53.8296983,6.94109344 C53.3487972,7.3179601 53.1083467,7.83825684 53.1083467,8.50198364 L53.1083467,8.51565552 C53.1083467,8.96561686 53.2153184,9.35676066 53.4292619,9.68908691 C53.6432054,10.0214132 53.935691,10.2779032 54.3067186,10.4585571 C54.6777462,10.639211 55.0977469,10.729538 55.5667207,10.729538 Z" id="a"></path>
<path d="M64.1054292,10.6480408 C64.2514761,10.6480408 64.3925385,10.6405818 64.5286164,10.6256638 C64.6646943,10.6107457 64.7913728,10.5933177 64.9086518,10.5733795 L64.9086518,9.38873291 C64.8043326,9.39784749 64.7129019,9.40489705 64.6343598,9.40988159 C64.5558178,9.41486613 64.4599366,9.4173584 64.3467164,9.4173584 C63.9806377,9.4173584 63.7174541,9.32863363 63.5571656,9.15118408 C63.3968771,8.97373454 63.3167329,8.68609111 63.3167329,8.28825378 L63.3167329,4.35150146 L64.9086518,4.35150146 L64.9086518,3.17657471 L63.3167329,3.17657471 L63.3167329,1.30950928 L61.7979798,1.30950928 L61.7979798,3.17657471 L60.6371522,3.17657471 L60.6371522,4.35150146 L61.7979798,4.35150146 L61.7979798,8.647995 C61.7979798,9.35985819 61.9790254,9.87116496 62.3411164,10.1819153 C62.7032075,10.4926656 63.2913117,10.6480408 64.1054292,10.6480408 Z" id="t"></path>
<path d="M69.5248706,10.7445984 C70.0004667,10.7445984 70.4226037,10.6835378 70.7912815,10.5614166 C71.1599592,10.4392955 71.4748218,10.2774048 71.7358692,10.0757446 C71.9969165,9.87408447 72.2072818,9.65173848 72.3669651,9.40870667 C72.5266483,9.16567485 72.6371448,8.92175293 72.6984546,8.67694092 L72.7134082,8.61595154 L71.2782886,8.61723328 L71.2535083,8.6711731 C71.1963286,8.79778035 71.0942523,8.92734273 70.9472797,9.05986023 C70.800307,9.19237773 70.611304,9.30315908 70.3802707,9.39220428 C70.1492374,9.48124949 69.874892,9.52577209 69.5572345,9.52577209 C69.1423786,9.52577209 68.783207,9.43375397 68.4797199,9.24971771 C68.1762327,9.06568146 67.9425291,8.80091349 67.778609,8.45541382 C67.614689,8.10991414 67.5327289,7.69349162 67.5327289,7.20614624 L67.5327289,6.61291504 C67.5327289,6.10328166 67.6165582,5.67290243 67.7842166,5.32177734 C67.9518751,4.97065226 68.1800958,4.7049408 68.4688785,4.52464294 C68.7576613,4.34434509 69.0864805,4.25419617 69.4553363,4.25419617 C69.8251178,4.25419617 70.1513914,4.34062449 70.4341571,4.51348114 C70.7169228,4.68633779 70.9384321,4.94645945 71.098685,5.29384613 C71.2589379,5.64123281 71.3390644,6.08092244 71.3390644,6.61291504 L71.3390644,7.20368958 L72.0547016,6.22016907 L66.791991,6.22016907 L66.791991,7.28070068 L72.7922351,7.28070068 L72.7922351,6.75946045 C72.7922351,6.01569621 72.6578484,5.36466217 72.389075,4.80635834 C72.1203016,4.2480545 71.7359048,3.8133316 71.2358844,3.50218964 C70.7358641,3.19104767 70.1396422,3.03547668 69.4472187,3.03547668 C68.7575723,3.03547668 68.1566506,3.19704692 67.6444538,3.52018738 C67.1322569,3.84332784 66.7361998,4.29451752 66.4562824,4.87375641 C66.176365,5.4529953 66.0364063,6.13023376 66.0364063,6.9054718 L66.0364063,6.91230774 C66.0364063,7.69502258 66.1765786,8.37320455 66.4569232,8.94685364 C66.7372679,9.52050273 67.1375797,9.96353912 67.6578586,10.2759628 C68.1781375,10.5883865 68.8004749,10.7445984 69.5248706,10.7445984 Z" id="e"></path>
<path d="M79.0089178,10.6033936 L82.3025579,10.6033936 C83.0051641,10.6033936 83.6069403,10.4914195 84.1078863,10.2674713 C84.6088324,10.0435232 84.9944754,9.72365824 85.2648153,9.30787659 C85.5351553,8.89209493 85.6703253,8.39709473 85.6703253,7.82287598 L85.6703253,7.8092041 C85.6703253,7.38046265 85.5776129,6.99590556 85.3921881,6.65553284 C85.2067633,6.31516012 84.9478877,6.03809102 84.6155615,5.82432556 C84.2832352,5.6105601 83.894014,5.48049927 83.4478979,5.43414307 L83.4478979,5.31974792 C83.7743851,5.26306661 84.0675472,5.13300578 84.327384,4.92956543 C84.5872208,4.72612508 84.7945064,4.47422791 84.9492407,4.1738739 C85.103975,3.8735199 85.1813421,3.55119832 85.1813421,3.20690918 L85.1813421,3.1932373 C85.1813421,2.69029744 85.0623185,2.25539653 84.8242712,1.88853455 C84.5862239,1.52167257 84.246047,1.2383906 83.8037405,1.03868866 C83.361434,0.838986715 82.8309546,0.739135742 82.2123022,0.739135742 L79.0089178,0.739135742 L79.0089178,1.99021912 L81.854804,1.99021912 C82.4211899,1.99021912 82.8618053,2.1188914 83.17665,2.37623596 C83.4914948,2.63358053 83.6489172,2.99453227 83.6489172,3.45909119 L83.6489172,3.47276306 C83.6489172,3.9504954 83.4755621,4.313797 83.1288519,4.56266785 C82.7821417,4.8115387 82.2697668,4.93597412 81.5917273,4.93597412 L79.0089178,4.93597412 L79.0089178,6.10577393 L81.9001989,6.10577393 C82.3817053,6.10577393 82.7854706,6.1658198 83.111495,6.28591156 C83.4375194,6.40600332 83.6831325,6.58530426 83.8483343,6.82381439 C84.0135361,7.06232452 84.096137,7.3577474 84.096137,7.71008301 L84.096137,7.72375488 C84.096137,8.25289917 83.9176728,8.65661112 83.5607443,8.93489075 C83.2038158,9.21317037 82.6806707,9.35231018 81.9913092,9.35231018 L79.0089178,9.35231018 L79.0089178,10.6033936 Z M78.2408361,10.6033936 L79.7771063,10.6033936 L79.7771063,0.739135742 L78.2408361,0.739135742 L78.2408361,10.6033936 Z" id="B"></path>
</g>
</g>
<g id="Group" transform="translate(47.000000, 90.000000)">
<mask id="mask-6" fill="white">
<use xlink:href="#path-5"></use>
</mask>
<g id="Rectangle"></g>
<g mask="url(#mask-6)" id="Stripes-Band" opacity="0.1">
<g transform="translate(-1.000000, 0.000000)">
<g id="Stripes" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(360.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(120.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(240.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(0.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(360.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(120.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(240.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(30.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(390.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(150.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(270.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(30.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(390.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(150.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(270.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(60.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(420.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(180.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(300.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(60.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(420.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(180.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(300.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(90.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(210.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(330.000000, 0.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(90.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(210.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
<g id="Stripes" transform="translate(330.000000, 30.000000)" fill="#000000">
<polygon id="Path" points="0 0 0 15 15 2.08166817e-14"></polygon>
<polygon id="Path-Copy" points="-1.18090979e-14 30 15 30 30 15 30 -3.12250226e-16"></polygon>
</g>
</g>
</g>
</g>
<g id="Read-A" transform="translate(216.000000, 130.000000)">
<g id="Background" filter="url(#filter-7)" fill="#D7E6F7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="120" rx="10"></rect>
</g>
</g>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-8)" x="-0.5" y="-0.5" width="111" height="121" rx="10"></rect>
<g id="Text" transform="translate(15.398436, 54.664917)" fill="#000000" fill-rule="nonzero">
<path d="M0,10.335083 L1.53627014,10.335083 L1.53627014,6.54081726 L3.61268616,6.54081726 C3.62429301,6.54081726 3.63776906,6.54081726 3.65311432,6.54081726 C3.66845957,6.54081726 3.68150838,6.54081726 3.69226074,6.54081726 L5.70309448,10.335083 L7.47509766,10.335083 L5.26708984,6.30551147 C5.86680094,6.10036214 6.33500926,5.74651337 6.67171478,5.24396515 C7.00842031,4.74141693 7.17677307,4.15795898 7.17677307,3.49359131 L7.17677307,3.47991943 C7.17677307,2.86653646 7.04375712,2.33546956 6.77772522,1.88671875 C6.51169332,1.43796794 6.13302867,1.08979797 5.64173126,0.842208862 C5.15043386,0.594619751 4.56672668,0.470825195 3.89060974,0.470825195 L0,0.470825195 L0,10.335083 Z M1.53627014,5.29667664 L1.53627014,1.75630188 L3.69525146,1.75630188 C4.28898112,1.75630188 4.75437673,1.91345723 5.09143829,2.22776794 C5.42849986,2.54207865 5.59703064,2.97270711 5.59703064,3.51965332 L5.59703064,3.5333252 C5.59703064,4.09308879 5.43501536,4.52692159 5.1109848,4.83482361 C4.78695424,5.14272563 4.32992554,5.29667664 3.73989868,5.29667664 L1.53627014,5.29667664 Z" id="R"></path>
<path d="M11.9391818,10.4762878 C12.4147779,10.4762878 12.8369149,10.4152273 13.2055926,10.2931061 C13.5742704,10.1709849 13.889133,10.0090942 14.1501803,9.80743408 C14.4112277,9.60577393 14.621593,9.38342794 14.7812762,9.14039612 C14.9409595,8.8973643 15.051456,8.65344238 15.1127658,8.40863037 L15.1277194,8.34764099 L13.6925998,8.34892273 L13.6678195,8.40286255 C13.6106397,8.52946981 13.5085635,8.65903219 13.3615909,8.79154968 C13.2146182,8.92406718 13.0256152,9.03484853 12.7945819,9.12389374 C12.5635486,9.21293894 12.2892032,9.25746155 11.9715457,9.25746155 C11.5566897,9.25746155 11.1975182,9.16544342 10.894031,8.98140717 C10.5905439,8.79737091 10.3568403,8.53260295 10.1929202,8.18710327 C10.0290001,7.8416036 9.94704008,7.42518107 9.94704008,6.93783569 L9.94704008,6.34460449 C9.94704008,5.83497111 10.0308693,5.40459188 10.1985278,5.0534668 C10.3661863,4.70234172 10.5944069,4.43663025 10.8831897,4.2563324 C11.1719724,4.07603455 11.5007917,3.98588562 11.8696475,3.98588562 C12.239429,3.98588562 12.5657026,4.07231394 12.8484683,4.24517059 C13.131234,4.41802724 13.3527433,4.67814891 13.5129962,5.02553558 C13.6732491,5.37292226 13.7533755,5.8126119 13.7533755,6.34460449 L13.7533755,6.93537903 L14.4690127,5.95185852 L9.20630217,5.95185852 L9.20630217,7.01239014 L15.2065463,7.01239014 L15.2065463,6.4911499 C15.2065463,5.74738566 15.0721596,5.09635162 14.8033862,4.53804779 C14.5346128,3.97974396 14.1502159,3.54502106 13.6501956,3.23387909 C13.1501753,2.92273712 12.5539533,2.76716614 11.8615298,2.76716614 C11.1718834,2.76716614 10.5709618,2.92873637 10.0587649,3.25187683 C9.54656808,3.57501729 9.15051095,4.02620697 8.87059355,4.60544586 C8.59067615,5.18468475 8.45071745,5.86192322 8.45071745,6.63716125 L8.45071745,6.64399719 C8.45071745,7.42671204 8.59088977,8.104894 8.87123442,8.67854309 C9.15157906,9.25219218 9.55189085,9.69522858 10.0721698,10.0076523 C10.5924487,10.320076 11.2147861,10.4762878 11.9391818,10.4762878 Z" id="e"></path>
<path d="M18.8538244,10.4612274 C19.1848689,10.4612274 19.4896022,10.4153519 19.7680242,10.3236008 C20.0464462,10.2318497 20.2947118,10.0975342 20.512821,9.9206543 C20.7309301,9.74377441 20.9120112,9.53089905 21.0560644,9.2820282 L21.1704595,9.2820282 L21.1704595,10.335083 L22.6456335,10.335083 L22.6456335,5.25630188 C22.6456335,4.73669942 22.5325913,4.29095713 22.3065069,3.91907501 C22.0804225,3.54719289 21.7501256,3.26223755 21.3156164,3.06420898 C20.8811071,2.86618042 20.3509303,2.76716614 19.725086,2.76716614 C19.1626165,2.76716614 18.6643941,2.85181427 18.2304189,3.02111053 C17.7964437,3.1904068 17.4463155,3.42663829 17.1800344,3.72980499 C16.9137533,4.0329717 16.7508123,4.38828023 16.6912115,4.79573059 L16.6843755,4.84550476 L18.114475,4.84550476 L18.1225927,4.82243347 C18.2124568,4.55875142 18.3882151,4.35477702 18.6498678,4.21051025 C18.9115204,4.06624349 19.2483149,3.99411011 19.6602514,3.99411011 C20.1599157,3.99411011 20.5365331,4.10223897 20.7901037,4.3184967 C21.0436742,4.53475444 21.1704595,4.84735616 21.1704595,5.25630188 L21.1704595,7.59077454 C21.1704595,7.90992737 21.0877696,8.19618225 20.9223897,8.44953918 C20.7570099,8.70289612 20.530249,8.90336355 20.2421072,9.05094147 C19.9539653,9.19851939 19.6250392,9.27230835 19.2553289,9.27230835 C18.8570643,9.27230835 18.5281382,9.17656962 18.2685506,8.98509216 C18.008963,8.79361471 17.8791692,8.52733358 17.8791692,8.18624878 L17.8791692,8.1725769 C17.8791692,7.84053548 17.99935,7.58198039 18.2397115,7.39691162 C18.4800731,7.21184285 18.8558894,7.10463969 19.3671606,7.07530212 L21.9080999,6.91241455 L21.9080999,5.86448669 L19.1672094,6.02983093 C18.2811722,6.08159892 17.5977031,6.29591624 17.116802,6.6727829 C16.6359009,7.04964956 16.3954504,7.56994629 16.3954504,8.2336731 L16.3954504,8.24734497 C16.3954504,8.69730632 16.5024221,9.08845011 16.7163656,9.42077637 C16.9303091,9.75310262 17.2227946,10.0095927 17.5938222,10.1902466 C17.9648499,10.3709005 18.3848506,10.4612274 18.8538244,10.4612274 Z" id="a"></path>
<path d="M27.2957616,10.4612274 C27.8174291,10.4612274 28.2748316,10.3469925 28.6679692,10.1185226 C29.0611068,9.8900528 29.3639175,9.57155863 29.5764012,9.16304016 L29.6907964,9.16304016 L29.6907964,10.335083 L31.1760106,10.335083 L31.1760106,0 L29.6907964,0 L29.6907964,4.08543396 L29.5764012,4.08543396 C29.3800817,3.68681335 29.0784103,3.36993917 28.6713872,3.1348114 C28.2643641,2.89968363 27.8058222,2.78211975 27.2957616,2.78211975 C26.6672826,2.78211975 26.1230067,2.93850962 25.6629338,3.25128937 C25.202861,3.56406911 24.8471074,4.00696309 24.5956731,4.57997131 C24.3442388,5.15297953 24.2185216,5.83126831 24.2185216,6.61483765 L24.2185216,6.62850952 C24.2185216,7.40666707 24.3448618,8.08317566 24.5975423,8.65803528 C24.8502227,9.2328949 25.2077387,9.67714183 25.6700902,9.99077606 C26.1324417,10.3044103 26.6743321,10.4612274 27.2957616,10.4612274 Z M27.7184148,9.18792725 C27.3069056,9.18792725 26.9526118,9.08533478 26.6555333,8.88014984 C26.3584549,8.6749649 26.1305369,8.38078817 25.9717793,7.99761963 C25.8130218,7.61445109 25.7336431,7.15808105 25.7336431,6.62850952 L25.7336431,6.61483765 C25.7336431,6.08241781 25.8130218,5.62553151 25.9717793,5.24417877 C26.1305369,4.86282603 26.3586507,4.56937917 26.6561208,4.3638382 C26.9535909,4.15829722 27.3076889,4.05552673 27.7184148,4.05552673 C28.129924,4.05552673 28.4851435,4.1590271 28.7840734,4.36602783 C29.0830032,4.57302856 29.3129862,4.8671875 29.4740224,5.24850464 C29.6350586,5.62982178 29.7155766,6.08569336 29.7155766,6.61611938 L29.7155766,6.62979126 C29.7155766,7.15558879 29.6352544,7.61008962 29.4746099,7.99329376 C29.3139653,8.3764979 29.0841959,8.67140452 28.7853017,8.87801361 C28.4864074,9.0846227 28.1307785,9.18792725 27.7184148,9.18792725 Z" id="d"></path>
<path d="M40.4045396,10.5749817 C41.1700222,10.5749817 41.8349773,10.449941 42.399405,10.1998596 C42.9638327,9.94977824 43.3999798,9.59580485 43.7078462,9.13793945 C44.0157126,8.68007406 44.1696458,8.13683065 44.1696458,7.50820923 L44.1696458,7.50137329 C44.1696458,6.76950073 43.9425645,6.1852239 43.4884019,5.74854279 C43.0342393,5.31186167 42.2892645,4.98250834 41.2534776,4.76048279 L40.1785264,4.52571106 C39.5411464,4.3898468 39.0828894,4.1998113 38.8037553,3.95560455 C38.5246212,3.71139781 38.3850541,3.40668233 38.3850541,3.04145813 L38.3850541,3.03462219 C38.3850541,2.72422791 38.4724971,2.46026103 38.6473832,2.24272156 C38.8222693,2.02518209 39.0602098,1.85782623 39.3612046,1.74065399 C39.6621995,1.62348175 40.004388,1.56489563 40.3877702,1.56489563 C40.786106,1.56119283 41.1343293,1.61999257 41.4324403,1.74129486 C41.7305512,1.86259715 41.9692572,2.02726491 42.1485581,2.23529816 C42.3278591,2.4433314 42.4390143,2.68317668 42.4820237,2.95483398 L42.4956956,3.0411377 L43.988173,3.0411377 L43.9813371,2.94917297 C43.9452348,2.43526713 43.7760631,1.97359212 43.4738221,1.56414795 C43.1715811,1.15470378 42.7595913,0.83013916 42.2378526,0.590454102 C41.7161139,0.350769043 41.1066473,0.230926514 40.4094529,0.230926514 C39.7120449,0.230926514 39.0944963,0.352335612 38.556807,0.595153809 C38.0191178,0.837972005 37.5980668,1.17569224 37.293654,1.60831451 C36.9892411,2.04093679 36.8351833,2.54239909 36.8314805,3.11270142 L36.8314805,3.11953735 C36.8314805,3.8475647 37.0590603,4.44433848 37.5142198,4.9098587 C37.9693793,5.37537893 38.6976914,5.71584066 39.6991563,5.9312439 L40.7741075,6.16046143 C41.4289333,6.30166626 41.8996339,6.49695333 42.1862092,6.74632263 C42.4727845,6.99569194 42.6160722,7.3095754 42.6160722,7.68797302 L42.6160722,7.69480896 C42.6160722,7.99744161 42.5237514,8.26528931 42.3391099,8.49835205 C42.1544684,8.73141479 41.9007732,8.91345723 41.5780244,9.04447937 C41.2552756,9.17550151 40.8847998,9.24101257 40.4665971,9.24101257 C40.0261064,9.24101257 39.63393,9.17993418 39.2900681,9.0577774 C38.9462063,8.93562063 38.6723237,8.76473999 38.4684205,8.5451355 C38.2645173,8.32553101 38.1474697,8.06669108 38.1172776,7.76861572 L38.1104417,7.69715881 L36.6004472,7.69715881 L36.6072831,7.78367615 C36.6540666,8.33525085 36.8368923,8.82060242 37.1557603,9.23973083 C37.4746283,9.65885925 37.9097428,9.98618317 38.4611039,10.2217026 C39.012465,10.457222 39.6602769,10.5749817 40.4045396,10.5749817 Z" id="S"></path>
<path d="M48.6638291,10.3797302 C48.809876,10.3797302 48.9509385,10.3722712 49.0870163,10.3573532 C49.2230942,10.3424352 49.3497727,10.3250071 49.4670517,10.305069 L49.4670517,9.12042236 C49.3627325,9.12953695 49.2713018,9.13658651 49.1927598,9.14157104 C49.1142177,9.14655558 49.0183365,9.14904785 48.9051163,9.14904785 C48.5390376,9.14904785 48.275854,9.06032308 48.1155655,8.88287354 C47.955277,8.70542399 47.8751328,8.41778056 47.8751328,8.01994324 L47.8751328,4.08319092 L49.4670517,4.08319092 L49.4670517,2.90826416 L47.8751328,2.90826416 L47.8751328,1.04119873 L46.3563797,1.04119873 L46.3563797,2.90826416 L45.1955521,2.90826416 L45.1955521,4.08319092 L46.3563797,4.08319092 L46.3563797,8.37968445 C46.3563797,9.09154765 46.5374253,9.60285441 46.8995163,9.91360474 C47.2616074,10.2243551 47.8497117,10.3797302 48.6638291,10.3797302 Z" id="t"></path>
<path d="M53.0823381,10.4612274 C53.4133826,10.4612274 53.7181159,10.4153519 53.9965379,10.3236008 C54.27496,10.2318497 54.5232255,10.0975342 54.7413347,9.9206543 C54.9594438,9.74377441 55.1405249,9.53089905 55.2845781,9.2820282 L55.3989732,9.2820282 L55.3989732,10.335083 L56.8741472,10.335083 L56.8741472,5.25630188 C56.8741472,4.73669942 56.761105,4.29095713 56.5350206,3.91907501 C56.3089362,3.54719289 55.9786394,3.26223755 55.5441301,3.06420898 C55.1096208,2.86618042 54.579444,2.76716614 53.9535997,2.76716614 C53.3911302,2.76716614 52.8929079,2.85181427 52.4589326,3.02111053 C52.0249574,3.1904068 51.6748292,3.42663829 51.4085481,3.72980499 C51.142267,4.0329717 50.979326,4.38828023 50.9197252,4.79573059 L50.9128892,4.84550476 L52.3429887,4.84550476 L52.3511064,4.82243347 C52.4409705,4.55875142 52.6167289,4.35477702 52.8783815,4.21051025 C53.1400341,4.06624349 53.4768287,3.99411011 53.8887651,3.99411011 C54.3884294,3.99411011 54.7650468,4.10223897 55.0186174,4.3184967 C55.2721879,4.53475444 55.3989732,4.84735616 55.3989732,5.25630188 L55.3989732,7.59077454 C55.3989732,7.90992737 55.3162833,8.19618225 55.1509035,8.44953918 C54.9855236,8.70289612 54.7587628,8.90336355 54.4706209,9.05094147 C54.182479,9.19851939 53.8535529,9.27230835 53.4838426,9.27230835 C53.085578,9.27230835 52.756652,9.17656962 52.4970644,8.98509216 C52.2374767,8.79361471 52.1076829,8.52733358 52.1076829,8.18624878 L52.1076829,8.1725769 C52.1076829,7.84053548 52.2278637,7.58198039 52.4682252,7.39691162 C52.7085868,7.21184285 53.0844031,7.10463969 53.5956743,7.07530212 L56.1366136,6.91241455 L56.1366136,5.86448669 L53.3957231,6.02983093 C52.5096859,6.08159892 51.8262168,6.29591624 51.3453157,6.6727829 C50.8644146,7.04964956 50.6239641,7.56994629 50.6239641,8.2336731 L50.6239641,8.24734497 C50.6239641,8.69730632 50.7309358,9.08845011 50.9448793,9.42077637 C51.1588228,9.75310262 51.4513083,10.0095927 51.822336,10.1902466 C52.1933636,10.3709005 52.6133643,10.4612274 53.0823381,10.4612274 Z" id="a"></path>
<path d="M61.6210465,10.3797302 C61.7670935,10.3797302 61.9081559,10.3722712 62.0442338,10.3573532 C62.1803117,10.3424352 62.3069901,10.3250071 62.4242692,10.305069 L62.4242692,9.12042236 C62.3199499,9.12953695 62.2285193,9.13658651 62.1499772,9.14157104 C62.0714351,9.14655558 61.975554,9.14904785 61.8623338,9.14904785 C61.4962551,9.14904785 61.2330715,9.06032308 61.072783,8.88287354 C60.9124945,8.70542399 60.8323503,8.41778056 60.8323503,8.01994324 L60.8323503,4.08319092 L62.4242692,4.08319092 L62.4242692,2.90826416 L60.8323503,2.90826416 L60.8323503,1.04119873 L59.3135972,1.04119873 L59.3135972,2.90826416 L58.1527696,2.90826416 L58.1527696,4.08319092 L59.3135972,4.08319092 L59.3135972,8.37968445 C59.3135972,9.09154765 59.4946427,9.60285441 59.8567338,9.91360474 C60.2188249,10.2243551 60.8069291,10.3797302 61.6210465,10.3797302 Z" id="t"></path>
<path d="M67.040488,10.4762878 C67.5160841,10.4762878 67.9382211,10.4152273 68.3068988,10.2931061 C68.6755766,10.1709849 68.9904392,10.0090942 69.2514865,9.80743408 C69.5125339,9.60577393 69.7228992,9.38342794 69.8825824,9.14039612 C70.0422657,8.8973643 70.1527622,8.65344238 70.214072,8.40863037 L70.2290256,8.34764099 L68.793906,8.34892273 L68.7691257,8.40286255 C68.7119459,8.52946981 68.6098697,8.65903219 68.4628971,8.79154968 C68.3159244,8.92406718 68.1269214,9.03484853 67.8958881,9.12389374 C67.6648548,9.21293894 67.3905094,9.25746155 67.0728519,9.25746155 C66.6579959,9.25746155 66.2988244,9.16544342 65.9953372,8.98140717 C65.6918501,8.79737091 65.4581465,8.53260295 65.2942264,8.18710327 C65.1303063,7.8416036 65.0483463,7.42518107 65.0483463,6.93783569 L65.0483463,6.34460449 C65.0483463,5.83497111 65.1321755,5.40459188 65.299834,5.0534668 C65.4674925,4.70234172 65.6957131,4.43663025 65.9844959,4.2563324 C66.2732786,4.07603455 66.6020979,3.98588562 66.9709537,3.98588562 C67.3407352,3.98588562 67.6670088,4.07231394 67.9497745,4.24517059 C68.2325402,4.41802724 68.4540495,4.67814891 68.6143024,5.02553558 C68.7745553,5.37292226 68.8546817,5.8126119 68.8546817,6.34460449 L68.8546817,6.93537903 L69.5703189,5.95185852 L64.3076084,5.95185852 L64.3076084,7.01239014 L70.3078525,7.01239014 L70.3078525,6.4911499 C70.3078525,5.74738566 70.1734658,5.09635162 69.9046924,4.53804779 C69.635919,3.97974396 69.2515221,3.54502106 68.7515018,3.23387909 C68.2514815,2.92273712 67.6552595,2.76716614 66.962836,2.76716614 C66.2731896,2.76716614 65.672268,2.92873637 65.1600711,3.25187683 C64.6478743,3.57501729 64.2518171,4.02620697 63.9718997,4.60544586 C63.6919823,5.18468475 63.5520236,5.86192322 63.5520236,6.63716125 L63.5520236,6.64399719 C63.5520236,7.42671204 63.692196,8.104894 63.9725406,8.67854309 C64.2528853,9.25219218 64.6531971,9.69522858 65.173476,10.0076523 C65.6937549,10.320076 66.3160923,10.4762878 67.040488,10.4762878 Z" id="e"></path>
<path d="M74.9991598,10.335083 L76.6131887,10.335083 L79.3323965,2.20277405 L79.8010855,2.20277405 L79.8010855,0.470825195 L78.5594015,0.470825195 L74.9991598,10.335083 Z M76.7155142,7.66981506 L82.0660238,7.66981506 L81.6381369,6.44084167 L77.143508,6.44084167 L76.7155142,7.66981506 Z M82.1659994,10.335083 L83.7801352,10.335083 L80.2198935,0.470825195 L79.4467916,0.470825195 L79.4467916,2.20277405 L82.1659994,10.335083 Z" id="A"></path>
</g>
</g>
<path id="Line" d="M120.387535,86.0014056 C122.87204,85.939293 124.936482,87.9030301 124.998594,90.3875351 C125.056477,92.7028458 123.355035,94.6533573 121.112328,94.9585466 L121.256092,100.737426 C121.382647,105.799632 125.452309,109.85547 130.482735,109.996222 L130.753125,110 L261.246875,110 C266.848691,110 271.44568,114.392441 271.73273,119.953809 L271.743596,120.237582 L271.88839,126.016393 C274.143726,126.208957 275.940708,128.072093 275.998594,130.387535 C276.060707,132.87204 274.09697,134.936482 271.612465,134.998594 C269.12796,135.060707 267.063518,133.09697 267.001406,130.612465 C266.943523,128.297154 268.644965,126.346643 270.887672,126.041453 L270.743908,120.262574 C270.617353,115.200368 266.547691,111.14453 261.517265,111.003778 L261.246875,111 L130.753125,111 C125.151309,111 120.55432,106.607559 120.26727,101.046191 L120.256404,100.762418 L120.11161,94.983607 C117.856274,94.7910431 116.059292,92.927907 116.001406,90.6124649 C115.939293,88.1279598 117.90303,86.0635182 120.387535,86.0014056 Z" fill="#000000" fill-rule="nonzero"></path>
<g id="Isolation" transform="translate(169.178682, 104.396606)" fill-rule="nonzero" stroke="#FFFFFF" stroke-width="2">
<path d="M2.53627014,-0.260864258 L2.53627014,11.6033936 L-1,11.6033936 L-1,-0.260864258 L2.53627014,-0.260864258 Z" id="I"></path>
<path d="M6.40716934,2.03547668 C7.12269265,2.03547668 7.74358995,2.15399296 8.27367845,2.37381416 C8.86671198,2.61973789 9.32936965,2.96755189 9.67396422,3.40155614 C10.2469617,4.12322546 10.4554479,5.01557486 10.2831081,6.08539814 L10.2831081,6.08539814 L9.224,6.091 L9.33071065,6.16227608 C9.38444825,6.20035786 9.43587839,6.23925816 9.48503368,6.27892302 L9.6257077,6.4001573 C10.1703636,6.90212912 10.4679604,7.56834248 10.4679604,8.42272949 C10.4679604,9.13044799 10.2598996,9.7333722 9.85780361,10.2550665 C9.48909706,10.7334401 8.99154229,11.1130724 8.35305264,11.3787662 C7.777436,11.6182967 7.12302421,11.7445984 6.38698196,11.7445984 C5.64878804,11.7445984 5.00835673,11.6284377 4.46220575,11.4124684 C3.84850739,11.1697883 3.36821925,10.8236069 3.00861428,10.3907691 C2.40760274,9.66736288 2.186161,8.76255147 2.36052419,7.66935182 L2.36052419,7.66935182 L3.791,7.658 L3.78130264,7.6528259 C3.66565819,7.57678493 3.55940696,7.49677788 3.46225451,7.41327369 L3.32331309,7.28545316 C2.80491462,6.7743677 2.52186966,6.10813545 2.52186966,5.26516724 C2.52186966,4.59734298 2.71467235,4.01775387 3.08883707,3.51214917 C3.43440152,3.04519171 3.90618203,2.67079315 4.51680554,2.4042349 C5.06936126,2.16302525 5.69843526,2.03547668 6.40716934,2.03547668 Z" id="s"></path>
<path d="M14.2291107,2.03547668 C15.1546352,2.03547668 15.946079,2.24477562 16.6113075,2.63707941 C17.3005411,3.04353967 17.8363723,3.62243346 18.2114795,4.38067494 C18.5572967,5.07970943 18.7419281,5.91140344 18.7419281,6.88186646 C18.7419281,7.86587075 18.5579508,8.69551453 18.2143145,9.39375932 C17.8408322,10.1526491 17.3057932,10.7326915 16.6163762,11.1406392 C15.951033,11.5343417 15.1579624,11.7445984 14.2291107,11.7445984 C13.3063871,11.7445984 12.5149822,11.5350947 11.8473422,11.1414256 C11.1554196,10.7334384 10.6189834,10.1532238 10.2449186,9.3942953 C9.90028784,8.69508457 9.71640015,7.8641679 9.71640015,6.89553833 C9.71640015,5.91022509 9.90168562,5.07989546 10.2476788,4.38146651 C10.6232154,3.62340078 11.1602628,3.04418058 11.851861,2.63722848 C12.5195665,2.24433542 13.3095241,2.03547668 14.2291107,2.03547668 Z M14.2291107,5.27619934 C14.0336836,5.27619934 13.8610535,5.30908005 13.7218483,5.40596939 C13.57573,5.50767041 13.4750649,5.66180437 13.3987428,5.85075457 C13.2833348,6.1364694 13.2364349,6.48342504 13.2364349,6.89682007 C13.2364349,7.29760509 13.2838413,7.64279485 13.3985986,7.92798898 C13.4747811,8.11731734 13.575455,8.27179274 13.7216957,8.37387798 C13.8607774,8.47096586 14.0335094,8.50376892 14.2291107,8.50376892 C14.4246616,8.50376892 14.5972739,8.47125856 14.7359154,8.37414939 C14.8823548,8.27157833 14.983267,8.1166423 15.0596468,7.92678043 C15.1747492,7.64066339 15.2217865,7.29457344 15.2217865,6.88314819 C15.2217865,6.48108609 15.174491,6.13542235 15.0595025,5.85068142 C14.9831546,5.66162442 14.8825705,5.50737663 14.7365578,5.40561448 C14.5975757,5.30875222 14.4248031,5.27619934 14.2291107,5.27619934 Z" id="o"></path>
<path d="M21.9093871,-0.731689453 L21.9093871,11.6033936 L18.4241729,11.6033936 L18.4241729,-0.731689453 L21.9093871,-0.731689453 Z" id="l"></path>
<path d="M25.8666501,2.03547668 C26.6577581,2.03547668 27.3240906,2.1729049 27.8718933,2.42256717 C28.5025447,2.70998795 28.9753038,3.1296183 29.3025538,3.66790584 C29.6164664,4.18425501 29.7871976,4.80033787 29.7871976,5.52461243 L29.7871976,5.52461243 L29.7871976,11.6033936 L26.3120236,11.6033936 L26.312,11.508 L26.2225715,11.54167 C25.923578,11.6402002 25.6022075,11.7013176 25.2579146,11.7218233 L24.9953885,11.729538 C24.3623678,11.729538 23.7975542,11.6010646 23.297619,11.3576454 C22.7549563,11.0934222 22.3296811,10.7159304 22.0171026,10.2303907 C21.704467,9.74476241 21.5370145,9.17552123 21.5370145,8.51565552 C21.5370145,7.49181187 21.9202446,6.7192499 22.641541,6.15399318 L22.641541,6.15399318 L22.692,6.116 L21.8045145,6.13032925 C21.7247892,4.93211982 21.9479054,4.12240571 22.4568383,3.47461135 L22.5702639,3.33819407 C22.9356633,2.92217919 23.411656,2.5906526 24.0085522,2.35779991 C24.5480492,2.14733897 25.1665021,2.03547668 25.8666501,2.03547668 Z" id="a"></path>
<path d="M33.7454007,0.309509277 L33.7454007,2.17657471 L35.3373196,2.17657471 L35.3373196,5.35150146 L33.7454007,5.35150146 L33.7454007,8.28825378 L34.1520529,7.90486209 L35.8774996,11.4544741 C32.5528165,11.8049576 31.6722134,11.4159518 31.1185259,10.9407714 C30.5773023,10.4762877 30.2266476,9.74267029 30.2266476,8.647995 L30.2266476,8.647995 L30.2266476,5.35150146 L29.06582,5.35150146 L29.06582,2.17657471 L30.2266476,2.17657471 L30.2266476,0.309509277 L33.7454007,0.309509277 Z" id="t"></path>
<path d="M38.4267728,2.17657471 L38.4267728,11.6033936 L34.9415586,11.6033936 L34.9415586,2.17657471 L38.4267728,2.17657471 Z M36.6896665,-1 C37.2234094,-1 37.6774237,-0.812470101 38.0529481,-0.440405081 C38.4310227,-0.0658133267 38.6215971,0.389529049 38.6215971,0.9269104 C38.6215971,1.45390209 38.4348971,1.90775538 38.0565739,2.28644941 C37.6800507,2.66334153 37.2245935,2.85243225 36.6896665,2.85243225 C36.1657015,2.85243225 35.7117703,2.66756053 35.3307028,2.29084514 C34.9463953,1.9109267 34.7578428,1.45529134 34.7578428,0.9269104 C34.7578428,0.388116217 34.9503091,-0.0689880049 35.3343506,-0.444777684 C35.7143952,-0.816656424 36.1668666,-1 36.6896665,-1 L36.6896665,-1 Z" id="i"></path>
<path d="M42.5756691,2.03547668 C43.5011935,2.03547668 44.2926374,2.24477562 44.9578658,2.63707941 C45.6470994,3.04353967 46.1829306,3.62243346 46.5580379,4.38067494 C46.903855,5.07970943 47.0884864,5.91140344 47.0884864,6.88186646 C47.0884864,7.86587075 46.9045091,8.69551453 46.5608728,9.39375932 C46.1873905,10.1526491 45.6523516,10.7326915 44.9629345,11.1406392 C44.2975913,11.5343417 43.5045207,11.7445984 42.5756691,11.7445984 C41.6529454,11.7445984 40.8615406,11.5350947 40.1939005,11.1414256 C39.501978,10.7334384 38.9655417,10.1532238 38.591477,9.3942953 C38.2468462,8.69508457 38.0629585,7.8641679 38.0629585,6.89553833 C38.0629585,5.91022509 38.248244,5.07989546 38.5942372,4.38146651 C38.9697737,3.62340078 39.5068211,3.04418058 40.1984194,2.63722848 C40.8661249,2.24433542 41.6560824,2.03547668 42.5756691,2.03547668 Z M42.5756691,5.27619934 C42.3802419,5.27619934 42.2076118,5.30908005 42.0684067,5.40596939 C41.9222883,5.50767041 41.8216233,5.66180437 41.7453011,5.85075457 C41.6298931,6.1364694 41.5829933,6.48342504 41.5829933,6.89682007 C41.5829933,7.29760509 41.6303996,7.64279485 41.7451569,7.92798898 C41.8213395,8.11731734 41.9220133,8.27179274 42.068254,8.37387798 C42.2073358,8.47096586 42.3800677,8.50376892 42.5756691,8.50376892 C42.7712199,8.50376892 42.9438322,8.47125856 43.0824737,8.37414939 C43.2289131,8.27157833 43.3298253,8.1166423 43.4062051,7.92678043 C43.5213076,7.64066339 43.5683448,7.29457344 43.5683448,6.88314819 C43.5683448,6.48108609 43.5210493,6.13542235 43.4060608,5.85068142 C43.3297129,5.66162442 43.2291288,5.50737663 43.0831161,5.40561448 C42.944134,5.30875222 42.7713615,5.27619934 42.5756691,5.27619934 Z" id="o"></path>
<path d="M51.4534857,2.03547668 C52.6212889,2.03547668 53.4882494,2.41214271 54.1002726,3.0741289 C54.6893987,3.71134891 55.0293524,4.60493083 55.0293524,5.79676819 L55.0293524,5.79676819 L55.0293524,11.6033936 L51.5441382,11.6033936 L51.5441382,6.14529419 C51.5441382,5.83593687 51.5320206,5.57471104 51.3946107,5.41382109 C50.2165046,5.82362401 50.1875861,6.02097441 50.1875861,6.24580383 L50.1875861,11.6033936 L46.7023718,11.6033936 L46.7023718,2.17657471 L50.1875861,2.17657471 L50.187,2.234 L50.3134125,2.19223945 C50.5846034,2.11051521 50.8815633,2.05922158 51.2054776,2.0419731 Z" id="n"></path>
</g>
<g id="Isolation" transform="translate(169.178682, 104.396606)" fill="#000000" fill-rule="nonzero">
<polygon id="I" points="0 10.6033936 1.53627014 10.6033936 1.53627014 0.739135742 0 0.739135742"></polygon>
<path d="M6.38698196,10.7445984 C6.97843297,10.7445984 7.50572586,10.6482366 7.96886063,10.455513 C8.43199539,10.2627894 8.79762904,9.99248505 9.06576157,9.64459991 C9.33389409,9.29671478 9.46796036,8.89355469 9.46796036,8.43511963 L9.46796036,8.42272949 C9.46796036,7.88404338 9.29464086,7.45496368 8.94800186,7.13549042 C8.60136286,6.81601715 8.07040278,6.57325236 7.35512161,6.40719604 L6.17773819,6.13621521 C5.76152929,6.03894552 5.46233241,5.91516876 5.28014755,5.76488495 C5.0979627,5.61460114 5.00687027,5.4233195 5.00687027,5.19104004 L5.00687027,5.1786499 C5.00687027,4.97827148 5.06730779,4.80356344 5.18818283,4.65452576 C5.30905787,4.50548808 5.47424189,4.38906352 5.68373489,4.30525208 C5.8932279,4.22144063 6.13252131,4.17953491 6.40161514,4.17953491 C6.82152685,4.17953491 7.15962092,4.26608785 7.41589737,4.43919373 C7.67217382,4.6122996 7.83442052,4.82880656 7.90263748,5.0887146 L7.90520096,5.10003662 L9.32611465,5.10003662 L9.32611465,5.09127808 C9.28139623,4.68852743 9.13629278,4.33256022 8.89080429,4.02337646 C8.64531581,3.71419271 8.31192144,3.47224681 7.89062119,3.29753876 C7.46932093,3.12283071 6.97483699,3.03547668 6.40716934,3.03547668 C5.84925715,3.03547668 5.35249456,3.13055674 4.91688156,3.32071686 C4.48126856,3.51087697 4.13986333,3.77297465 3.89266586,4.10700989 C3.64546839,4.44104513 3.52186966,4.82481893 3.52186966,5.2583313 L3.52186966,5.26516724 C3.52186966,5.80634562 3.68970617,6.24240367 4.02537918,6.57334137 C4.3610522,6.90427907 4.87841161,7.15010579 5.57745743,7.31082153 L6.76039505,7.58180237 C7.18942134,7.68199158 7.49750137,7.81187439 7.68463516,7.97145081 C7.87176895,8.13102722 7.96533585,8.32738241 7.96533585,8.56051636 L7.96533585,8.57290649 C7.96533585,8.77527873 7.89930852,8.95315552 7.76725388,9.10653687 C7.63519923,9.25991821 7.45399348,9.38036601 7.22363663,9.46788025 C6.99327977,9.55539449 6.72553889,9.59915161 6.42041397,9.59915161 C5.97942479,9.59915161 5.62438329,9.51242065 5.35528946,9.33895874 C5.08619563,9.16549683 4.90486526,8.93944804 4.81129837,8.66081238 L4.80755997,8.65077209 L3.3174324,8.65077209 L3.31871414,8.66209412 C3.36514155,9.07602437 3.51816686,9.43923696 3.77779007,9.75173187 C4.03741328,10.0642268 4.38812892,10.3078283 4.82993698,10.4825363 C5.27174505,10.6572444 5.79076004,10.7445984 6.38698196,10.7445984 Z" id="s"></path>
<path d="M14.2291107,10.7445984 C14.9577077,10.7445984 15.5837123,10.5897395 16.1071243,10.2800217 C16.6305364,9.97030385 17.0338567,9.5276947 17.3170853,8.95219421 C17.6003138,8.37669373 17.7419281,7.69114176 17.7419281,6.89553833 L17.7419281,6.88186646 C17.7419281,6.0851237 17.599673,5.3991979 17.3151627,4.82408905 C17.0306524,4.2489802 16.626709,3.80710093 16.1033325,3.49845123 C15.5799561,3.18980153 14.9552155,3.03547668 14.2291107,3.03547668 C13.5076345,3.03547668 12.8842646,3.19001516 12.3590012,3.4990921 C11.8337377,3.80816905 11.428655,4.25026194 11.1437531,4.82537079 C10.8588511,5.40047963 10.7164001,6.08597819 10.7164001,6.88186646 L10.7164001,6.89553833 C10.7164001,7.69114176 10.858228,8.37669373 11.1418839,8.95219421 C11.4255397,9.5276947 11.8299993,9.97030385 12.3552628,10.2800217 C12.8805262,10.5897395 13.5051422,10.7445984 14.2291107,10.7445984 Z M14.2291107,9.50376892 C13.8052114,9.50376892 13.4452744,9.40046438 13.1492996,9.19385529 C12.8533249,8.9872462 12.6271871,8.6897227 12.4708862,8.30128479 C12.3145854,7.91284688 12.2364349,7.44469198 12.2364349,6.89682007 L12.2364349,6.88314819 C12.2364349,6.33321126 12.314799,5.86423747 12.4715271,5.47622681 C12.6282552,5.08821615 12.8546066,4.7912089 13.1505814,4.58520508 C13.4465561,4.37920125 13.8060659,4.27619934 14.2291107,4.27619934 C14.6530101,4.27619934 15.0127513,4.37920125 15.3083344,4.58520508 C15.6039174,4.7912089 15.8300552,5.08821615 15.9867477,5.47622681 C16.1434402,5.86423747 16.2217865,6.33321126 16.2217865,6.88314819 L16.2217865,6.89682007 C16.2217865,7.44383748 16.1436539,7.91156514 15.9873886,8.30000305 C15.8311234,8.68844096 15.6051992,8.98617808 15.3096161,9.19321442 C15.014033,9.40025075 14.6538645,9.50376892 14.2291107,9.50376892 Z" id="o"></path>
<polygon id="l" points="19.4241729 10.6033936 20.9093871 10.6033936 20.9093871 0.268310547 19.4241729 0.268310547"></polygon>
<path d="M24.9953885,10.729538 C25.326433,10.729538 25.6311663,10.6836624 25.9095883,10.5919113 C26.1880104,10.5001602 26.436276,10.3658447 26.6543851,10.1889648 C26.8724942,10.012085 27.0535754,9.79920959 27.1976285,9.55033875 L27.3120236,9.55033875 L27.3120236,10.6033936 L28.7871976,10.6033936 L28.7871976,5.52461243 C28.7871976,5.00500997 28.6741554,4.55926768 28.448071,4.18738556 C28.2219866,3.81550344 27.8916898,3.5305481 27.4571805,3.33251953 C27.0226712,3.13449097 26.4924944,3.03547668 25.8666501,3.03547668 C25.3041806,3.03547668 24.8059583,3.12012482 24.3719831,3.28942108 C23.9380078,3.45871735 23.5878797,3.69494883 23.3215985,3.99811554 C23.0553174,4.30128225 22.8923764,4.65659078 22.8327756,5.06404114 L22.8259397,5.11381531 L24.2560391,5.11381531 L24.2641568,5.09074402 C24.3540209,4.82706197 24.5297793,4.62308757 24.7914319,4.4788208 C25.0530845,4.33455404 25.3898791,4.26242065 25.8018155,4.26242065 C26.3014798,4.26242065 26.6780972,4.37054952 26.9316678,4.58680725 C27.1852384,4.80306498 27.3120236,5.11566671 27.3120236,5.52461243 L27.3120236,7.85908508 C27.3120236,8.17823792 27.2293337,8.4644928 27.0639539,8.71784973 C26.898574,8.97120667 26.6718132,9.17167409 26.3836713,9.31925201 C26.0955294,9.46682994 25.7666033,9.5406189 25.396893,9.5406189 C24.9986285,9.5406189 24.6697024,9.44488017 24.4101148,9.25340271 C24.1505272,9.06192525 24.0207334,8.79564412 24.0207334,8.45455933 L24.0207334,8.44088745 C24.0207334,8.10884603 24.1409141,7.85029093 24.3812757,7.66522217 C24.6216372,7.4801534 24.9974535,7.37295024 25.5087247,7.34361267 L28.049664,7.1807251 L28.049664,6.13279724 L25.3087735,6.29814148 C24.4227363,6.34990946 23.7392672,6.56422679 23.2583661,6.94109344 C22.777465,7.3179601 22.5370145,7.83825684 22.5370145,8.50198364 L22.5370145,8.51565552 C22.5370145,8.96561686 22.6439862,9.35676066 22.8579297,9.68908691 C23.0718732,10.0214132 23.3643587,10.2779032 23.7353864,10.4585571 C24.106414,10.639211 24.5264147,10.729538 24.9953885,10.729538 Z" id="a"></path>
<path d="M33.534097,10.6480408 C33.6801439,10.6480408 33.8212063,10.6405818 33.9572842,10.6256638 C34.0933621,10.6107457 34.2200406,10.5933177 34.3373196,10.5733795 L34.3373196,9.38873291 C34.2330004,9.39784749 34.1415697,9.40489705 34.0630276,9.40988159 C33.9844855,9.41486613 33.8886044,9.4173584 33.7753842,9.4173584 C33.4093055,9.4173584 33.1461219,9.32863363 32.9858334,9.15118408 C32.8255449,8.97373454 32.7454007,8.68609111 32.7454007,8.28825378 L32.7454007,4.35150146 L34.3373196,4.35150146 L34.3373196,3.17657471 L32.7454007,3.17657471 L32.7454007,1.30950928 L31.2266476,1.30950928 L31.2266476,3.17657471 L30.06582,3.17657471 L30.06582,4.35150146 L31.2266476,4.35150146 L31.2266476,8.647995 C31.2266476,9.35985819 31.4076931,9.87116496 31.7697842,10.1819153 C32.1318753,10.4926656 32.7199795,10.6480408 33.534097,10.6480408 Z" id="t"></path>
<path d="M35.9415586,10.6033936 L37.4267728,10.6033936 L37.4267728,3.17657471 L35.9415586,3.17657471 L35.9415586,10.6033936 Z M36.6896665,1.85243225 C36.9476519,1.85243225 37.1674701,1.76151784 37.3491209,1.57968903 C37.5307717,1.39786021 37.6215971,1.18026733 37.6215971,0.9269104 C37.6215971,0.668924967 37.5307717,0.449943542 37.3491209,0.269966125 C37.1674701,0.0899887085 36.9476519,0 36.6896665,0 C36.4363096,0 36.2176664,0.0899887085 36.0337369,0.269966125 C35.8498075,0.449943542 35.7578428,0.668924967 35.7578428,0.9269104 C35.7578428,1.18026733 35.8498075,1.39786021 36.0337369,1.57968903 C36.2176664,1.76151784 36.4363096,1.85243225 36.6896665,1.85243225 Z" id="i"></path>
<path d="M42.5756691,10.7445984 C43.3042661,10.7445984 43.9302706,10.5897395 44.4536827,10.2800217 C44.9770947,9.97030385 45.380415,9.5276947 45.6636436,8.95219421 C45.9468722,8.37669373 46.0884864,7.69114176 46.0884864,6.89553833 L46.0884864,6.88186646 C46.0884864,6.0851237 45.9462313,5.3991979 45.661721,4.82408905 C45.3772107,4.2489802 44.9732673,3.80710093 44.4498909,3.49845123 C43.9265144,3.18980153 43.3017738,3.03547668 42.5756691,3.03547668 C41.8541928,3.03547668 41.230823,3.19001516 40.7055595,3.4990921 C40.180296,3.80816905 39.7752133,4.25026194 39.4903114,4.82537079 C39.2054094,5.40047963 39.0629585,6.08597819 39.0629585,6.88186646 L39.0629585,6.89553833 C39.0629585,7.69114176 39.2047864,8.37669373 39.4884422,8.95219421 C39.772098,9.5276947 40.1765576,9.97030385 40.7018211,10.2800217 C41.2270846,10.5897395 41.8517005,10.7445984 42.5756691,10.7445984 Z M42.5756691,9.50376892 C42.1517697,9.50376892 41.7918327,9.40046438 41.495858,9.19385529 C41.1998832,8.9872462 40.9737454,8.6897227 40.8174446,8.30128479 C40.6611437,7.91284688 40.5829933,7.44469198 40.5829933,6.89682007 L40.5829933,6.88314819 C40.5829933,6.33321126 40.6613573,5.86423747 40.8180854,5.47622681 C40.9748135,5.08821615 41.201165,4.7912089 41.4971397,4.58520508 C41.7931144,4.37920125 42.1526242,4.27619934 42.5756691,4.27619934 C42.9995684,4.27619934 43.3593096,4.37920125 43.6548927,4.58520508 C43.9504758,4.7912089 44.1766136,5.08821615 44.3333061,5.47622681 C44.4899986,5.86423747 44.5683448,6.33321126 44.5683448,6.88314819 L44.5683448,6.89682007 C44.5683448,7.44383748 44.4902122,7.91156514 44.3339469,8.30000305 C44.1776817,8.68844096 43.9517575,8.98617808 43.6561744,9.19321442 C43.3605913,9.40025075 43.0004229,9.50376892 42.5756691,9.50376892 Z" id="o"></path>
<path d="M47.7023718,10.6033936 L49.1875861,10.6033936 L49.1875861,6.24580383 C49.1875861,5.84632874 49.25931,5.50250244 49.4027579,5.21432495 C49.5462058,4.92614746 49.7493613,4.70317841 50.0122244,4.54541779 C50.2750876,4.38765717 50.5870306,4.30877686 50.9480536,4.30877686 C51.4932908,4.30877686 51.8956142,4.46064504 52.1550238,4.76438141 C52.4144334,5.06811778 52.5441382,5.52842204 52.5441382,6.14529419 L52.5441382,10.6033936 L54.0293524,10.6033936 L54.0293524,5.79676819 C54.0293524,4.9125824 53.8082348,4.2313207 53.3659995,3.75298309 C52.9237641,3.27464549 52.2862596,3.03547668 51.4534857,3.03547668 C50.9128058,3.03547668 50.4645,3.14746857 50.1085684,3.37145233 C49.7526368,3.5954361 49.4837744,3.90631104 49.3019812,4.30407715 L49.1875861,4.30407715 L49.1875861,3.17657471 L47.7023718,3.17657471 L47.7023718,10.6033936 Z" id="n"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 126 KiB

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