Compare commits

...
639 Commits
Author SHA1 Message Date
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é 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é 5d87609f4b Ignore .swiftpm 2021-11-25 15:08:53 +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é 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é 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é 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é 2273efa07f Improve documentation of persistence methods 2021-11-02 08:13:34 +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é a7c1a99866 Fix wording 2021-10-31 18:48:26 +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é 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é de7d5f42d4 Clarify the benefits of shared observations 2021-10-25 08:47:50 +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é 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é 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
352 changed files with 34798 additions and 12644 deletions

No files matched your search

+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.
+271
View File
@@ -7,6 +7,18 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
#### 5.x Releases
- `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 +80,265 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
- [0.110.0](#01100), ...
---
## 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
+2 -2
View File
@@ -118,7 +118,7 @@ Starting points:
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)
- [Concurrency Guide](Documentation/Concurrency.md)
- [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)
@@ -313,7 +313,7 @@ Features that blur this focus are non-goals:
[Non-Goals]: #non-goals
[Report Bugs]: #report-bugs
[RxGRDB]: http://github.com/RxSwiftCommunity/RxGRDB
[Concurrency]: #concurrency
[Concurrency]: Documentation/Concurrency.md
[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
+124 -5
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]
@@ -855,14 +857,18 @@ Before we describe them in detail, let's see a few requests they can build:
let request = Author
.including(all: Author.books)
/// All authors with their awarded books
let request = Author
.including(all: Author.books.having(Book.awards.isEmpty == false))
/// 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)
.order(Column("title"))
/// All books written by a French author
let request = Book
@@ -941,7 +947,21 @@ The pattern is always the same: you start from a base request, that you extend w
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.
Finally, readers who speak SQL may compare `optional` with left joins, and `required` with inner joins.
Finally, readers who speak SQL may compare `optional` with left joins, and `required` with inner joins:
```swift
// SELECT book.* FROM book LEFT JOIN author ON author.id = book.authorID
Book.joining(optional: Book.author)
// SELECT book.* FROM book JOIN author ON author.id = book.authorID
Book.joining(required: Book.author)
// SELECT book.*, author.* FROM book LEFT JOIN author ON author.id = book.authorID
Book.including(optional: Book.author)
// SELECT book.*, author.* FROM book JOIN author ON author.id = book.authorID
Book.including(required: Book.author)
```
## Combining Associations
@@ -1044,7 +1064,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,7 +1241,6 @@ let teamInfos = try Team
.fetchAll(db)
```
## Columns Selected by an Association
By default, associated records include all their columns:
@@ -1248,6 +1267,104 @@ 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).
## 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
In all examples we have seen so far, all associated records are joined, included, filtered, and sorted independently. We could not filter them on conditions that involve several records, for example.
@@ -2433,6 +2550,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
@@ -2483,4 +2601,5 @@ 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
+105 -27
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:)`]
@@ -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 ony 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
+517
View File
@@ -0,0 +1,517 @@
: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 three ways to access the database asynchronously:
<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...
dbQueue.writePublisher { 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 ... }
```
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.
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` has no async version.
- **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#databasepool-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
@@ -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).
**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)";
};
@@ -78,8 +78,10 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -87,7 +89,7 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</RemoteRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -95,8 +97,10 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
@@ -104,7 +108,16 @@
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
@@ -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).
**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.
+7 -2
View File
@@ -1,6 +1,11 @@
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.
[GRDBCombineDemo] uses the `@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
[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.15/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.15/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)
```
+7 -7
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]
@@ -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 {
@@ -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

+217 -142
View File
@@ -1,173 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="489px" height="362px" viewBox="0 0 489 362" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.2 (57519) - http://www.bohemiancoding.com/sketch -->
<svg width="496px" height="314px" viewBox="0 0 496 314" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>DatabasePoolScheduling</title>
<desc>Created with Sketch.</desc>
<defs>
<linearGradient x1="50%" y1="100%" x2="50%" y2="1.41638472e-14%" id="linearGradient-1">
<stop stop-color="#FFFFFF" stop-opacity="0.9" offset="0%"></stop>
<filter x="-19.5%" y="-26.9%" width="139.1%" height="153.8%" 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>
<rect id="path-2" x="0" y="0" width="120" height="88" rx="10"></rect>
<filter x="-12.1%" y="-13.1%" width="124.2%" height="133.0%" filterUnits="objectBoundingBox" id="filter-4">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<filter x="-19.5%" y="-12.4%" width="139.1%" height="124.7%" filterUnits="objectBoundingBox" id="filter-3">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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="120" height="250" rx="10"></rect>
<filter x="-12.1%" y="-4.6%" width="124.2%" height="111.6%" filterUnits="objectBoundingBox" id="filter-7">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<linearGradient x1="50%" y1="99.532889%" x2="50%" y2="1.11022302e-14%" id="linearGradient-4">
<stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
<stop stop-color="#FFFFFF" offset="100%"></stop>
</linearGradient>
<filter x="-19.5%" y="-35.8%" width="139.1%" height="171.7%" filterUnits="objectBoundingBox" id="filter-5">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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-8" x="0" y="0" width="120" height="94" rx="10"></rect>
<filter x="-12.1%" y="-12.2%" width="124.2%" height="130.9%" filterUnits="objectBoundingBox" id="filter-10">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<linearGradient x1="50%" y1="99.532889%" x2="50%" y2="1.11022302e-14%" id="linearGradient-6">
<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-7">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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-11" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-13">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<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>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-9">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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-14" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-16">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-10">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
</filter>
<rect id="path-17" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-19">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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>
</defs>
<g id="Page-3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="DatabasePoolScheduling">
<g id="Group-2" transform="translate(44.000000, 0.000000)" stroke="#D7D7D7">
<rect id="Rectangle-2" x="0.5" y="0.5" width="444" height="361" rx="6"></rect>
<rect id="Rectangle-2-Copy" fill-opacity="0.02" fill="#000000" x="148.5" y="0.5" width="148" height="361"></rect>
</g>
<text id="Thread-1" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="89.9428711" y="26">Thread 1</tspan>
</text>
<text id="Thread-2" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="236.979004" y="26">Thread 2</tspan>
</text>
<text id="Thread-3" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="384.818359" y="26">Thread 3</tspan>
</text>
<g id="BlueBox" transform="translate(58.000000, 44.000000)">
<g id="Group">
<mask id="mask-3" fill="white">
<use xlink:href="#path-2"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-2"></use>
<use fill="#005CC5" fill-rule="evenodd" xlink:href="#path-2"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="89" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-3)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.7509766" y="49">Read State A</tspan>
</text>
<g id="DatabasePoolScheduling" 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="313"></rect>
<rect id="Rectangle" fill-opacity="0.02" fill="#000000" x="150" y="1" width="150" height="313"></rect>
<line x1="0.5" y1="0.357630979" x2="0.5" y2="313.642369" id="Line" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="150.5" y1="0.357630979" x2="150.5" y2="313.642369" id="Line-Copy" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="299.5" y1="0.357630979" x2="299.5" y2="313.642369" id="Line-Copy-2" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="449.5" y1="0.357630979" x2="449.5" y2="313.642369" 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="313.5" x2="449.415584" y2="313.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="BlueBox" transform="translate(355.000000, 94.000000)">
<g id="Group">
<mask id="mask-6" fill="white">
<use xlink:href="#path-5"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-7)" xlink:href="#path-5"></use>
<use fill="#005CC5" fill-rule="evenodd" xlink:href="#path-5"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="251" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-6)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.7509766" y="130">Read State A</tspan>
</text>
<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.998218,32.9232757 L22.9999968,33.4232725 L23.969,306.003 L27.9697313,305.98973 L23.5017788,315.005683 L18.9697882,306.021749 L22.969,306.007 L22.0000032,33.4268302 L21.9982243,32.9268334 L22.998218,32.9232757 Z"></path>
</g>
</g>
<g id="Read-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="80" rx="10"></rect>
</g>
</g>
<g id="GreenBox" transform="translate(207.000000, 60.000000)">
<g id="Group">
<mask id="mask-9" fill="white">
<use xlink:href="#path-8"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-10)" xlink:href="#path-8"></use>
<use fill="#366500" fill-rule="evenodd" xlink:href="#path-8"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="95" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-9)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="14.7802734" y="52">Write State B</tspan>
</text>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-2)" x="-0.5" y="-0.5" width="111" height="81" rx="10"></rect>
<g id="Text" transform="translate(13.565043, 34.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>
<g id="Read-A-Copy" transform="translate(366.000000, 120.000000)">
<g id="Background" filter="url(#filter-3)" fill="#D7E6F7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="174" rx="10"></rect>
</g>
</g>
<g id="GreenBox" transform="translate(58.000000, 172.000000)">
<g id="Group">
<mask id="mask-12" fill="white">
<use xlink:href="#path-11"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-13)" xlink:href="#path-11"></use>
<use fill="#366500" fill-rule="evenodd" xlink:href="#path-11"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-12)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.9663086" y="27">Read State B</tspan>
</text>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-4)" x="-0.5" y="-0.5" width="111" height="175" rx="10"></rect>
<g id="Text" transform="translate(13.565043, 81.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>
<g id="Write-B" transform="translate(216.000000, 90.000000)">
<g id="Background" filter="url(#filter-5)" fill="#E6F0C7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="60" rx="10"></rect>
</g>
</g>
<g id="OrangeBox" transform="translate(58.000000, 231.000000)">
<g id="Group">
<mask id="mask-15" fill="white">
<use xlink:href="#path-14"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-16)" xlink:href="#path-14"></use>
<use fill="#CD7F00" fill-rule="evenodd" xlink:href="#path-14"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-15)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="14.4179688" y="27">Write State C</tspan>
</text>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-6)" x="-0.5" y="-0.5" width="111" height="61" rx="10"></rect>
<g id="Text" transform="translate(12.183546, 24.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="Read-B" transform="translate(66.000000, 158.000000)">
<g id="Background" filter="url(#filter-7)" fill="#E6F0C7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<g id="OrangeBox" transform="translate(207.000000, 300.000000)">
<g id="Group">
<mask id="mask-18" fill="white">
<use xlink:href="#path-17"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-19)" xlink:href="#path-17"></use>
<use fill="#CD7F00" fill-rule="evenodd" xlink:href="#path-17"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-18)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.6040039" y="27">Read State C</tspan>
</text>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-8)" x="-0.5" y="-0.5" width="111" height="41" rx="10"></rect>
<g id="Text" transform="translate(13.738909, 14.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="M76.5245352,10.335083 L79.8181753,10.335083 C80.5207815,10.335083 81.1225576,10.2231089 81.6235037,9.99916077 C82.1244497,9.77521261 82.5100927,9.4553477 82.7804327,9.03956604 C83.0507727,8.62378438 83.1859426,8.12878418 83.1859426,7.55456543 L83.1859426,7.54089355 C83.1859426,7.1121521 83.0932302,6.72759501 82.9078054,6.38722229 C82.7223806,6.04684957 82.4635051,5.76978048 82.1311789,5.55601501 C81.7988526,5.34224955 81.4096314,5.21218872 80.9635153,5.16583252 L80.9635153,5.05143738 C81.2900025,4.99475606 81.5831645,4.86469523 81.8430014,4.66125488 C82.1028382,4.45781453 82.3101238,4.20591736 82.4648581,3.90556335 C82.6195923,3.60520935 82.6969595,3.28288778 82.6969595,2.93859863 L82.6969595,2.92492676 C82.6969595,2.4219869 82.5779359,1.98708598 82.3398886,1.620224 C82.1018413,1.25336202 81.7616644,0.970080058 81.3193579,0.770378113 C80.8770514,0.570676168 80.3465719,0.470825195 79.7279196,0.470825195 L76.5245352,0.470825195 L76.5245352,1.72190857 L79.3704214,1.72190857 C79.9368073,1.72190857 80.3774227,1.85058085 80.6922674,2.10792542 C81.0071122,2.36526998 81.1645346,2.72622172 81.1645346,3.19078064 L81.1645346,3.20445251 C81.1645346,3.68218486 80.9911795,4.04548645 80.6444693,4.2943573 C80.2977591,4.54322815 79.7853842,4.66766357 79.1073446,4.66766357 L76.5245352,4.66766357 L76.5245352,5.83746338 L79.4158163,5.83746338 C79.8973227,5.83746338 80.301088,5.89750926 80.6271124,6.01760101 C80.9531368,6.13769277 81.1987499,6.31699371 81.3639517,6.55550385 C81.5291535,6.79401398 81.6117544,7.08943685 81.6117544,7.44177246 L81.6117544,7.45544434 C81.6117544,7.98458862 81.4332902,8.38830058 81.0763617,8.6665802 C80.7194331,8.94485982 80.1962881,9.08399963 79.5069265,9.08399963 L76.5245352,9.08399963 L76.5245352,10.335083 Z M75.7564535,10.335083 L77.2927237,10.335083 L77.2927237,0.470825195 L75.7564535,0.470825195 L75.7564535,10.335083 Z" id="B"></path>
</g>
</g>
<g id="Write-C" transform="translate(66.000000, 206.000000)">
<g id="Background" filter="url(#filter-9)" fill="#FFEEB3">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<g id="Group-4" transform="translate(0.000000, 13.000000)" fill="#000000">
<text id="Time" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal">
<tspan x="0.501953125" y="13">Time</tspan>
</text>
<path id="Line" d="M16.5,340 L21,331 L12,331 L16.5,340 Z M16,22.5 L16,331.5 L16,332 L17,332 L17,331.5 L17,22.5 L17,22 L16,22 L16,22.5 Z" fill-rule="nonzero"></path>
<rect id="Overlay" stroke-opacity="0.25" stroke="#000000" fill="url(#linearGradient-8)" 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="Read-C" transform="translate(216.000000, 254.000000)">
<g id="Background" filter="url(#filter-10)" 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-8)" x="-0.5" y="-0.5" width="111" height="41" rx="10"></rect>
<g id="Text" transform="translate(13.356327, 14.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="M79.8083487,10.5749817 C80.5444225,10.5749817 81.2020432,10.4433721 81.7812109,10.1801529 C82.3603786,9.9169337 82.8347464,9.54916382 83.2043142,9.07684326 C83.5738821,8.60452271 83.8066956,8.05170186 83.9027548,7.41838074 L83.9039297,7.38088989 L82.3790884,7.38088989 L82.3654165,7.41090393 C82.2759797,7.77911886 82.1126471,8.09857432 81.8754187,8.36927032 C81.6381903,8.63996633 81.3437999,8.84853363 80.9922476,8.99497223 C80.6406953,9.14141083 80.2464895,9.21463013 79.8096304,9.21463013 C79.2178946,9.21463013 78.7064098,9.05977122 78.275176,8.75005341 C77.8439423,8.44033559 77.5115627,8.00077057 77.2780371,7.43135834 C77.0445115,6.86194611 76.9277487,6.18841044 76.9277487,5.41075134 L76.9277487,5.39707947 C76.9277487,4.61564636 77.0445115,3.94065094 77.2780371,3.3720932 C77.5115627,2.80353546 77.8439423,2.36459351 78.275176,2.05526733 C78.7064098,1.74594116 79.2156159,1.59127808 79.8027945,1.59127808 C80.2359508,1.59127808 80.6280025,1.67329152 80.9789495,1.83731842 C81.3298966,2.00134532 81.6260494,2.23193359 81.8674078,2.52908325 C82.1087662,2.82623291 82.2766205,3.17710876 82.3709707,3.58171082 L82.3778067,3.60670471 L83.8970938,3.60670471 L83.901473,3.5667572 C83.817448,2.91442362 83.5881592,2.33740997 83.2136068,1.83571625 C82.8390544,1.33402252 82.3582602,0.941134135 81.771224,0.657051086 C81.1841879,0.372968038 80.5280447,0.230926514 79.8027945,0.230926514 C78.8869925,0.230926514 78.0968542,0.440348307 77.4323797,0.859191895 C76.7679052,1.27803548 76.2553167,1.87317149 75.8946142,2.64459991 C75.5339117,3.41602834 75.3535604,4.33391317 75.3535604,5.39825439 L75.3535604,5.41192627 C75.3535604,6.4725647 75.5339117,7.38859812 75.8946142,8.16002655 C76.2553167,8.93145498 76.7690446,9.52680461 77.4357977,9.94607544 C78.1025508,10.3653463 78.8934011,10.5749817 79.8083487,10.5749817 Z" id="C"></path>
</g>
</g>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 135 KiB

+181 -124
View File
@@ -1,150 +1,207 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="489px" height="362px" viewBox="0 0 489 362" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.2 (57519) - http://www.bohemiancoding.com/sketch -->
<svg width="496px" height="302px" viewBox="0 0 496 302" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>DatabaseQueueScheduling</title>
<desc>Created with Sketch.</desc>
<defs>
<linearGradient x1="50%" y1="100%" x2="50%" y2="1.41638472e-14%" id="linearGradient-1">
<stop stop-color="#FFFFFF" stop-opacity="0.9" offset="0%"></stop>
<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>
<rect id="path-2" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-4">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<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>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-7">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<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>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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-8" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-10">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-5">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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-11" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-13">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<filter x="-19.5%" y="-53.8%" width="139.1%" height="207.5%" filterUnits="objectBoundingBox" id="filter-6">
<feOffset dx="0" dy="3" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
</filter>
<rect id="path-14" x="0" y="0" width="120" height="44" rx="10"></rect>
<filter x="-12.1%" y="-26.1%" width="124.2%" height="165.9%" filterUnits="objectBoundingBox" id="filter-16">
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
<feOffset dx="0" dy="3" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite>
<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"></feColorMatrix>
<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>
</defs>
<g id="Page-3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="DatabaseQueueScheduling">
<g id="Group-2" transform="translate(44.000000, 0.000000)" stroke="#D7D7D7">
<rect id="Rectangle-2" x="0.5" y="0.5" width="444" height="361" rx="6"></rect>
<rect id="Rectangle-2-Copy" fill-opacity="0.02" fill="#000000" x="148.5" y="0.5" width="148" height="361"></rect>
</g>
<text id="Thread-1" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="89.9428711" y="26">Thread 1</tspan>
</text>
<text id="Thread-2" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="236.979004" y="26">Thread 2</tspan>
</text>
<text id="Thread-3" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal" fill="#000000">
<tspan x="384.818359" y="26">Thread 3</tspan>
</text>
<g id="Group-4" transform="translate(0.000000, 13.000000)" fill="#000000">
<text id="Time" font-family="-apple-system,sans-serif" font-size="14" font-weight="normal">
<tspan x="0.501953125" y="13">Time</tspan>
</text>
<path id="Line" d="M16.5,340 L21,331 L12,331 L16.5,340 Z M16,22.5 L16,331.5 L16,332 L17,332 L17,331.5 L17,22.5 L17,22 L16,22 L16,22.5 Z" fill-rule="nonzero"></path>
</g>
<g id="BlueBox" transform="translate(58.000000, 44.000000)">
<g id="Group">
<mask id="mask-3" fill="white">
<use xlink:href="#path-2"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-2"></use>
<use fill="#005CC5" fill-rule="evenodd" xlink:href="#path-2"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-3)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.7509766" y="27">Read State A</tspan>
</text>
<g id="DatabaseQueueScheduling" 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="301"></rect>
<rect id="Rectangle" fill-opacity="0.02" fill="#000000" x="150" y="1" width="150" height="301"></rect>
<line x1="0.5" y1="0.343963554" x2="0.5" y2="301.656036" id="Line" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="150.5" y1="0.343963554" x2="150.5" y2="301.656036" id="Line-Copy" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="299.5" y1="0.343963554" x2="299.5" y2="301.656036" id="Line-Copy-2" stroke="#CCCCCC" stroke-linecap="square"></line>
<line x1="449.5" y1="0.343963554" x2="449.5" y2="301.656036" 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="301.5" x2="449.415584" y2="301.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="GreenBox" transform="translate(207.000000, 110.000000)">
<g id="Group">
<mask id="mask-6" fill="white">
<use xlink:href="#path-5"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-7)" xlink:href="#path-5"></use>
<use fill="#366500" fill-rule="evenodd" xlink:href="#path-5"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-6)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="14.7802734" y="27">Write State B</tspan>
</text>
<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.9981384,32.9050519 L22.9999965,33.4050484 L23.968,293.986 L27.9683802,293.971964 L23.5018582,302.988625 L18.9684424,294.005411 L22.968,293.99 L22.0000035,33.4087647 L21.9981453,32.9087682 L22.9981384,32.9050519 Z"></path>
</g>
</g>
<g id="Read-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>
<g id="GreenBox" transform="translate(355.000000, 159.000000)">
<g id="Group">
<mask id="mask-9" fill="white">
<use xlink:href="#path-8"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-10)" xlink:href="#path-8"></use>
<use fill="#366500" fill-rule="evenodd" xlink:href="#path-8"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-9)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.9663086" y="27">Read State B</tspan>
</text>
<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.565043, 14.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>
<g id="Write-B" transform="translate(216.000000, 98.000000)">
<g id="Background" filter="url(#filter-3)" fill="#E6F0C7">
<g id="RectangleBackground">
<rect id="RectangleBackgroundRectangle" x="0" y="0" width="110" height="40" rx="10"></rect>
</g>
</g>
<g id="OrangeBox" transform="translate(355.000000, 297.000000)">
<g id="Group">
<mask id="mask-12" fill="white">
<use xlink:href="#path-11"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-13)" xlink:href="#path-11"></use>
<use fill="#CD7F00" fill-rule="evenodd" xlink:href="#path-11"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-12)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="15.6040039" y="27">Read State C</tspan>
</text>
<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="Read-B" transform="translate(366.000000, 146.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>
<g id="OrangeBox" transform="translate(58.000000, 231.000000)">
<g id="Group">
<mask id="mask-15" fill="white">
<use xlink:href="#path-14"></use>
</mask>
<g id="Rectangle">
<use fill="black" fill-opacity="1" filter="url(#filter-16)" xlink:href="#path-14"></use>
<use fill="#CD7F00" fill-rule="evenodd" xlink:href="#path-14"></use>
<rect stroke-opacity="0.25" stroke="#000000" stroke-width="1" fill="url(#linearGradient-1)" fill-rule="evenodd" x="-0.5" y="-0.5" width="121" height="45" rx="10"></rect>
</g>
<text id="Label" mask="url(#mask-15)" font-family="-apple-system,sans-serif" font-size="14" font-weight="500" fill="#000000">
<tspan x="14.4179688" y="27">Write State C</tspan>
</text>
<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.738909, 14.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="M76.5245352,10.335083 L79.8181753,10.335083 C80.5207815,10.335083 81.1225576,10.2231089 81.6235037,9.99916077 C82.1244497,9.77521261 82.5100927,9.4553477 82.7804327,9.03956604 C83.0507727,8.62378438 83.1859426,8.12878418 83.1859426,7.55456543 L83.1859426,7.54089355 C83.1859426,7.1121521 83.0932302,6.72759501 82.9078054,6.38722229 C82.7223806,6.04684957 82.4635051,5.76978048 82.1311789,5.55601501 C81.7988526,5.34224955 81.4096314,5.21218872 80.9635153,5.16583252 L80.9635153,5.05143738 C81.2900025,4.99475606 81.5831645,4.86469523 81.8430014,4.66125488 C82.1028382,4.45781453 82.3101238,4.20591736 82.4648581,3.90556335 C82.6195923,3.60520935 82.6969595,3.28288778 82.6969595,2.93859863 L82.6969595,2.92492676 C82.6969595,2.4219869 82.5779359,1.98708598 82.3398886,1.620224 C82.1018413,1.25336202 81.7616644,0.970080058 81.3193579,0.770378113 C80.8770514,0.570676168 80.3465719,0.470825195 79.7279196,0.470825195 L76.5245352,0.470825195 L76.5245352,1.72190857 L79.3704214,1.72190857 C79.9368073,1.72190857 80.3774227,1.85058085 80.6922674,2.10792542 C81.0071122,2.36526998 81.1645346,2.72622172 81.1645346,3.19078064 L81.1645346,3.20445251 C81.1645346,3.68218486 80.9911795,4.04548645 80.6444693,4.2943573 C80.2977591,4.54322815 79.7853842,4.66766357 79.1073446,4.66766357 L76.5245352,4.66766357 L76.5245352,5.83746338 L79.4158163,5.83746338 C79.8973227,5.83746338 80.301088,5.89750926 80.6271124,6.01760101 C80.9531368,6.13769277 81.1987499,6.31699371 81.3639517,6.55550385 C81.5291535,6.79401398 81.6117544,7.08943685 81.6117544,7.44177246 L81.6117544,7.45544434 C81.6117544,7.98458862 81.4332902,8.38830058 81.0763617,8.6665802 C80.7194331,8.94485982 80.1962881,9.08399963 79.5069265,9.08399963 L76.5245352,9.08399963 L76.5245352,10.335083 Z M75.7564535,10.335083 L77.2927237,10.335083 L77.2927237,0.470825195 L75.7564535,0.470825195 L75.7564535,10.335083 Z" id="B"></path>
</g>
</g>
<g id="Write-C" transform="translate(66.000000, 194.000000)">
<g id="Background" filter="url(#filter-5)" 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="Read-C" transform="translate(366.000000, 242.000000)">
<g id="Background" filter="url(#filter-6)" 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(13.356327, 14.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="M79.8083487,10.5749817 C80.5444225,10.5749817 81.2020432,10.4433721 81.7812109,10.1801529 C82.3603786,9.9169337 82.8347464,9.54916382 83.2043142,9.07684326 C83.5738821,8.60452271 83.8066956,8.05170186 83.9027548,7.41838074 L83.9039297,7.38088989 L82.3790884,7.38088989 L82.3654165,7.41090393 C82.2759797,7.77911886 82.1126471,8.09857432 81.8754187,8.36927032 C81.6381903,8.63996633 81.3437999,8.84853363 80.9922476,8.99497223 C80.6406953,9.14141083 80.2464895,9.21463013 79.8096304,9.21463013 C79.2178946,9.21463013 78.7064098,9.05977122 78.275176,8.75005341 C77.8439423,8.44033559 77.5115627,8.00077057 77.2780371,7.43135834 C77.0445115,6.86194611 76.9277487,6.18841044 76.9277487,5.41075134 L76.9277487,5.39707947 C76.9277487,4.61564636 77.0445115,3.94065094 77.2780371,3.3720932 C77.5115627,2.80353546 77.8439423,2.36459351 78.275176,2.05526733 C78.7064098,1.74594116 79.2156159,1.59127808 79.8027945,1.59127808 C80.2359508,1.59127808 80.6280025,1.67329152 80.9789495,1.83731842 C81.3298966,2.00134532 81.6260494,2.23193359 81.8674078,2.52908325 C82.1087662,2.82623291 82.2766205,3.17710876 82.3709707,3.58171082 L82.3778067,3.60670471 L83.8970938,3.60670471 L83.901473,3.5667572 C83.817448,2.91442362 83.5881592,2.33740997 83.2136068,1.83571625 C82.8390544,1.33402252 82.3582602,0.941134135 81.771224,0.657051086 C81.1841879,0.372968038 80.5280447,0.230926514 79.8027945,0.230926514 C78.8869925,0.230926514 78.0968542,0.440348307 77.4323797,0.859191895 C76.7679052,1.27803548 76.2553167,1.87317149 75.8946142,2.64459991 C75.5339117,3.41602834 75.3535604,4.33391317 75.3535604,5.39825439 L75.3535604,5.41192627 C75.3535604,6.4725647 75.5339117,7.38859812 75.8946142,8.16002655 C76.2553167,8.93145498 76.7690446,9.52680461 77.4357977,9.94607544 C78.1025508,10.3653463 78.8934011,10.5749817 79.8083487,10.5749817 Z" id="C"></path>
</g>
</g>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 118 KiB

-3
View File
@@ -1,3 +0,0 @@
fixfonts:
sed -i '' -- 's/SFUIText-Regular, SF UI Text/-apple-system,sans-serif/g' *.svg
sed -i '' -- 's/SFUIText-Semibold, SF UI Text/-apple-system,sans-serif/g' *.svg
Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

+184 -7
View File
@@ -2,6 +2,15 @@
**Migrations** are a convenient way to alter your database schema over time in a consistent and easy way.
- [Migrations Overview]
- [The `eraseDatabaseOnSchemaChange` Option]
- [Advanced Database Schema Changes]
- [Foreign Key Checks]
- [Asynchronous Migrations]
## Migrations Overview
Migrations run in order, once and only once. When a user upgrades your application, only non-applied migrations are run.
Inside each migration, you typically [define and update your database tables](../README.md#database-schema) according to your evolving application needs:
@@ -31,7 +40,7 @@ migrator.registerMigration("v2") { db in
**Each migration runs in a separate transaction.** Should one throw an error, its transaction is rollbacked, subsequent migrations do not run, and the error is eventually thrown by `migrator.migrate(dbQueue)`.
**Migrations run with deferred foreign key checks.** This means that eventual foreign key violations are only checked at the end of the migration (and they make the migration fail).
**Migrations run with deferred foreign key checks.** This means that eventual foreign key violations are only checked at the end of the migration (and they make the migration fail). See [Foreign Key Checks] below for more information.
**The memory of applied migrations is stored in the database itself** (in a reserved table).
@@ -68,7 +77,7 @@ try dbQueue.read { db in
}
```
See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.3/Structs/DatabaseMigrator.html) for more migrator methods.
See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.15/Structs/DatabaseMigrator.html) for more migrator methods.
## The `eraseDatabaseOnSchemaChange` Option
@@ -102,13 +111,10 @@ The `eraseDatabaseOnSchemaChange` option triggers a recreation of the database i
## Advanced Database Schema Changes
SQLite does not support many schema changes, and won't let you drop a table column with "ALTER TABLE ... DROP COLUMN ...", for example.
Yet any kind of schema change is still possible, by recreating tables:
If SQLite does not directly support all kinds of schema alterations, you can make arbitrary changes to the schema design of any table using a sequence of operations, as in the example below:
```swift
migrator.registerMigration("AddNotNullCheckOnName") { db in
// Add a NOT NULL constraint on player.name:
migrator.registerMigration("Add NOT NULL check on player.name") { db in
try db.create(table: "new_player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
@@ -119,4 +125,175 @@ migrator.registerMigration("AddNotNullCheckOnName") { db in
}
```
This technique is described in SQLite documentation: [Making Other Kinds Of Table Schema Changes](https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes).
The detailed sequence of operations is described below, some of them are performed by GRDB, and others by your code:
1. GRDB: If foreign key constraints are enabled, disable them using PRAGMA foreign_keys=OFF.
2. GRDB: Start a transaction.
3. **Your code**: Remember the format of all indexes, triggers, and views associated with table X. This information will be needed in step 8 below. One way to do this is to run a query like the following: `SELECT type, sql FROM sqlite_schema WHERE tbl_name='X'`.
4. **Your code**: Use `CREATE TABLE` to construct a new table "new_X" that is in the desired revised format of table X. Make sure that the name "new_X" does not collide with any existing table name, of course.
5. **Your code**: Transfer content from X into new_X using a statement like: `INSERT INTO new_X SELECT ... FROM X`.
6. **Your code**: Drop the old table X: `DROP TABLE X`.
7. **Your code**: Change the name of new_X to X using: `ALTER TABLE new_X RENAME TO X`.
8. **Your code**: Use `CREATE INDEX`, `CREATE TRIGGER`, and `CREATE VIEW` to reconstruct indexes, triggers, and views associated with table X. Perhaps use the old format of the triggers, indexes, and views saved from step 3 above as a guide, making changes as appropriate for the alteration.
9. **Your code**: If any views refer to table X in a way that is affected by the schema change, then drop those views using `DROP VIEW` and recreate them with whatever changes are necessary to accommodate the schema change using `CREATE VIEW`.
10. GRDB: If foreign key constraints were originally enabled then run [`PRAGMA foreign_key_check`](https://www.sqlite.org/pragma.html#pragma_foreign_key_check) to verify that the schema change did not break any foreign key constraints.
11. GRDB: Commit the transaction started in step 2.
12. GRDB: If foreign keys constraints were originally enabled, reenable them now.
> :point_up: **Note**: Take care to follow the procedure above precisely, in the same order, or you might corrupt triggers, views, and foreign key constraints. Have a second look at [Making Other Kinds Of Table Schema Changes](https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes) if necessary.
>
> :point_up: **Note**: By default, all migrations perform, at step 10, a full check of all foreign keys in your database. When your database is big, those checks may have a noticeable impact on migration performances. See [Foreign Key Checks] for a discussion of your ways to avoid this toll.
## Foreign Key Checks
SQLite makes it [difficult](https://www.sqlite.org/lang_altertable.html) to perform some schema changes, and this creates very undesired churn w.r.t. foreign keys. GRDB makes its best to hide those problems to you, but you might have to deal with them one day, especially if your database becomes *very big*:
You'll need to read this chapter if you are looking for a mitigation to the time spent by migrations performing foreign key checks. You'll know this by instrumenting your migrations, and looking for the time spent in the `checkForeignKeys` method. See [Advanced Database Schema Changes] right above to know what are those foreign key checks.
**Your first mitigation technique is immediate foreign key checks.**
If you register a migration with `.immediate` foreign key checks, the migration will not temporarily disable foreign keys, and won't need to perform a deferred full check of all foreign keys in your database:
```swift
migrator.registerMigration("make it faster please", foreignKeyChecks: .immediate) { db in
try db.create(table: ...) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
}
```
Such a migration is much faster, and it still guarantees that no foreign key constraint is broken. But it can not run the kind of migrations covered by [Making Other Kinds Of Table Schema Changes](https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes). In this case, you'll need to use the second mitigation technique:
**Your second mitigation technique is to disable deferred foreign key checks.**
You can ask the migrator to stop performing foreign key checks for all newly registered migrations.
:warning: If you use this technique, your app becomes responsible for preventing foreign key violations from being committed to disk!
```swift
migrator = migrator.disablingDeferredForeignKeyChecks()
// From now on, migrations are unchecked!
migrator.registerMigration("fast but unchecked") { db in ... }
```
In order to prevent foreign key violations from being committed to disk, you can:
- Run migrations with immediate foreign key check, as long as they do not require the technique described by [Making Other Kinds Of Table Schema Changes](https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes):
```swift
migrator = migrator.disablingDeferredForeignKeyChecks()
migrator.registerMigration("unchecked") { db in ... }
migrator.registerMigration("checked", foreignKeyChecks: .immediate) { db in ... }
```
- Perform foreign key checks on some tables only:
```swift
migrator = migrator.disablingDeferredForeignKeyChecks()
migrator.registerMigration("partially checked") { db in
...
// Throws an error and stops migrations if there exists a
// foreign key violation in the 'player' table.
try db.checkForeignKeys(in: "player")
}
```
- Perform a full check of foreign keys, eventually:
```swift
try migrator.migrate(dbQueue)
// Throws an error if there exists any foreign key violation.
try dbQueue.read { db in
try db.checkForeignKeys()
}
```
In order to check for foreign key violations, the `checkForeignKeys()` and `checkForeignKeys(in:)` methods are recommended over the raw use of the [`PRAGMA foreign_key_check`](https://www.sqlite.org/pragma.html#pragma_foreign_key_check). Those methods throw a nicely detailed DatabaseError that contains a lot of debugging information:
```swift
// SQLite error 19: FOREIGN KEY constraint violation - from player(teamId) to team(id),
// in [id:1 teamId:2 name:"O'Brien" score:1000]
try db.checkForeignKeys()
```
You can also iterate a lazy [cursor](../README.md#cursors) of all individual foreign key violations found in the database:
```swift
let violations = try db.foreignKeyViolations()
while let violation = try violations.next() {
// The name of the table that contains the `REFERENCES` clause
violation.originTable
// The rowid of the row that contains the invalid `REFERENCES` clause, or
// nil if the origin table is a `WITHOUT ROWID` table.
violation.originRowID
// The name of the table that is referred to.
violation.destinationTable
// The id of the specific foreign key constraint that failed. This id
// matches `ForeignKeyInfo.id`. See `Database.foreignKeys(on:)` for more
// information.
violation.foreignKeyId
// Plain description:
// "FOREIGN KEY constraint violation - from player to team, in rowid 1"
String(describing: violation)
// Rich description:
// "FOREIGN KEY constraint violation - from player(teamId) to team(id),
// in [id:1 teamId:2 name:"O'Brien" score:1000]"
try violation.failureDescription(db)
// Turn violation into a DatabaseError
throw violation.databaseError(db)
}
```
## Asynchronous Migrations
`DatabaseMigrator` provides two ways to migrate a database in an asynchronous way.
The `asyncMigrate(_:completion:)` method:
```swift
// Completes in a protected dispatch queue that can write in the database
migrator.asyncMigrate(dbQueue, completion: { db, error in
if let error = error {
// Some error occurred during migrations
}
})
```
The `migratePublisher(_:receiveOn:)` [Combine](https://developer.apple.com/documentation/combine) publisher:
```swift
// DatabasePublishers.Migrate
let publisher = migrator.migratePublisher(dbQueue)
```
This publisher completes on the main queue, unless you provide a specific [scheduler](https://developer.apple.com/documentation/combine/scheduler) to the `receiveOn` argument.
[Migrations Overview]: #migrations-overview
[The `eraseDatabaseOnSchemaChange` Option]: #the-erasedatabaseonschemachange-option
[Advanced Database Schema Changes]: #advanced-database-schema-changes
[Foreign Key Checks]: #foreign-key-checks
[Asynchronous Migrations]: #asynchronous-migrations
@@ -212,30 +212,30 @@ extension Base: MyDatabaseDecoder {
//: **prepared statement**:
//:
//: try dbQueue.read { db in
//: let statement = try db.makeSelectStatement(sql: "SELECT ...")
//: let statement = try db.makeStatement(sql: "SELECT ...")
//: try Base.fetchCursor(statement) // Cursor of Base
//: try Base.fetchAll(statement) // [Base]
//: try Base.fetchOne(statement) // Base?
//: }
extension MyDatabaseDecoder {
// MARK: - Fetch from SelectStatement
// MARK: - Fetch from Prepared Statement
// SelectStatement, StatementArguments, and RowAdapter are the fundamental
// Statement, StatementArguments, and RowAdapter are the fundamental
// fetching parameters of GRDB. Make sure to accept them all:
static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> MapCursor<RowCursor, DecodedType> {
static func fetchCursor(_ statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> MapCursor<RowCursor, DecodedType> {
// Turn the cursor of raw rows into a cursor of decoded rows
return try Row.fetchCursor(statement, arguments: arguments, adapter: adapter).map {
self.decode(row: $0)
}
}
static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [DecodedType] {
static func fetchAll(_ statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [DecodedType] {
// Turn the cursor into an Array
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
}
static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DecodedType? {
static func fetchOne(_ statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DecodedType? {
// Consume the first value of the cursor
return try fetchCursor(statement, arguments: arguments, adapter: adapter).next()
}
@@ -243,7 +243,7 @@ extension MyDatabaseDecoder {
try dbQueue.read { db in
print("> Fetch from prepared statement")
let statement = try db.makeSelectStatement(sql: "SELECT * FROM base")
let statement = try db.makeStatement(sql: "SELECT * FROM base")
let bases = try Base.fetchAll(statement)
for base in bases {
print(base.description)
@@ -368,15 +368,15 @@ extension MyDatabaseDecoder {
// MARK: - Fetch from SQL
static func fetchCursor(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> MapCursor<RowCursor, DecodedType> {
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
static func fetchAll(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [DecodedType] {
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
static func fetchOne(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> DecodedType? {
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -422,7 +422,7 @@ protocol ContextFetchableRecord {
extension ContextFetchableRecord {
static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil,
context: Context)
@@ -454,7 +454,7 @@ protocol FailableFetchableRecord {
extension FailableFetchableRecord {
static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> MapCursor<RowCursor, Self>
@@ -8,16 +8,39 @@ configuration.prepareDatabase { db in
}
let dbQueue = DatabaseQueue(configuration: configuration)
try! dbQueue.inDatabase { db in
struct Player: Codable, FetchableRecord, MutablePersistableRecord {
var id: Int64?
var name: String
var score: Int
mutating func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
}
try dbQueue.write { db in
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
}
try db.execute(sql: "INSERT INTO player (name, score) VALUES (?, ?)", arguments: ["Arthur", 1000])
try db.execute(sql: "INSERT INTO player (name, score) VALUES (?, ?)", arguments: ["Barbara", 1000])
do {
var player = Player(id: nil, name: "Arthur", score: 100)
try player.insert(db)
player = Player(id: nil, name: "Barbara", score: 100)
try player.insert(db)
}
let names = try String.fetchAll(db, sql: "SELECT name FROM player")
print(names)
do {
let players = try Player.fetchAll(db)
for player in players {
print(player)
}
}
do {
let count = try Player.fetchCount(db)
print(count)
}
}
+632
View File
@@ -0,0 +1,632 @@
Query Interface Organization
============================
**The [query interface] is a Swift API that approximates the [SQLite SELECT query grammar](https://sqlite.org/lang_select.html) through a hierarchy of values and protocols.**
This document exposes its inner organization, so that you can leverage the most of those types and protocols when you want it.
In the diagram below, protocols are pale blue and have rounded corners, and standard types are grey rectangles. Solid arrows read "inherits from", and dashed arrows read "produces". Generic types are marked as such, as well as "PATs" (protocols with associated types).
<img src="https://github.com/groue/GRDB.swift/raw/master/Documentation/Images/QueryInterfaceOrganization2.png" width="100%">
Diagram items are described below:
- [Association]
- [Column]
- [ColumnExpression]
- [DatabaseRegionConvertible]
- [DatabaseValue]
- [DatabaseValueConvertible]
- [DerivableRequest]
- [FetchRequest]
- [Int, String, Date…]
- [QueryInterfaceRequest]
- [SQL]
- [SQLExpression]
- [SQLExpressible]
- [SQLOrderingTerm]
- [SQLOrdering]
- [SQLRequest]
- [SQLSelectable]
- [SQLSelection]
- [SQLSpecificExpressible]
- [SQLSubquery]
- [SQLSubqueryable]
---
### Association
`Association` is the protocol for all [associations]. It is adopted by `BelongsToAssociation`, `HasManyAssociation`, etc. It conforms to [DerivableRequest].
```swift
protocol Association: DerivableRequest {
associatedtype OriginRowDecoder
func forKey(_ key: String) -> Self
}
```
Association has two sub-protocols:
```swift
protocol AssociationToOne: Association { }
protocol AssociationToMany: Association { }
```
`AssociationToMany`, adopted by `HasManyAssociation` and `HasManyThroughAssociation`, leverages [association aggregates].
### Column
`Column` is the type for database columns. It conforms to [ColumnExpression].
```swift
Column("name")
Column("id")
Column.rowID
```
### ColumnExpression
`ColumnExpression` is the protocol for database columns. It is adopted by [Column]. It conforms to [SQLSpecificExpressible].
```swift
protocol ColumnExpression: SQLSpecificExpressible {
/// The name of a database column.
var name: String { get }
}
```
Columns can be used, for example, to query database rows:
```swift
let row = try Row.fetchOne(db, sql: "SELECT 'Arthur' AS name")!
let name: String = row[Column("name")] // "Arthur"
```
Columns are special expressions that allow some optimizations and niceties:
- Database observation: When a request is limited to a known list of rowids in a database table, changes applied to other rows do not trigger the observation. GRDB needs column expressions in order to apply this optimization:
```swift
// Optimized Observations
ValueObservation.tracking { db in
try Player.fetchOne(db, id: 1)
// or
try Player.filter(Column("id") == 1).fetchOne(db)
}
// Non-optimized observations
ValueObservation.tracking { db in
try SQLRequest<Player>("SELECT * FROM player WHERE id = 1").fetchOne(db)
// or
try Player.filter(sql: "id = 1").fetchOne(db)
}
```
- SQL generation: when it generates SQL queries, GRDB appends `LIMIT 1` or not, depending on the primary key and unique indexes used on the queried table. GRDB needs column expressions in order to improve its SQL generation:
```swift
// Nicer SQL
// SELECT * FROM player WHERE id = 1
try Player.fetchOne(db, id: 1)
try Player.filter(Column("id") == 1).fetchOne(db)
// Less nice SQL
// SELECT * FROM player WHERE id = 1 LIMIT 1
try Player.filter(sql: "id = 1").fetchOne(db)
```
### DatabaseRegionConvertible
`DatabaseRegionConvertible` is the protocol for observable requests. It is adopted by [FetchRequest].
```swift
protocol DatabaseRegionConvertible {
func databaseRegion(_ db: Database) throws -> DatabaseRegion
}
```
DatabaseRegionConvertible feeds [DatabaseRegionObservation], which tracks database transactions that impact a particular database region:
```swift
let request = Player.all()
let observation = DatabaseRegionObservation(tracking: request)
let observer = try observation.start(in: dbQueue) { (db: Database) in
print("Players were changed")
}
```
### DatabaseValue
`DatabaseValue` is the type for SQL values (integers, doubles, strings, blobs, and NULL). It conforms to [SQLSpecificExpressible].
You generally build a DatabaseValue from a [DatabaseValueConvertible] type:
```swift
1.databaseValue
"Hello".databaseValue
DatabaseValue.null
```
The query interface will sometimes not accept raw [SQLExpressible] values such as [Int, String, Date], etc. In this case, turn those values into DatabaseValue so that you leverage APIs that need [SQLSpecificExpressible]. For example:
```swift
// SQL: firstName || ' ' || lastName
let fullname = [
Column("firstName"),
" ".databaseValue,
Column("lastName"),
].joined(operator: .concat)
```
### DatabaseValueConvertible
`DatabaseValueConvertible` is the protocol for types that can provide [DatabaseValue]: SQL integers, doubles, strings, blobs, and NULL. It is adopted by [Int, String, Date], etc. It conforms to [SQLExpressible] because all SQL values are SQL expressions.
```swift
protocol DatabaseValueConvertible: SQLExpressible {
/// Returns a value that can be stored in the database.
var databaseValue: DatabaseValue { get }
/// Returns a value initialized from `dbValue`, if possible.
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
}
```
### DerivableRequest
`DerivableRequest` is the protocol for query interface requests and associations that can be refined. It is adopted by [QueryInterfaceRequest] and [Association].
```swift
protocol DerivableRequest: AggregatingRequest, FilteredRequest,
JoinableRequest, OrderedRequest,
SelectionRequest, TableRequest
{
func distinct() -> Self
func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> Self
}
```
- `AggregatingRequest` provides grouping methods such as `groupByPrimaryKey()`
- `FilteredRequest` provides filtering methods such as `filter(expression)` or `filter(id: value)`
- `JoinableRequest` provides association methods such as `joining(required: association)` or `including(all: association)`
- `OrderedRequest` provides ordering methods such as `order(ordering)` or `reversed()`
- `SelectionRequest` provides selection methods such as `select(selection)` or `annotated(with: selection)`
- `TableRequest` provides table targeting methods such as `aliased(tableAlias)`
DerivableRequest makes it possible to build reusable code snippets that apply to both requests and associations. You'll read more about it in the [Good Practices for Designing Record Types](GoodPracticesForDesigningRecordTypes.md) and [Associations](AssociationsBasics.md).
### FetchRequest
`FetchRequest` is the protocol for requests that can fetch. It is adopted by [QueryInterfaceRequest] and [SQLRequest]. It conforms to [SQLSubqueryable] and [DatabaseRegionConvertible].
```swift
protocol FetchRequest: SQLSubqueryable, DatabaseRegionConvertible {
/// The type that tells how fetched database rows should be interpreted.
associatedtype RowDecoder
/// Returns a PreparedRequest that is ready to be executed.
func makePreparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest
/// Returns the number of rows fetched by the request.
func fetchCount(_ db: Database) throws -> Int
}
```
FetchRequest can fetch values from the database as long as its `RowDecoder` associated type is `Row`, a [DatabaseValueConvertible] type, or a [FetchableRecord] type.
```swift
let row: Row? = try SQLRequest<Row>("SELECT * FROM player").fetchOne(db)
let players: [Player] = try Player.all().fetchAll(db)
```
FetchRequest usually executes a single SQL query:
```swift
// SELECT * FROM player
let request = Player.all()
try request.fetchAll(db)
```
This single SQL query is exposed through `makePreparedRequest(_:forSingleResult:)`:
```swift
let request = Player.all()
let preparedRequest = try request.makePreparedRequest(db)
print(preparedRequest.statement.sql) // SELECT * FROM player
```
But not all fetch requests execute a single SQL query. A [QueryInterfaceRequest] that involves [associations] can execute several:
```swift
// SELECT * FROM player
// SELECT * FROM award WHERE playerId IN (...)
struct PlayerInfo: Decodable, FetchableRecord {
var player: Player
var awards: [Award]
}
let playerInfos = try Player
.including(all: Player.awards)
.asRequest(of: PlayerInfo.self)
.fetchAll(db)
```
Those supplementary SQL queries are an implementation detail of `PreparedRequest`, and are not currently exposed.
### Int, String, Date…
The basic value types conform to [DatabaseValueConvertible] so that they can feed database queries with [DatabaseValue]:
```swift
// SELECT * FROM player WHERE name = 'O''Brien'
// ~~~~~~~~~~
Player.filter(Column("name") == "O'Brien")
```
### QueryInterfaceRequest
`QueryInterfaceRequest` is the type of fetch requests built by the GRDB query builder. It conforms to [FetchRequest] and [DerivableRequest].
It is generic on the type of fetched values:
```swift
struct PlayerInfo: Decodable, FetchableRecord {
var player: Player
var awards: [Award]
}
// QueryInterfaceRequest<Player>
let playerRequest = Player.all()
// QueryInterfaceRequest<String>
let nameRequest = Player.select(Column("name"), as: String.self)
// QueryInterfaceRequest<PlayerInfo>
let playerInfoRequest = Player
.including(all: Player.awards)
.asRequest(of: PlayerInfo.self)
try playerRequest.fetchAll(db) // [Player]
try nameRequest.fetchAll(db) // [String]
try playerInfoRequest.fetchAll(db) // [PlayerInfo]
```
For more information on QueryInterfaceRequest, see [Requests](../README.md#requests) and [Associations](AssociationsBasics.md).
### SQL
`SQL` is the type for SQL literals that support [SQL Interpolation]. It can feed all GRDB APIs that have a `literal` argument:
```swift
let literal: SQL = "SELECT * FROM player"
let request = SQLRequest<Player>(literal: literal)
let players: [Player] = try request.fetchAll(db)
```
`SQL` conforms to [SQLSpecificExpressible], and thus behaves as an [SQLite expression](https://sqlite.org/syntax/expr.html) by default:
```swift
let literal: SQL = "name = \("O'Brien")"
let request = Player.filter(literal)
let players: [Player] = try request.fetchAll(db)
```
:warning: **Warning**: Not all SQL snippets are expressions. It is not recommended to pass `SQL` literals around, or you may end up forgetting their content, and eventually generate invalid SQL. When possible, prefer building an explicit [SQLExpression], [SQLOrdering], [SQLSelection], [SQLRequest], or [SQLSubquery], depending on what you want to express:
```swift
// SQLExpression
SQL("name = \("O'Brien")").sqlExpression
// SQLOrdering
SQL("name DESC)").sqlOrdering
// SQLSelection
SQL("score + bonus AS total)").sqlSelection
SQL("*").sqlSelection
// SQLRequest
SQLRequest<Player>(literal: "SELECT * FROM player")
// SQLSubquery
SQLRequest(literal: "SELECT * FROM player").sqlSubquery
```
### SQLExpression
`SQLExpression` is the opaque type for all [SQLite expressions](https://sqlite.org/syntax/expr.html). It adopts [SQLSpecificExpressible], and is built from [SQLExpressible].
```swift
struct SQLExpression: SQLSpecificExpressible {
// opaque implementation
}
```
Functions and methods that build an SQL expression should return an SQLExpression value:
```swift
// SELECT * FROM player WHERE LENGTH(name) > 0
let expression = length(Column("name")) > 0 // SQLExpression
Player.filter(expression)
```
When it looks like GRDB APIs are unable to build a particular expression, use [SQL]:
```swift
func date(_ value: SQLSpecificExpressible) -> SQLExpression {
SQL("DATE(\(value))").sqlExpression
}
// SELECT * FROM player WHERE DATE(createdAt) = '2020-01-23'
let request = Player.filter(date(Column("createdAt")) == "2020-01-23")
```
This technique, based on [SQL Interpolation], is composable and works well even when several tables are involved. See how the `createdAt` column below is correctly attributed to the `player` table:
```swift
// SELECT player.*, team.* FROM player
// JOIN team ON team.id = player.teamId
// WHERE DATE(player.createdAt) = '2020-01-23'
let request = Player
.filter(date(Column("createdAt")) == "2020-01-23")
.including(required: Player.team)
```
### SQLExpressible
`SQLExpressible` is the protocol for all [SQLite expressions](https://sqlite.org/syntax/expr.html). It is adopted by [Column], [SQL], [SQLExpression], and also [Int, String, Date], etc. It has an `sqlExpression` property which returns an [SQLExpression].
```swift
protocol SQLExpressible {
var sqlExpression: SQLExpression { get }
}
```
SQLExpressible-conforming types include types which are not directly related to SQL, such as [Int, String, Date], etc. Because of this, SQLExpressible has limited powers that prevent misuses and API pollution. For full-fledged SQL expressions, see [SQLSpecificExpressible]. For example, compare:
```swift
Player.filter(1) // Compiler warning (will become an error in the next major release)
Player.select(1) // Compiler error
Player.order("name") // Compiler error
length("name") // Compiler error
"name".desc // Compiler error
```
```swift
Player.filter(id: 1) // OK
Player.filter(1.databaseValue) // Odd, but OK
Player.select(1.databaseValue) // Odd, but OK
Player.order(Column("name")) // OK
length(Column("name")) // OK
Column("name").desc // OK
```
### SQLOrderingTerm
`SQLOrderingTerm` is the protocol for all [SQLite ordering terms](https://sqlite.org/syntax/ordering-term.html). It is adopted by [SQLSpecificExpressible]. It has an `sqlOrdering` property which returns an [SQLOrdering].
```swift
protocol SQLOrderingTerm {
var sqlOrdering: SQLOrdering { get }
}
```
SQLOrderingTerm feeds the `order()` method of the query interface:
```swift
// SELECT * FROM player
// ORDER BY score DESC, name COLLATE ...
Player.order(
Column("score").desc,
Column("name").collating(.localizedCaseInsensitiveCompare))
```
All [SQLSpecificExpressible] values are ordering terms. [SQLExpressible] values are not: `Player.order("name")` does not compile. Instead, use:
```swift
// SELECT * FROM player ORDER BY name -- Order according to a column
Player.order(Column("name"))
// SELECT * FROM player ORDER BY 'name' -- Order according to a constant string (why not)
Player.order("name".databaseValue)
```
### SQLOrdering
`SQLOrdering` is the opaque type for all [SQLite ordering terms](https://sqlite.org/syntax/ordering-term.html). An SQLOrdering adopts and is built from [SQLOrderingTerm].
```swift
struct SQLOrdering: SQLOrderingTerm {
// opaque implementation
}
```
Functions and methods that build ordering terms should return an SQLOrdering value:
```swift
// SELECT * FROM player ORDER BY score DESC
let ordering = Column("score").desc // SQLOrdering
Player.order(ordering)
```
To build an SQLOrdering without applying any `DESC` or `ASC` qualifier, use `sqlOrdering` (from [SQLOrderingTerm], inherited by [SQLSpecificExpressible], [ColumnExpression]...):
```swift
let ordering = Column("score").sqlOrdering // SQLOrdering
```
### SQLRequest
`SQLRequest` is the type of fetch requests expressed with raw SQL. It conforms to [FetchRequest].
It is generic on the type of fetched values (which defaults to `Row`):
```swift
let rowRequest = SQLRequest(sql: "SELECT * FROM player") // SQLRequest<Row>
let playerRequest = SQLRequest<Player>(sql: "SELECT * FROM player") // SQLRequest<Player>
let nameRequest = SQLRequest<String>(sql: "SELECT name FROM player") // SQLRequest<String>
try rowRequest.fetchAll(db) // [Row]
try playerRequest.fetchAll(db) // [Player]
try nameRequest.fetchAll(db) // [String]
try rowRequest.fetchOne(db) // Row?
try playerRequest.fetchOne(db) // Player?
try nameRequest.fetchOne(db) // String?
```
SQLRequest supports [SQL Interpolation]:
```swift
// SELECT * FROM player WHERE name = 'O''Brien'
let playerRequest: SQLRequest<Player> = """
SELECT * FROM player WHERE name = \("O'Brien")
"""
```
### SQLSelectable
`SQLSelectable` is the protocol for all [SQLite result columns](https://sqlite.org/syntax/result-column.html). It is adopted by [SQLSpecificExpressible]. It has an `sqlSelection` property which returns an [SQLSelection].
```swift
protocol SQLSelectable {
var sqlSelection: SQLSelection { get }
}
```
SQLSelectable feeds the `select()` method of the query interface:
```swift
Player.select(AllColumns())
Player.select(Column("name"), Column("score"))
```
All [SQLSpecificExpressible] values are selectable. Other selectable values are:
```swift
// SELECT * FROM player
Player.select(AllColumns())
// SELECT MAX(score) AS maxScore FROM player
Player.select(max(Column("score")).forKey("maxScore"))
```
[SQLExpressible] values are not selectable: `Player.select("name")` does not compile. Instead, use:
```swift
// SELECT name FROM player -- Selects a column
Player.select(Column("name"))
// SELECT 'name' FROM player -- Selects a constant string (why not)
Player.select("name".databaseValue)
```
### SQLSelection
`SQLSelection` is the opaque type for all [SQLite result columns](https://sqlite.org/syntax/result-column.html). An SQLSelection adopts and is built from [SQLSelectable].
```swift
struct SQLSelection: SQLSelectable {
// opaque implementation
}
```
Functions and methods that build result columns should return an SQLSelection value:
```swift
// SELECT (score + bonus) AS total
let selection = (Column("score") + Column("bonus")).forKey("total") // SQLSelection
Player.select(selection)
```
### SQLSpecificExpressible
`SQLSpecificExpressible` is the protocol for all SQL expressions, except values such as [Int, String, Date], etc. It conforms to [SQLExpressible], [SQLSelectable], and [SQLOrderingTerm]. It is adopted by [Column], [SQL], and [SQLExpression]. It is also adopted through [SQLSubqueryable] by [QueryInterfaceRequest] and [SQLRequest].
```swift
protocol SQLSpecificExpressible: SQLExpressible, SQLSelectable, SQLOrderingTerm { }
```
Use SQLSpecificExpressible when you want to operate on expressions, except [Int, String, Date] and other types which are not directly related to SQL. For example, the built-in `length(_:)` GRDB function accepts SQLSpecificExpressible:
```swift
/// The LENGTH SQL function
func length(_ value: SQLSpecificExpressible) -> SQLExpression { ... }
length(Column("name")) // OK
length("name") // Compiler error
```
### SQLSubquery
`SQLSubquery` is the opaque type for all [SQLite SELECT queries](https://sqlite.org/syntax/select-stmt.html). An SQLSubquery adopts and is built from [SQLSubqueryable].
```swift
struct SQLSubquery: SQLSubqueryable {
// opaque implementation
}
```
### SQLSubqueryable
`SQLSubqueryable` is the protocol for all [SQLite SELECT queries](https://sqlite.org/syntax/select-stmt.html). It conforms to [SQLSpecificExpressible], and is adopted by [FetchRequest], [QueryInterfaceRequest], [SQLRequest]. It has an `sqlSubquery` property which returns an [SQLSubquery].
```swift
protocol SQLSubqueryable: SQLSpecificExpressible {
var sqlSubquery: SQLSubquery { get }
}
```
SQLSubqueryable provides the GRDB support for subqueries. Its [SQLSpecificExpressible] facet lets you use any request as an expression:
```swift
// SELECT * FROM player
// WHERE score >= (SELECT AVG(score) FROM player)
let averageScore = Player.select(average(Column("score")))
Player.filter(Column("score") >= averageScore)
```
SQLSubqueryable has the `contains(_:)` and `exists()` methods that support the `value IN (subquery)` and `EXISTS (subquery)` expressions.
Use SQLSubqueryable in order to define a function that requires a subquery argument:
```swift
func myRequest(_ nameSubquery: SQLSubqueryable) -> SQLRequest<Player> {
"""
SELECT * FROM player
WHERE name IN (\(nameSubquery) UNION ...)
"""
}
myRequest(SQLRequest("SELECT ..."))
myRequest(Player.select(...).filter(...))
```
[Association]: #association
[associations]: AssociationsBasics.md
[association aggregates]: AssociationsBasics.md#association-aggregates
[Column]: #column
[ColumnExpression]: #columnexpression
[DatabaseRegionConvertible]: #databaseregionconvertible
[DatabaseRegionObservation]: ../README.md#databaseregionobservation
[DatabaseValue]: #databasevalue
[DatabaseValueConvertible]: #databasevalueconvertible
[DerivableRequest]: #derivablerequest
[FetchableRecord]: ../README.md#fetchablerecord-protocol
[FetchRequest]: #fetchrequest
[Int, String, Date…]: #int-string-date
[Int, String, Date]: #int-string-date
[query interface]: ../README.md#the-query-interface
[QueryInterfaceRequest]: #queryinterfacerequest
[SQL]: #sql
[SQL Interpolation]: SQLInterpolation.md
[SQLExpression]: #sqlexpression
[SQLExpressible]: #sqlexpressible
[SQLOrderingTerm]: #sqlorderingterm
[SQLOrdering]: #sqlordering
[SQLRequest]: #sqlrequest
[SQLSelectable]: #sqlselectable
[SQLSelection]: #sqlselection
[SQLSpecificExpressible]: #sqlspecificexpressible
[SQLSubquery]: #sqlsubquery
[SQLSubqueryable]: #sqlsubqueryable
+1 -1
View File
@@ -22,7 +22,7 @@ To release a new GRDB version:
- Support/Info.plist
- Commit and tag
- Check tag authors: `git for-each-ref --format '%(refname) %(authorname)' refs/tags`
- Push to the master branch
- Push to the master & development branch
- `pod trunk push --allow-warnings GRDB.swift.podspec`
- `make doc`, and update index.html in the `gh-pages` branch
- Update http://github.com/groue/WWDCCompanion
+49 -30
View File
@@ -19,10 +19,10 @@ try dbQueue.write { db in
}
```
SQL Interpolation is an answer to these troubles. It is available in Swift 5.
SQL Interpolation is an answer to these troubles.
- [Introduction]
- [SQLLiteral]
- [SQL Literal]
- [SQL Interpolation and the Query Interface]
- [SQL Interpolation and Record Protocols]
- [SQL Interpolation Reference]
@@ -73,38 +73,38 @@ Plain SQL strings are indeed still available, and SQL interpolation only kicks i
```
## SQLLiteral
## SQL Literal
**SQLLiteral** is the type that looks like a plain String, but profits from SQL interpolation:
**`SQL`** is the type that looks like a plain String, but profits from SQL interpolation:
```swift
try dbQueue.write { db in
let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
try db.execute(literal: query)
}
```
**SQLLiteral is not a Swift String.** You can not use the `execute(literal:)` method with a String argument:
**`SQL` is not a Swift String.** You can not use the `execute(literal:)` method with a String argument:
```swift
try dbQueue.write { db in
let query = "UPDATE player SET name = \(name) WHERE id = \(id)" // a regular String
// Compiler error:
// Cannot convert value of type 'String' to expected argument type 'SQLLiteral'
// Cannot convert value of type 'String' to expected argument type 'SQL'
try db.execute(literal: query)
}
```
SQLLiteral can build your queries step by step, with regular operators and methods:
`SQL` can build your queries step by step, with regular operators and methods:
```swift
// +, +=, append
var query: SQLLiteral = "UPDATE player "
var query: SQL = "UPDATE player "
query += "SET name = \(name) "
query.append(literal: "WHERE id = \(id)")
// joined(), joined(separator:)
let components: [SQLLiteral] = [
let components: [SQL] = [
"UPDATE player",
"SET name = \(name)",
"WHERE id = \(id)"
@@ -115,7 +115,7 @@ let query = components.joined(separator: " ")
Extract the plain SQL string from a literal:
```swift
let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
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]
@@ -124,17 +124,17 @@ print(arguments) // prints ["O'Brien", 42]
Build a literal from a plain SQL string:
```swift
let query = SQLLiteral(
let query = SQL(
sql: "UPDATE player SET name = ? WHERE id = ?",
arguments: [name, id])
```
SQLLiteral can embed any [value], as we have seen above, but not only. Please keep on reading the next chapter, or jump directly to the [SQL Interpolation Reference].
`SQL` can embed any [value], as we have seen above, but not only. Please keep on reading the next chapter, or jump directly to the [SQL Interpolation Reference].
## SQL Interpolation and the Query Interface
SQL Interpolation and SQLLiteral let you embed raw SQL snippets in [query interface requests].
SQL Interpolation and `SQL` let you embed raw SQL snippets in [query interface requests].
For example:
@@ -143,25 +143,37 @@ For example:
let request = Player.filter(literal: "name = \("O'Brien")")
```
You can also build literal expressions from other expressions. For example, let's call the `DATE` SQLite function on a query interface column:
You can also build literals from other expressions. For example, let's call the `DATE` SQLite function on a query interface column:
```swift
// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
// SELECT * FROM player WHERE DATE(createdAt) = '2020-01-23'
let createdAt = Column("createdAt")
let creationDay = SQLLiteral("DATE(\(createdAt))").sqlExpression
let creationDay = SQL("DATE(\(createdAt))")
let request = Player.filter(creationDay == "2020-01-23")
```
Such literal expressions can be returned by Swift functions:
Such literals play well with the query interface, even when several tables are involved with [associations](AssociationsBasics.md):
```swift
func date(_ value: SQLExpressible) -> SQLExpression {
SQLLiteral("DATE(\(value))").sqlExpression
// SELECT player.*, team.*
// FROM player
// JOIN team ON team.id = player.teamID
// WHERE DATE(player.createdAt) = '2020-01-23'
// ~~~~~~~~~~~~~~~~~~~~~~
// automatic table disambiguation
let request = Player
.filter(creationDay == "2020-01-23")
.including(required: Player.team)
```
This allows you to define Swift functions that you can use in all circumstances:
```swift
func date(_ expression: SQLExpressible) -> SQLExpression {
SQL("DATE(\(expression))").sqlExpression
}
// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
let createdAt = Column("createdAt")
let request = Player.filter(date(createdAt) == "2020-01-23")
let request = Player.filter(date(Column("createdAt")) == "2020-01-23")
```
@@ -334,7 +346,7 @@ Let's extend Player with database methods.
extension Player: Decodable, FetchableRecord, TableRecord {
/// A complex request
static func complexRequest() -> SQLRequest<Player> {
let query: SQLLiteral = "SELECT \(columnsOf: self) "
let query: SQL = "SELECT \(columnsOf: self) "
query += "FROM \(self) "
query += "JOIN \(Team.self) ON ..."
query += "GROUP BY ..."
@@ -343,7 +355,7 @@ Let's extend Player with database methods.
}
```
This last request shows how to build an SQLRequest from an [SQLLiteral]. You will need SQLLiteral when the request can not be written in a single stroke.
This last request shows how to build an SQLRequest from an [SQL Literal]. You will need `SQL` when the request can not be written in a single stroke.
@@ -417,14 +429,21 @@ This chapter lists all kinds of supported interpolations.
```swift
// SELECT * FROM player ORDER BY name DESC
"SELECT * FROM player WHERE id IN \(Column("name").desc)"
"SELECT * FROM player ORDER BY \(Column("name").desc)"
```
- Database Collations:
```swift
"SELECT * FROM player ORDER BY email COLLATING \(.nocase)"
"SELECT * FROM player ORDER BY email COLLATING \(.localizedCompare)"
```
- Subqueries:
```swift
// SELECT * FROM player WHERE score = (SELECT MAX(score) FROM player)
let subquery: SQLRequest<Int> = "SELECT MAX(score) FROM player"
let subquery = SQLRequest("SELECT MAX(score) FROM player")
"SELECT * FROM player WHERE score = (\(subquery))"
// SELECT * FROM player WHERE score = (SELECT MAX(score) FROM player)
@@ -442,11 +461,11 @@ This chapter lists all kinds of supported interpolations.
"WITH \(definitionFor: cte) SELECT * FROM \(cte)"
```
- SQLLiteral:
- `SQL` literal:
```swift
// SELECT * FROM player WHERE name = 'O''Brien'
let condition: SQLLiteral = "name = \("O'Brien")"
let condition: SQL = "name = \("O'Brien")"
"SELECT * FROM player WHERE \(literal: condition)"
```
@@ -461,7 +480,7 @@ This chapter lists all kinds of supported interpolations.
```
[Introduction]: #introduction
[SQLLiteral]: #sqlliteral
[SQL Literal]: #sql-literal
[SQL Interpolation and the Query Interface]: #sql-interpolation-and-the-query-interface
[SQL Interpolation and Record Protocols]: #sql-interpolation-and-record-protocols
[SQL Interpolation Reference]: #sql-interpolation-reference
+13 -8
View File
@@ -1,7 +1,7 @@
Sharing a Database
==================
This chapter describes a recommended setup that applies as soon as several processes want to access a same SQLite database.
**This guide describes a recommended setup that applies as soon as several processes want to access the same SQLite database.** It complements the [Concurrency](Concurrency.md) guide, that you should read first.
On iOS for example, you can share database files between multiple processes by storing them in an [App Group Container](https://developer.apple.com/documentation/foundation/nsfilemanager/1412643-containerurlforsecurityapplicati). On macOS as well, several processes may want to open the same database, according to their particular sandboxing contexts.
@@ -66,7 +66,7 @@ Since several processes may open the database at the same time, protect the crea
}
}
}
let dbPool = try DatabasePool(path: databaseURL.path)
let dbPool = try DatabasePool(path: databaseURL.path, configuration: configuration)
// Perform here other database setups, such as defining
// the database schema with a DatabaseMigrator, and
@@ -152,7 +152,6 @@ If several processes want to write in the database, configure the database pool
```swift
var configuration = Configuration()
configuration.busyMode = .timeout(/* a TimeInterval */)
configuration.defaultTransactionKind = .immediate
let dbPool = try DatabasePool(path: ..., configuration: configuration)
```
@@ -161,7 +160,7 @@ With such a setup, you may still get `SQLITE_BUSY` (5, "database is locked") err
```swift
do {
try dbPool.write { db in ... }
} catch let error as DatabaseError where error.resultCode == .SQLITE_BUSY {
} catch DatabaseError.SQLITE_BUSY {
// Another process won't let you write. Deal with it.
}
```
@@ -173,9 +172,9 @@ do {
> The exception code 0xDEAD10CC indicates that an application has been terminated by the OS because it held on to a file lock or sqlite database lock during suspension.
See https://developer.apple.com/library/archive/technotes/tn2151/_index.html for more information about this exception.
See https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report for more information about this exception.
1. If you use SQLCipher, use SQLCipher 4+, and call the `cipher_plaintext_header_size` pragma from your database preparation function:
1. If you use SQLCipher, use SQLCipher 4+, and call the [`cipher_plaintext_header_size` pragma](https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_plaintext_header_size) from your database preparation function:
```swift
var configuration = Configuration()
@@ -186,7 +185,13 @@ See https://developer.apple.com/library/archive/technotes/tn2151/_index.html for
let dbPool = try DatabasePool(path: ..., configuration: configuration)
```
This will avoid https://github.com/sqlcipher/sqlcipher/issues/255.
This will avoid this issue: https://github.com/sqlcipher/sqlcipher/issues/255.
This will also disable a SQLCipher security feature: the salt. As described by https://www.zetetic.net/sqlcipher/design/:
> The salt is used for key derivation and it ensures that even if two databases are created using the same password, they will not have the same encryption key.
Applications are responsible for managing the salt themselves and providing it to SQLCipher. See https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_plaintext_header_size for instructions.
2. [**:fire: EXPERIMENTAL**](../README.md#what-are-experimental-features) In each process that wants to write in the database:
@@ -245,7 +250,7 @@ See https://developer.apple.com/library/archive/technotes/tn2151/_index.html for
```swift
do {
try dbPool.write { db in ... }
} catch let error as DatabaseError where error.isInterruptionError {
} catch DatabaseError.SQLITE_INTERRUPT, DatabaseError.SQLITE_ABORT {
// Oops, the database is suspended.
// Maybe try again after database is resumed?
}
+242
View File
@@ -0,0 +1,242 @@
Single-Row Tables
=================
Let's talk about database tables that should contain a single row.
Such tables can store configuration values, user preferences, and generally some global application state. They are a suitable alternative to `UserDefaults` in some applications, especially when configuration refers to values found in other database tables, and database integrity is a concern.
An alternative way to store such configuration is a table of key-value pairs: two columns, and one row for each configuration value. This technique works, but it has a few drawbacks: you will have to deal with the various types of configuration values (strings, integers, dates, etc), and you won't be able to define foreign keys. This is why we won't explore key-value tables.
This guide helps you implementing a single-row table with GRDB, with recommendations on the database schema, migrations, and the design of a matching [record] type.
- [The Single-Row Table]
- [The Single-Row Record]
- [Wrap-Up]
## The Single-Row Table
As always with GRDB, everything starts at the level of the database schema. Putting the robust SQLite on our side is always a good idea, because we have to write less code, and this helps shipping less bugs.
We want to instruct SQLite that our table must never contain more than one row. We will never have to wonder what to do if we were unlucky enough to find two rows with conflicting values in this table.
SQLite is not able to guarantee that the table is never empty, so we have to deal with two cases: either the table is empty, or it contains one row.
Those two cases can create a nagging question for the application. By default, inserts fail when the row already exists, and updates fail when the table is empty. In order to avoid those errors, we will have the app perform an insert in case of a failed update (in the [The Single-Row Record] chapter). And we instruct SQLite to just replace the eventual existing row in case of conflicting inserts:
```swift
// CREATE TABLE appConfiguration (
// id INTEGER PRIMARY KEY ON CONFLICT REPLACE CHECK (id = 1),
// flag BOOLEAN NOT NULL,
// ...)
try db.create(table: "appConfiguration") { t in
// Single row guarantee
t.column("id", .integer)
// Have inserts replace the existing row
.primaryKey(onConflict: .replace)
// Make sure the id column is always 1
.check { $0 == 1 }
// The configuration colums
t.column("flag", .boolean).notNull()
// ... other columns
}
```
When you use [migrations], you may wonder if it is a good idea or not to perform an initial insert just after the table is created. Well, this is not recommended:
```swift
// NOT RECOMMENDED
migrator.registerMigration("appConfiguration") { db in
try db.create(table: "appConfiguration") { t in
// Single row guarantee
t.column("id", .integer).primaryKey(onConflict: .replace).check { $0 == 1 }
// Define sensible defaults for each column
t.column("flag", .boolean).notNull()
.defaults(to: false)
// ... other columns
}
// Populate the table
try db.execute(sql: "INSERT INTO appConfiguration DEFAULT VALUES")
}
```
It is not a good idea to populate the table in a migration, for two reasons:
1. This is not a hard guarantee that the table will never be empty. As a consequence, this won't prevent your Swift code from dealing with the possibility of a missing row. On top of that, the Swift code that deals with the missing row may not use the same default values as the SQLite schema (a [DRY] violation), with unclear consequences.
2. Migrations that are shipped in the wild should *never* change, because you want to control the state of the databases installed on your users' devices, regardless of the application version they install first, regardless of how many application versions are skipped when they download an upgrade, etc. By inserting an initial row in a migration, you make it difficult for your application to adjust the sensible default values in the future, while keeping a clear idea of the various installation and upgrade scenarios.
The recommended migration creates the table, nothing more:
```swift
// RECOMMENDED
migrator.registerMigration("appConfiguration") { db in
try db.create(table: "appConfiguration") { t in
// Single row guarantee
t.column("id", .integer).primaryKey(onConflict: .replace).check { $0 == 1 }
// The configuration colums
t.column("flag", .boolean).notNull()
// ... other columns
}
}
```
## The Single-Row Record
Now that the database schema has been defined, we can define the [record] type that will help the application access the single row:
```swift
struct AppConfiguration: Codable {
// Support for the single row guarantee
private var id = 1
// The configuration properties
var flag: Bool
// ... other properties
}
```
In case the database table would be empty, we need a default configuration:
```swift
extension AppConfiguration {
/// The default configuration
static let `default` = AppConfiguration(flag: false, ...)
}
```
We make our record able to access the database:
```swift
extension AppConfiguration: FetchableRecord, PersistableRecord {
```
We have seen in the [The Single-Row Table] chapter that by default, updates throw an error if the database table is empty. To avoid this error, we instruct GRDB to perform an insert in case of a failed update (see [Persistence Methods] for more information):
```swift
// Customize the default PersistableRecord behavior
func update(_ db: Database, columns: Set<String>) throws {
do {
try performUpdate(db, columns: columns)
} catch PersistenceError.recordNotFound {
// No row was updated: perform an insert
try performInsert(db)
}
}
```
The standard GRDB method `fetchOne` returns an optional which is nil when the database table is empty. As a convenience, let's define a method that returns a non-optional (replacing the missing row with `default`):
```swift
/// Returns the persisted configuration, or the default one if the
/// database table is empty.
static func fetch(_ db: Database) throws -> AppConfiguration {
try fetchOne(db) ?? .default
}
}
```
And that's it! Now we can use our singleton record:
```swift
// READ
let config = try dbQueue.read { db in
try AppConfiguration.fetch(db)
}
if config.flag {
// ...
}
// WRITE
try dbQueue.write { db in
var config = try AppConfiguration.fetch(db)
// Update some config values
try config.updateChanges(db) {
$0.flag = true
}
// Other possible ways to write config:
try config.update(db)
try config.save(db)
try config.insert(db)
}
```
The three `update`, `save` and `insert` methods can be used interchangeably: all three make sure the configuration is stored in the database.
The `updateChanges` method only updates the values changed by its closure argument (and performs an insert if the database table is empty).
See [Persistence Methods] for more information.
## Wrap-Up
We all love to copy and paste, don't we? Just customize the template code below:
```swift
// Table creation
try db.create(table: "appConfiguration") { t in
// Single row guarantee
t.column("id", .integer).primaryKey(onConflict: .replace).check { $0 == 1 }
// The configuration columns
t.column("flag", .boolean).notNull()
// ... other columns
}
```
```swift
//
// AppConfiguration.swift
//
import GRDB
struct AppConfiguration: Codable {
// Support for the single row guarantee
private var id = 1
// The configuration properties
var flag: Bool
// ... other properties
}
extension AppConfiguration {
/// The default configuration
static let `default` = AppConfiguration(flag: false, ...)
}
// Database Access
extension AppConfiguration: FetchableRecord, PersistableRecord {
// Customize the default PersistableRecord behavior
func update(_ db: Database, columns: Set<String>) throws {
do {
try performUpdate(db, columns: columns)
} catch PersistenceError.recordNotFound {
// No row was updated: perform an insert
try performInsert(db)
}
}
/// Returns the persisted configuration, or the default one if the
/// database table is empty.
static func fetch(_ db: Database) throws -> AppConfiguration {
try fetchOne(db) ?? .default
}
}
```
[migrations]: Migrations.md
[record]: ../README.md#records
[The Single-Row Table]: #the-single-row-table
[The Single-Row Record]: #the-single-row-record
[Wrap-Up]: #wrap-up
[DRY]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
[Persistence Methods]: ../README.md#persistence-methods
+3 -5
View File
@@ -240,7 +240,7 @@ let maximumScore: Int? = try Int.fetchOne(db, sql: """
""")
```
With Swift 5, you can profit from **SQL interpolation**. It lets you build SQL queries from natural looking strings, but without any risk of syntax error or [SQL injection](https://xkcd.com/327/):
[SQL interpolation] lets you build SQL queries from natural looking strings, but without any risk of syntax error or [SQL injection](https://xkcd.com/327/):
```swift
try db.execute(literal: "UPDATE player SET score = \(score) WHERE id = \(id)")
@@ -283,11 +283,9 @@ while let row = try rows.next() {
If this little tour of GRDB has convinced you, the real trip starts here: [GRDB].
And if you happen to maintain an Objective-C application that uses FMDB, checkout [GRDBObjc]. It provides FMDB-compatible bindings to GRDB, so that you can inject sweet drops of Swift into your app, at your own pace, and at minimal cost.
Happy GRDB! :gift:
[Concurrency Guide]: ../README.md#concurrency
[Concurrency Guide]: Concurrency.md
[Core Data]: https://developer.apple.com/documentation/coredata
[DatabasePool]: ../README.md#database-pools
[Diesel]: http://diesel.rs
@@ -296,7 +294,6 @@ Happy GRDB! :gift:
[Fluent]: https://github.com/vapor/fluent
[FMDB]: http://github.com/ccgus/fmdb
[GRDB]: http://github.com/groue/GRDB.swift
[GRDBObjc]: http://github.com/groue/GRDBObjc
[PersistableRecord]: ../README.md#records
[Realm]: http://realm.io
[FetchableRecord]: ../README.md#records
@@ -309,3 +306,4 @@ Happy GRDB! :gift:
[associations]: AssociationsBasics.md
[Codable records]: ../README.md#codable-records
[records]: ../README.md#records
[SQL interpolation]: SQLInterpolation.md
+3 -3
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
s.version = '5.3.0'
s.version = '5.15.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
@@ -9,8 +9,8 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/groue/GRDB.swift.git', :tag => "v#{s.version}" }
s.module_name = 'GRDB'
s.swift_versions = ['5.2']
s.ios.deployment_target = '10.0'
s.swift_versions = ['5.3', '5.4', '5.5']
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.10'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
File diff suppressed because it is too large. Load diff
+23 -7
View File
@@ -9,12 +9,12 @@ public struct Configuration {
/// If true, foreign key constraints are checked.
///
/// Default: true
public var foreignKeysEnabled: Bool = true
public var foreignKeysEnabled = true
/// If true, database modifications are disallowed.
///
/// Default: false
public var readonly: Bool = false
public var readonly = false
/// The configuration label.
///
@@ -91,7 +91,7 @@ public struct Configuration {
/// When true, the `Database.suspendNotification` and
/// `Database.resumeNotification` suspend and resume the database. Database
/// suspension helps avoiding the [`0xdead10cc`
/// exception](https://developer.apple.com/library/archive/technotes/tn2151/_index.html).
/// exception](https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report).
///
/// During suspension, all database accesses but reads in WAL mode may throw
/// a DatabaseError of code `SQLITE_INTERRUPT`, or `SQLITE_ABORT`. You can
@@ -108,6 +108,9 @@ public struct Configuration {
/// The function argument is run when an SQLite connection is opened,
/// before the connection is made available for database access methods.
///
/// This method can be called several times. The preparation functions are
/// run in the same order.
///
/// For example:
///
/// var config = Configuration()
@@ -115,8 +118,21 @@ public struct Configuration {
/// try db.execute(sql: "PRAGMA kdf_iter = 10000")
/// }
///
/// This method can be called several times. The setup functions are run in
/// the same order.
/// When you use a `DatabasePool`, preparation functions are called for
/// the writer connection and all reader connections. You can distinguish
/// them by querying `db.configuration.readonly`:
///
/// var config = Configuration()
/// config.prepareDatabase { db in
/// if db.configuration.readonly {
/// // reader connection
/// } else {
/// // writer connection
/// }
/// }
///
/// On newly created databases, `DatabasePool` the WAL mode is activated
/// after the preparation functions have run.
public mutating func prepareDatabase(_ setup: @escaping (Database) throws -> Void) {
setups.append(setup)
}
@@ -159,11 +175,11 @@ public struct Configuration {
/// never allow leaving a transaction opened at the end of a read access.
///
/// Default: false
public var allowsUnsafeTransactions: Bool = false
public var allowsUnsafeTransactions = false
// MARK: - Concurrency
/// The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy
/// The behavior in case of SQLITE_BUSY error. See <https://www.sqlite.org/rescode.html#busy>
///
/// Default: immediateError
public var busyMode: Database.BusyMode = .immediateError
+147 -22
View File
@@ -9,38 +9,176 @@
//
//===----------------------------------------------------------------------===//
// MARK: - Array, Sequence, Dictionary, Set extensions
// MARK: - RangeReplaceableCollection, Sequence, Dictionary, Set extensions
extension Array {
/// Creates an array containing the elements of a cursor.
extension RangeReplaceableCollection {
/// Creates a collection containing the elements of a cursor.
///
/// let cursor = try String.fetchCursor(db, sql: "SELECT 'foo' UNION ALL SELECT 'bar'")
/// let strings = try Array(cursor) // ["foo", "bar"]
@inlinable
/// // [String]
/// let cursor = try String.fetchCursor(db, ...)
/// let strings = try Array(cursor)
///
/// - parameter cursor: The cursor whose elements feed the collection.
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
self.init()
while let element = try cursor.next() {
append(element)
}
}
/// Creates a collection containing the elements of a cursor.
///
/// // [String]
/// let cursor = try String.fetchCursor(db, ...)
/// let strings = try Array(cursor, minimumCapacity: 100)
///
/// - parameter cursor: The cursor whose elements feed the collection.
/// - parameter minimumCapacity: Prepares the returned collection to store
/// the specified number of elements.
public init<C: Cursor>(_ cursor: C, minimumCapacity: Int) throws where C.Element == Element {
self.init()
reserveCapacity(minimumCapacity)
while let element = try cursor.next() {
append(element)
}
}
}
extension Dictionary {
/// Creates a new dictionary whose keys are the groupings returned by the
/// given closure and whose values are arrays of the elements that returned
/// each key.
public init<C: Cursor>(grouping values: C, by keyForValue: (C.Element) throws -> Key)
///
/// // [Int64: [Player]]
/// let cursor = try Player.fetchCursor(db)
/// let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })
///
/// - parameter cursor: A cursor of values to group into a dictionary.
/// - parameter keyForValue: A closure that returns a key for each element
/// in the cursor.
public init<C: Cursor>(grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
throws where Value == [C.Element]
{
self.init()
while let value = try values.next() {
while let value = try cursor.next() {
try self[keyForValue(value), default: []].append(value)
}
}
/// Creates a new dictionary whose keys are the groupings returned by the
/// given closure and whose values are arrays of the elements that returned
/// each key.
///
/// // [Int64: [Player]]
/// let cursor = try Player.fetchCursor(db)
/// let dictionary = try Dictionary(
/// minimumCapacity: 100,
/// grouping: cursor,
/// by: { $0.teamID })
///
/// - parameter minimumCapacity: The minimum number of key-value pairs that
/// the newly created dictionary should be able to store without
/// reallocating its storage buffer.
/// - parameter cursor: A cursor of values to group into a dictionary.
/// - parameter keyForValue: A closure that returns a key for each element
/// in the cursor.
public init<C: Cursor>(minimumCapacity: Int, grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
throws where Value == [C.Element]
{
self.init(minimumCapacity: minimumCapacity)
while let value = try cursor.next() {
try self[keyForValue(value), default: []].append(value)
}
}
/// Creates a new dictionary from the key-value pairs in the given cursor.
///
/// You use this initializer to create a dictionary when you have a cursor
/// of key-value tuples with unique keys. Passing a cursor with duplicate
/// keys to this initializer results in a fatal error.
///
/// // [Int64: Player]
/// let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
/// let playerByID = try Dictionary(uniqueKeysWithValues: cursor)
///
/// - parameter keysAndValues: A cursor of key-value pairs to use for the
/// new dictionary. Every key in `keysAndValues` must be unique.
/// - precondition: The cursor must not have duplicate keys.
public init<C: Cursor>(uniqueKeysWithValues keysAndValues: C)
throws where C.Element == (Key, Value)
{
self.init()
while let (key, value) = try keysAndValues.next() {
if updateValue(value, forKey: key) != nil {
fatalError("Duplicate values for key: '\(String(describing: key))'")
}
}
}
/// Creates a new dictionary from the key-value pairs in the given cursor.
///
/// You use this initializer to create a dictionary when you have a cursor
/// of key-value tuples with unique keys. Passing a cursor with duplicate
/// keys to this initializer results in a fatal error.
///
/// // [Int64: Player]
/// let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
/// let playerByID = try Dictionary(
/// minimumCapacity: 100,
/// uniqueKeysWithValues: cursor)
///
/// - parameter minimumCapacity: The minimum number of key-value pairs that
/// the newly created dictionary should be able to store without
/// reallocating its storage buffer.
/// - parameter keysAndValues: A cursor of key-value pairs to use for the
/// new dictionary. Every key in `keysAndValues` must be unique.
/// - precondition: The cursor must not have duplicate keys.
public init<C: Cursor>(minimumCapacity: Int, uniqueKeysWithValues keysAndValues: C)
throws where C.Element == (Key, Value)
{
self.init(minimumCapacity: minimumCapacity)
while let (key, value) = try keysAndValues.next() {
if updateValue(value, forKey: key) != nil {
fatalError("Duplicate values for key: '\(String(describing: key))'")
}
}
}
}
extension Set {
/// Creates a set containing the elements of a cursor.
///
/// // Set<String>
/// let cursor = try String.fetchCursor(db, ...)
/// let strings = try Set(cursor)
///
/// - parameter cursor: A cursor of values to gather into a set.
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
self.init()
while let element = try cursor.next() {
insert(element)
}
}
/// Creates a set containing the elements of a cursor.
///
/// // Set<String>
/// let cursor = try String.fetchCursor(db, ...)
/// let strings = try Set(cursor, minimumCapacity: 100)
///
/// - parameter cursor: A cursor of values to gather into a set.
/// - parameter minimumCapacity: The minimum number of elements that the
/// newly created set should be able to store without reallocating its
/// storage buffer.
public init<C: Cursor>(_ cursor: C, minimumCapacity: Int) throws where C.Element == Element {
self.init(minimumCapacity: minimumCapacity)
while let element = try cursor.next() {
insert(element)
}
}
}
extension Sequence {
/// Returns a cursor over the concatenated results of mapping transform
/// over self.
public func flatMap<SegmentOfResult: Cursor>(
@@ -51,19 +189,6 @@ extension Sequence {
}
}
extension Set {
/// Creates a set containing the elements of a cursor.
///
/// let cursor = try String.fetchCursor(db, sql: "SELECT 'foo' UNION ALL SELECT 'foo'")
/// let strings = try Set(cursor) // ["foo"]
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
self.init()
while let element = try cursor.next() {
insert(element)
}
}
}
// MARK: - Cursor
/// A type that supplies the values of some external resource, one at a time.
+394 -81
View File
@@ -1,4 +1,51 @@
extension Database {
/// A SQLite schema. See <https://sqlite.org/lang_naming.html>
enum SchemaIdentifier: Hashable {
/// The main database
case main
/// The temp database
case temp
/// An attached database: <https://sqlite.org/lang_attach.html>
case attached(String)
/// The name of the schema in SQL queries
var sql: String {
switch self {
case .main: return "main"
case .temp: return "temp"
case let .attached(name): return name
}
}
/// The name of the master sqlite table
var masterTableName: String { // swiftlint:disable:this inclusive_language
switch self {
case .main: return "sqlite_master"
case .temp: return "sqlite_temp_master"
case let .attached(name): return "\(name).sqlite_master"
}
}
}
/// A table identifier
struct TableIdentifier {
/// The SQLite schema
var schemaID: SchemaIdentifier
/// The table name
var name: String
/// Returns the receiver, quoted for safe insertion as an identifier in
/// an SQL query.
///
/// // SELECT * FROM temp.player
/// db.execute(sql: "SELECT * FROM \(table.quotedDatabaseIdentifier)")
var quotedDatabaseIdentifier: String {
"\(schemaID.sql).\(name.quotedDatabaseIdentifier)"
}
}
// MARK: - Database Schema
@@ -10,8 +57,8 @@ extension Database {
SchedulingWatchdog.preconditionValidQueue(self)
schemaCache.clear()
// We also clear updateStatementCache and selectStatementCache despite
// the automatic statement recompilation (see https://www.sqlite.org/c3ref/prepare.html)
// We also clear statement cache despite the automatic statement
// recompilation (see https://www.sqlite.org/c3ref/prepare.html)
// because the automatic statement recompilation only happens a
// limited number of times.
internalStatementCache.clear()
@@ -21,23 +68,55 @@ extension Database {
/// Clears the database schema cache if the database schema has changed
/// since this method was last called.
func clearSchemaCacheIfNeeded() throws {
let schemaVersion = try Int32.fetchOne(internalCachedSelectStatement(sql: "PRAGMA schema_version"))
let schemaVersion = try Int32.fetchOne(internalCachedStatement(sql: "PRAGMA schema_version"))
if _lastSchemaVersion != schemaVersion {
_lastSchemaVersion = schemaVersion
clearSchemaCache()
}
}
/// Returns whether a table exists.
/// The list of database schemas, in the order of SQLite resolution:
/// temp, main, then attached databases.
func schemaIdentifiers() throws -> [SchemaIdentifier] {
if let schemaIdentifiers = schemaCache.schemaIdentifiers {
return schemaIdentifiers
}
var schemaIdentifiers = try Row
.fetchAll(self, sql: "PRAGMA database_list")
.map { row -> SchemaIdentifier in
switch row[1] as String {
case "main": return .main
case "temp": return .temp
case let other: return .attached(other)
}
}
// Temp schema shadows other schema: put it first
if let tempIdx = schemaIdentifiers.firstIndex(of: .temp) {
schemaIdentifiers.swapAt(tempIdx, 0)
}
schemaCache.schemaIdentifiers = schemaIdentifiers
return schemaIdentifiers
}
/// Returns whether a table exists in the main or temp schema.
public func tableExists(_ name: String) throws -> Bool {
try exists(type: .table, name: name)
try schemaIdentifiers().contains {
try exists(type: .table, name: name, in: $0)
}
}
private func tableExists(_ table: TableIdentifier) throws -> Bool {
try exists(type: .table, name: table.name, in: table.schemaID)
}
/// Returns whether a table is an internal SQLite table.
///
/// Those are tables whose name begins with `sqlite_` and `pragma_`.
///
/// For more information, see https://www.sqlite.org/fileformat2.html
/// For more information, see <https://www.sqlite.org/fileformat2.html>
public static func isSQLiteInternalTable(_ tableName: String) -> Bool {
// https://www.sqlite.org/fileformat2.html#internal_schema_objects
// > The names of internal schema objects always begin with "sqlite_"
@@ -52,7 +131,7 @@ extension Database {
///
/// Those are tables whose name begins with `sqlite_` and `pragma_`.
///
/// For more information, see https://www.sqlite.org/fileformat2.html
/// For more information, see <https://www.sqlite.org/fileformat2.html>
@available(*, deprecated, message: "Use Database.isSQLiteInternalTable(_:) static method instead.")
public func isSQLiteInternalTable(_ tableName: String) -> Bool {
Self.isSQLiteInternalTable(tableName)
@@ -73,21 +152,25 @@ extension Database {
Self.isGRDBInternalTable(tableName)
}
/// Returns whether a view exists.
/// Returns whether a view exists in the main or temp schema.
public func viewExists(_ name: String) throws -> Bool {
try exists(type: .view, name: name)
try schemaIdentifiers().contains {
try exists(type: .view, name: name, in: $0)
}
}
/// Returns whether a trigger exists.
/// Returns whether a trigger exists in the main or temp schema.
public func triggerExists(_ name: String) throws -> Bool {
try exists(type: .trigger, name: name)
try schemaIdentifiers().contains {
try exists(type: .trigger, name: name, in: $0)
}
}
private func exists(type: SchemaObjectType, name: String) throws -> Bool {
private func exists(type: SchemaObjectType, name: String, in schemaID: SchemaIdentifier) throws -> Bool {
// SQlite identifiers are case-insensitive, case-preserving:
// http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html
let name = name.lowercased()
return try schema()
return try schema(schemaID)
.names(ofType: type)
.contains { $0.lowercased() == name }
}
@@ -100,10 +183,20 @@ extension Database {
///
/// - throws: A DatabaseError if table does not exist.
public func primaryKey(_ tableName: String) throws -> PrimaryKeyInfo {
for schemaIdentifier in try schemaIdentifiers() {
if let result = try primaryKey(TableIdentifier(schemaID: schemaIdentifier, name: tableName)) {
return result
}
}
throw DatabaseError.noSuchTable(tableName)
}
/// Returns nil if table does not exist
private func primaryKey(_ table: TableIdentifier) throws -> PrimaryKeyInfo? {
SchedulingWatchdog.preconditionValidQueue(self)
if let primaryKey = schemaCache.primaryKey(tableName) {
return primaryKey
if let primaryKey = schemaCache[table.schemaID].primaryKey(table.name) {
return primaryKey.value
}
// https://www.sqlite.org/pragma.html
@@ -130,7 +223,11 @@ extension Database {
// 1 | name | TEXT | 0 | NULL | 0 |
// 2 | score | INTEGER | 0 | NULL | 0 |
let columns = try self.columns(in: tableName)
guard let columns = try self.columns(in: table) else {
// table does not exist
schemaCache[table.schemaID].set(primaryKey: .missing, forTable: table.name)
return nil
}
let primaryKey: PrimaryKeyInfo
let pkColumns = columns
@@ -168,14 +265,14 @@ extension Database {
if pkColumn.type.uppercased() == "INTEGER" {
primaryKey = .rowID(pkColumn.name)
} else {
primaryKey = try .regular([pkColumn.name], tableHasRowID: tableHasRowID(tableName))
primaryKey = try .regular([pkColumn.name], tableHasRowID: tableHasRowID(table))
}
default:
// Multi-columns primary key
primaryKey = try .regular(pkColumns.map(\.name), tableHasRowID: tableHasRowID(tableName))
primaryKey = try .regular(pkColumns.map(\.name), tableHasRowID: tableHasRowID(table))
}
schemaCache.set(primaryKey: primaryKey, forTable: tableName)
schemaCache[table.schemaID].set(primaryKey: .value(primaryKey), forTable: table.name)
return primaryKey
}
@@ -186,11 +283,21 @@ extension Database {
}
/// Returns whether the table has a rowid column.
private func tableHasRowID(_ tableName: String) throws -> Bool {
///
/// - precondition: table exists.
private func tableHasRowID(_ table: TableIdentifier) throws -> Bool {
// Not need to cache the result, because this information feeds
// `PrimaryKeyInfo`, which is cached.
do {
_ = try makeSelectStatement(sql: "SELECT rowid FROM \(tableName.quotedDatabaseIdentifier)")
// Use a distinctive alias so that we better understand in the
// future why this query appears in the error log.
// https://github.com/groue/GRDB.swift/issues/945#issuecomment-804896196
//
// TODO: find a way to know if a table is WITHOUT ROWID without
// generating an error.
_ = try makeStatement(sql: """
SELECT rowid AS checkWithoutRowidOptimization FROM \(table.quotedDatabaseIdentifier)
""")
return true
} catch DatabaseError.SQLITE_ERROR {
return false
@@ -207,21 +314,35 @@ extension Database {
///
/// If you want to know if a set of columns uniquely identify a row, prefer
/// `table(_:hasUniqueKey:)` instead.
///
/// - throws: A DatabaseError if table does not exist.
public func indexes(on tableName: String) throws -> [IndexInfo] {
if let indexes = schemaCache.indexes(on: tableName) {
return indexes
for schemaIdentifier in try schemaIdentifiers() {
if let result = try indexes(on: TableIdentifier(schemaID: schemaIdentifier, name: tableName)) {
return result
}
}
throw DatabaseError.noSuchTable(tableName)
}
/// Returns nil if table does not exist
private func indexes(on table: TableIdentifier) throws -> [IndexInfo]? {
if let indexes = schemaCache[table.schemaID].indexes(on: table.name) {
return indexes.value
}
let indexes = try Row
// [seq:0 name:"index" unique:0 origin:"c" partial:0]
.fetchAll(self, sql: "PRAGMA index_list(\(tableName.quotedDatabaseIdentifier))")
.fetchAll(self, sql: "PRAGMA \(table.schemaID.sql).index_list(\(table.name.quotedDatabaseIdentifier))")
.compactMap { row -> IndexInfo? in
let indexName: String = row[1]
let unique: Bool = row[2]
let indexInfoRows = try Row
// [seqno:0 cid:2 name:"column"]
.fetchAll(self, sql: "PRAGMA index_info(\(indexName.quotedDatabaseIdentifier))")
.fetchAll(self, sql: """
PRAGMA \(table.schemaID.sql).index_info(\(indexName.quotedDatabaseIdentifier))
""")
// Sort by rank
.sorted(by: { ($0[0] as Int) < ($1[0] as Int) })
var columns: [String] = []
@@ -243,12 +364,13 @@ extension Database {
if indexes.isEmpty {
// PRAGMA index_list doesn't throw any error when table does
// not exist. So let's check if table exists:
if try tableExists(tableName) == false {
throw DatabaseError(message: "no such table: \(tableName)")
if try tableExists(table) == false {
schemaCache[table.schemaID].set(indexes: .missing, forTable: table.name)
return nil
}
}
schemaCache.set(indexes: indexes, forTable: tableName)
schemaCache[table.schemaID].set(indexes: .value(indexes), forTable: table.name)
return indexes
}
@@ -264,16 +386,32 @@ extension Database {
}
/// The foreign keys defined on table named `tableName`.
///
/// - throws: A DatabaseError if table does not exist.
public func foreignKeys(on tableName: String) throws -> [ForeignKeyInfo] {
if let foreignKeys = schemaCache.foreignKeys(on: tableName) {
return foreignKeys
for schemaIdentifier in try schemaIdentifiers() {
if let result = try foreignKeys(on: TableIdentifier(schemaID: schemaIdentifier, name: tableName)) {
return result
}
}
throw DatabaseError.noSuchTable(tableName)
}
/// Returns nil if table does not exist
private func foreignKeys(on table: TableIdentifier) throws -> [ForeignKeyInfo]? {
if let foreignKeys = schemaCache[table.schemaID].foreignKeys(on: table.name) {
return foreignKeys.value
}
var rawForeignKeys: [(
id: Int,
destinationTable: String,
mapping: [(origin: String, destination: String?, seq: Int)])] = []
var previousId: Int? = nil
for row in try Row.fetchAll(self, sql: "PRAGMA foreign_key_list(\(tableName.quotedDatabaseIdentifier))") {
for row in try Row.fetchAll(self, sql: """
PRAGMA \(table.schemaID.sql).foreign_key_list(\(table.name.quotedDatabaseIdentifier))
""")
{
// row = [id:0 seq:0 table:"parents" from:"parentId" to:"id" on_update:"..." on_delete:"..." match:"..."]
let id: Int = row[0]
let seq: Int = row[1]
@@ -287,7 +425,7 @@ extension Database {
.append((origin: origin, destination: destination, seq: seq))
} else {
let mapping = [(origin: origin, destination: destination, seq: seq)]
rawForeignKeys.append((destinationTable: table, mapping: mapping))
rawForeignKeys.append((id: id, destinationTable: table, mapping: mapping))
previousId = id
}
}
@@ -295,12 +433,13 @@ extension Database {
if rawForeignKeys.isEmpty {
// PRAGMA foreign_key_list doesn't throw any error when table does
// not exist. So let's check if table exists:
if try tableExists(tableName) == false {
throw DatabaseError(message: "no such table: \(tableName)")
if try tableExists(table) == false {
schemaCache[table.schemaID].set(foreignKeys: .missing, forTable: table.name)
return nil
}
}
let foreignKeys = try rawForeignKeys.map { (destinationTable, columnMapping) -> ForeignKeyInfo in
let foreignKeys = try rawForeignKeys.map { (id, destinationTable, columnMapping) -> ForeignKeyInfo in
let orderedMapping = columnMapping
.sorted { $0.seq < $1.seq }
.map { (origin: $0.origin, destination: $0 .destination) }
@@ -316,39 +455,93 @@ extension Database {
(origin: origin, destination: destination!)
}
}
return ForeignKeyInfo(destinationTable: destinationTable, mapping: completeMapping)
return ForeignKeyInfo(id: id, destinationTable: destinationTable, mapping: completeMapping)
}
schemaCache.set(foreignKeys: foreignKeys, forTable: tableName)
schemaCache[table.schemaID].set(foreignKeys: .value(foreignKeys), forTable: table.name)
return foreignKeys
}
/// Returns the actual name of the database table
func canonicalTableName(_ tableName: String) throws -> String {
guard let name = try schema().canonicalName(tableName, ofType: .table) else {
throw DatabaseError(message: "no such table: \(tableName)")
}
return name
/// Returns a cursor over foreign key violations in the database.
public func foreignKeyViolations() throws -> RecordCursor<ForeignKeyViolation> {
try ForeignKeyViolation.fetchCursor(self, sql: "PRAGMA foreign_key_check")
}
func schema() throws -> SchemaInfo {
if let schemaInfo = schemaCache.schemaInfo {
/// Returns a cursor over foreign key violations in the table.
public func foreignKeyViolations(in tableName: String) throws -> RecordCursor<ForeignKeyViolation> {
for schemaIdentifier in try schemaIdentifiers() {
if try exists(type: .table, name: tableName, in: schemaIdentifier) {
return try foreignKeyViolations(in: TableIdentifier(schemaID: schemaIdentifier, name: tableName))
}
}
throw DatabaseError.noSuchTable(tableName)
}
/// Throws a DatabaseError of extended code `SQLITE_CONSTRAINT_FOREIGNKEY`
/// if there exists a foreign key violation in the database.
public func checkForeignKeys() throws {
try checkForeignKeys(from: foreignKeyViolations())
}
/// Throws a DatabaseError of extended code `SQLITE_CONSTRAINT_FOREIGNKEY`
/// if there exists a foreign key violation in the table.
public func checkForeignKeys(in tableName: String) throws {
try checkForeignKeys(from: foreignKeyViolations(in: tableName))
}
private func foreignKeyViolations(in table: TableIdentifier) throws -> RecordCursor<ForeignKeyViolation> {
try ForeignKeyViolation.fetchCursor(self, sql: """
PRAGMA \(table.schemaID.sql).foreign_key_check(\(table.name.quotedDatabaseIdentifier))
""")
}
private func checkForeignKeys(from violations: RecordCursor<ForeignKeyViolation>) throws {
if let violation = try violations.next() {
throw violation.databaseError(self)
}
}
/// Returns the actual name of the database table, in the main or temp
/// schema, or nil if the table does not exist.
///
/// - throws: A DatabaseError if table does not exist.
func canonicalTableName(_ tableName: String) throws -> String? {
for schemaIdentifier in try schemaIdentifiers() {
if let result = try schema(schemaIdentifier).canonicalName(tableName, ofType: .table) {
return result
}
}
return nil
}
func schema(_ schemaID: SchemaIdentifier) throws -> SchemaInfo {
if let schemaInfo = schemaCache[schemaID].schemaInfo {
return schemaInfo
}
let schemaInfo = try SchemaInfo(self)
schemaCache.schemaInfo = schemaInfo
let schemaInfo = try SchemaInfo(self, masterTableName: schemaID.masterTableName)
schemaCache[schemaID].schemaInfo = schemaInfo
return schemaInfo
}
}
extension Database {
/// The columns in the table named `tableName`
/// The columns in the table named `tableName`.
///
/// - throws: A DatabaseError if table does not exist.
public func columns(in tableName: String) throws -> [ColumnInfo] {
if let columns = schemaCache.columns(in: tableName) {
return columns
for schemaIdentifier in try schemaIdentifiers() {
if let result = try columns(in: TableIdentifier(schemaID: schemaIdentifier, name: tableName)) {
return result
}
}
throw DatabaseError.noSuchTable(tableName)
}
/// Returns nil if table does not exist
private func columns(in table: TableIdentifier) throws -> [ColumnInfo]? {
if let columns = schemaCache[table.schemaID].columns(in: table.name) {
return columns.value
}
// https://www.sqlite.org/pragma.html
@@ -396,27 +589,35 @@ extension Database {
if sqlite3_libversion_number() < 3008005 {
// Work around a bug in SQLite where PRAGMA table_info would
// return a result even after the table was deleted.
if try !tableExists(tableName) {
throw DatabaseError(message: "no such table: \(tableName)")
if try !tableExists(table) {
schemaCache[table.schemaID].set(columns: .missing, forTable: table.name)
return nil
}
}
columnInfoQuery = "PRAGMA table_info(\(tableName.quotedDatabaseIdentifier))"
columnInfoQuery = "PRAGMA \(table.schemaID.sql).table_info(\(table.name.quotedDatabaseIdentifier))"
} else {
// For our purposes, we look for generated columns, not hidden
// columns. The "hidden" column magic numbers come from the SQLite
// source code. The values 2 and 3 refer to virtual and stored
// generated columns, respectively. Search for COLFLAG_VIRTUAL in
// https://www.sqlite.org/cgi/src/file?name=src/pragma.c&ci=fca8dc8b578f215a
columnInfoQuery = "SELECT * FROM pragma_table_xinfo('\(tableName)') WHERE hidden IN (0,2,3)"
// Use PRAGMA table_xinfo so that we can load generated columns
columnInfoQuery = "PRAGMA \(table.schemaID.sql).table_xinfo(\(table.name.quotedDatabaseIdentifier))"
}
let columns = try ColumnInfo
.fetchAll(self, sql: columnInfoQuery)
.filter {
// Purpose: keep generated columns, but discard hidden ones.
// The "hidden" column magic numbers come from the SQLite
// source code. The values 2 and 3 refer to virtual and stored
// generated columns, respectively, and 1 refer to hidden one.
// Search for COLFLAG_HIDDEN in
// https://www.sqlite.org/cgi/src/file?name=src/pragma.c&ci=fca8dc8b578f215a
$0.hidden != 1
}
.sorted(by: { $0.cid < $1.cid })
if columns.isEmpty {
throw DatabaseError(message: "no such table: \(tableName)")
// Table does not exist
schemaCache[table.schemaID].set(columns: .missing, forTable: table.name)
return nil
}
schemaCache.set(columns: columns, forTable: tableName)
schemaCache[table.schemaID].set(columns: .value(columns), forTable: table.name)
return columns
}
@@ -461,22 +662,29 @@ extension Database {
/// A column of a database table.
///
/// This type closely matches the information returned by the
/// `table_info` pragma.
/// `table_info` and `table_xinfo` pragmas.
///
/// > CREATE TABLE player (
/// id INTEGER PRIMARY KEY,
/// firstName TEXT,
/// lastName TEXT)
/// > PRAGMA table_info("player")
/// cid name type notnull dflt_value pk
/// ---- ----- ------- -------- ---------- ---
/// 0 id INTEGER 0 NULL 1
/// 1 name TEXT 0 NULL 0
/// 2 score INTEGER 0 NULL 0
/// sqlite> CREATE TABLE player (
/// ...> id INTEGER PRIMARY KEY,
/// ...> firstName TEXT,
/// ...> lastName TEXT);
/// sqlite> PRAGMA table_info(player);
/// cid name type notnull dflt_value pk
/// ------ ---------- ---------- ---------- ---------- -----
/// 0 id INTEGER 0 1
/// 1 firstName TEXT 0 0
/// 2 lastName TEXT 0 0
/// sqlite> PRAGMA table_xinfo(player);
/// cid name type notnull dflt_value pk hidden
/// ------ ---------- ---------- ---------- ---------- ----- ----------
/// 0 id INTEGER 0 1 0
/// 1 firstName TEXT 0 0 0
/// 2 lastName TEXT 0 0 0
///
/// See `Database.columns(in:)` and https://www.sqlite.org/pragma.html#pragma_table_info
/// See `Database.columns(in:)` and <https://www.sqlite.org/pragma.html#pragma_table_info>
public struct ColumnInfo: FetchableRecord {
let cid: Int
let hidden: Int?
/// The column name
public let name: String
@@ -521,8 +729,8 @@ public struct ColumnInfo: FetchableRecord {
/// the primary key for columns that are part of the primary key.
///
/// References:
/// - https://sqlite.org/releaselog/3_7_16.html
/// - http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/2013-April/046034.html
/// - <https://sqlite.org/releaselog/3_7_16.html>
/// - <http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/2013-April/046034.html>
public let primaryKeyIndex: Int
/// :nodoc:
@@ -533,6 +741,7 @@ public struct ColumnInfo: FetchableRecord {
isNotNull = row["notnull"]
defaultValueSQL = row["dflt_value"]
primaryKeyIndex = row["pk"]
hidden = row["hidden"]
}
}
@@ -556,6 +765,89 @@ public struct IndexInfo {
}
}
/// A foreign key violation produced by PRAGMA foreign_key_check
///
/// See <https://www.sqlite.org/pragma.html#pragma_foreign_key_check>
public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
/// The name of the table that contains the `REFERENCES` clause
public var originTable: String
/// The rowid of the row that contains the invalid `REFERENCES` clause, or
/// nil if the origin table is a `WITHOUT ROWID` table.
public var originRowID: Int64?
/// The name of the table that is referred to.
public var destinationTable: String
/// The id of the specific foreign key constraint that failed. This id
/// matches `ForeignKeyInfo.id`. See `Database.foreignKeys(on:)` for more
/// information.
public var foreignKeyId: Int
public init(row: Row) {
originTable = row[0]
originRowID = row[1]
destinationTable = row[2]
foreignKeyId = row[3]
}
public var description: String {
if let originRowID = originRowID {
return """
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable), \
in rowid \(originRowID)
"""
} else {
return """
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable)
"""
}
}
/// Returns a precise description of the foreign key violation.
///
/// For example: 'FOREIGN KEY constraint violation - from player(teamId) to team(id),
/// in [id:1 teamId:2 name:"O'Brien" score: 1000]'
public func failureDescription(_ db: Database) throws -> String {
// Grab detailed information, if possible, for better error message
let originRow = try originRowID.flatMap { rowid in
try Row.fetchOne(db, sql: "SELECT * FROM \(originTable.quotedDatabaseIdentifier) WHERE rowid = \(rowid)")
}
let foreignKey = try db.foreignKeys(on: originTable).first(where: { foreignKey in
foreignKey.id == foreignKeyId
})
var description: String
if let foreignKey = foreignKey {
description = """
FOREIGN KEY constraint violation - \
from \(originTable)(\(foreignKey.originColumns.joined(separator: ", "))) \
to \(destinationTable)(\(foreignKey.destinationColumns.joined(separator: ", ")))
"""
} else {
description = "FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable)"
}
if let originRow = originRow {
description += ", in \(String(describing: originRow))"
} else if let originRowID = originRowID {
description += ", in rowid \(originRowID)"
}
return description
}
/// Returns a DatabaseError of extended code `SQLITE_CONSTRAINT_FOREIGNKEY`
public func databaseError(_ db: Database) -> DatabaseError {
// Grab detailed information, if possible, for better error message.
// If detailed information is not available, fallback to plain description.
let message = (try? failureDescription(db)) ?? String(describing: self)
return DatabaseError(
resultCode: .SQLITE_CONSTRAINT_FOREIGNKEY,
message: message)
}
}
/// Primary keys are returned from the Database.primaryKey(_:) method.
///
/// When the table's primary key is the rowid:
@@ -669,11 +961,32 @@ public struct PrimaryKeyInfo {
return tableHasRowID
}
}
/// The name of the fastest primary key column
///
/// Returns nil for WITHOUT ROWID tables with a multi-columns primary key
var fastPrimaryKeyColumn: String? {
if let rowIDColumn = rowIDColumn {
// Prefer the user-provided name of the rowid
return rowIDColumn
} else if tableHasRowID {
// Prefer the rowid
return Column.rowID.name
} else if columns.count == 1 {
// WITHOUT ROWID table: use primary key column
return columns[0]
} else {
return nil
}
}
}
/// You get foreign keys from table names, with the
/// `foreignKeys(on:)` method.
public struct ForeignKeyInfo {
/// The first column in the output of the `foreign_key_list` pragma
public var id: Int
/// The name of the destination table
public let destinationTable: String
@@ -701,11 +1014,10 @@ enum SchemaObjectType: String {
struct SchemaInfo: Equatable {
private var objects: Set<SchemaObject>
init(_ db: Database) throws {
/// - parameter masterTable: "sqlite_master" or "sqlite_temp_master"
init(_ db: Database, masterTableName: String) throws { // swiftlint:disable:this inclusive_language
objects = try Set(SchemaObject.fetchCursor(db, sql: """
SELECT type, name, tbl_name, sql, 0 AS isTemporary FROM sqlite_master \
UNION \
SELECT type, name, tbl_name, sql, 1 FROM sqlite_temp_master
SELECT type, name, tbl_name, sql FROM \(masterTableName)
"""))
}
@@ -724,7 +1036,9 @@ struct SchemaInfo: Equatable {
/// try db.schema().canonicalName("foobar", ofType: .table) // "FooBar"
func canonicalName(_ name: String, ofType type: SchemaObjectType) -> String? {
let name = name.lowercased()
return objects.first { $0.name.lowercased() == name }?.name
return objects
.first { $0.type == type.rawValue && $0.name.lowercased() == name }?
.name
}
private struct SchemaObject: Codable, Hashable, FetchableRecord {
@@ -732,6 +1046,5 @@ struct SchemaInfo: Equatable {
var name: String
var tbl_name: String?
var sql: String?
var isTemporary: Bool
}
}
+475 -189
View File
@@ -4,6 +4,62 @@ extension Database {
// MARK: - Statements
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeStatement(sql: "SELECT * FROM player WHERE id = ?")
/// let player1 = try Player.fetchOne(statement, arguments: [1])!
/// let player2 = try Player.fetchOne(statement, arguments: [2])!
///
/// let statement = try db.makeStatement(sql: "INSERT INTO player (name) VALUES (?)")
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
///
/// - parameter sql: An SQL query.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func makeStatement(sql: String) throws -> Statement {
try makeStatement(sql: sql, prepFlags: 0)
}
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeStatement(literal: "SELECT * FROM player WHERE id = ?")
/// let player1 = try Player.fetchOne(statement, arguments: [1])!
/// let player2 = try Player.fetchOne(statement, arguments: [2])!
///
/// let statement = try db.makeStatement(literal: "INSERT INTO player (name) VALUES (?)")
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
///
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try makeStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > ?
/// """)
/// try makeStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > \(1000)
/// """)
///
/// // NOT OK
/// try makeStatement(literal: """
/// SELECT COUNT(*) FROM player
/// WHERE color = ? AND score > \(1000)
/// """)
public func makeStatement(literal sqlLiteral: SQL) throws -> Statement {
let (sql, arguments) = try sqlLiteral.build(self)
let statement = try makeStatement(sql: sql)
if arguments.isEmpty == false {
// Throws if arguments do not match
try statement.setArguments(arguments)
}
return statement
}
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT * FROM player WHERE id = ?")
@@ -11,25 +67,139 @@ extension Database {
/// let player2 = try Player.fetchOne(statement, arguments: [2])!
///
/// - parameter sql: An SQL query.
/// - returns: A SelectStatement.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func makeSelectStatement(sql: String) throws -> SelectStatement {
try makeSelectStatement(sql: sql, prepFlags: 0)
@available(*, deprecated, renamed: "makeStatement(sql:)")
public func makeSelectStatement(sql: String) throws -> Statement {
try makeStatement(sql: sql)
}
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT COUNT(*) FROM player WHERE score > ?", prepFlags: 0)
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try makeSelectStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > ?
/// """)
/// try makeSelectStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > \(1000)
/// """)
///
/// // NOT OK
/// try makeSelectStatement(literal: """
/// SELECT COUNT(*) FROM player
/// WHERE color = ? AND score > \(1000)
/// """)
@available(*, deprecated, renamed: "makeStatement(literal:)")
public func makeSelectStatement(literal sqlLiteral: SQL) throws -> Statement {
try makeStatement(literal: sqlLiteral)
}
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeStatement(sql: "SELECT COUNT(*) FROM player WHERE score > ?", prepFlags: 0)
/// let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])!
/// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
///
/// - parameter sql: An SQL query.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
/// - returns: A SelectStatement.
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
func makeSelectStatement(sql: String, prepFlags: Int32) throws -> SelectStatement {
try SelectStatement.prepare(self, sql: sql, prepFlags: prepFlags)
func makeStatement(sql: String, prepFlags: Int32) throws -> Statement {
let statements = SQLStatementCursor(database: self, sql: sql, arguments: nil, prepFlags: prepFlags)
guard let statement = try statements.next() else {
throw DatabaseError(
resultCode: .SQLITE_ERROR,
message: "empty statement",
sql: sql)
}
do {
guard try statements.next() == nil else {
throw DatabaseError(
resultCode: .SQLITE_MISUSE,
message: """
Multiple statements found. To execute multiple statements, use \
Database.execute(sql:) or Database.allStatements(sql:) instead.
""",
sql: sql)
}
} catch {
// Something while would not compile was found after the first statement.
// Complain about multiple statements anyway.
throw DatabaseError(
resultCode: .SQLITE_MISUSE,
message: """
Multiple statements found. To execute multiple statements, use \
Database.execute(sql:) or Database.allStatements(sql:) instead.
""",
sql: sql)
}
return statement
}
/// Returns a prepared statement that can be reused.
///
/// let statement = try db.cachedStatement(sql: "SELECT * FROM player WHERE id = ?")
/// let player1 = try Player.fetchOne(statement, arguments: [1])!
/// let player2 = try Player.fetchOne(statement, arguments: [2])!
///
/// let statement = try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
///
/// The returned statement may have already been used: it may or may not
/// contain values for its eventual arguments.
///
/// - parameter sql: An SQL query.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func cachedStatement(sql: String) throws -> Statement {
try publicStatementCache.statement(sql)
}
/// Returns a prepared statement that can be reused.
///
/// let statement = try db.cachedStatement(literal: "SELECT * FROM player WHERE id = ?")
/// let player1 = try Player.fetchOne(statement, arguments: [1])!
/// let player2 = try Player.fetchOne(statement, arguments: [2])!
///
/// let statement = try db.cachedStatement(literal: "INSERT INTO player (name) VALUES (?)")
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
///
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try cachedStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > ?
/// """)
/// try cachedStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > \(1000)
/// """)
///
/// // NOT OK
/// try cachedStatement(literal: """
/// SELECT COUNT(*) FROM player
/// WHERE color = ? AND score > \(1000)
/// """)
public func cachedStatement(literal sqlLiteral: SQL) throws -> Statement {
let (sql, arguments) = try sqlLiteral.build(self)
let statement = try cachedStatement(sql: sql)
if arguments.isEmpty == false {
// Throws if arguments do not match
try statement.setArguments(arguments)
}
return statement
}
/// Returns a prepared statement that can be reused.
@@ -42,15 +212,45 @@ extension Database {
/// contain values for its eventual arguments.
///
/// - parameter sql: An SQL query.
/// - returns: An UpdateStatement.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func cachedSelectStatement(sql: String) throws -> SelectStatement {
try publicStatementCache.selectStatement(sql)
@available(*, deprecated, renamed: "cachedStatement(sql:)")
public func cachedSelectStatement(sql: String) throws -> Statement {
try cachedStatement(sql: sql)
}
/// Returns a prepared statement that can be reused.
///
/// let statement = try db.cachedSelectStatement(literal: "SELECT COUNT(*) FROM player WHERE score > \(20)")
/// let moreThanTwentyCount = try Int.fetchOne(statement)!
///
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try cachedSelectStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > ?
/// """)
/// try cachedSelectStatement(literal: """
/// SELECT COUNT(*) FROM player WHERE score > \(1000)
/// """)
///
/// // NOT OK
/// try cachedSelectStatement(literal: """
/// SELECT COUNT(*) FROM player
/// WHERE color = ? AND score > \(1000)
/// """)
@available(*, deprecated, renamed: "cachedStatement(literal:)")
public func cachedSelectStatement(literal sqlLiteral: SQL) throws -> Statement {
try cachedStatement(literal: sqlLiteral)
}
/// Returns a cached statement that does not conflict with user's cached statements.
func internalCachedSelectStatement(sql: String) throws -> SelectStatement {
try internalStatementCache.selectStatement(sql)
func internalCachedStatement(sql: String) throws -> Statement {
try internalStatementCache.statement(sql)
}
/// Returns a new prepared statement that can be reused.
@@ -62,23 +262,34 @@ extension Database {
/// - parameter sql: An SQL query.
/// - returns: An UpdateStatement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func makeUpdateStatement(sql: String) throws -> UpdateStatement {
try makeUpdateStatement(sql: sql, prepFlags: 0)
@available(*, deprecated, renamed: "makeStatement(sql:)")
public func makeUpdateStatement(sql: String) throws -> Statement {
try makeStatement(sql: sql)
}
/// Returns a new prepared statement that can be reused.
///
/// let statement = try db.makeUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)", prepFlags: 0)
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
///
/// - parameter sql: An SQL query.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
/// - returns: An UpdateStatement.
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
func makeUpdateStatement(sql: String, prepFlags: Int32) throws -> UpdateStatement {
try UpdateStatement.prepare(self, sql: sql, prepFlags: prepFlags)
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try makeUpdateStatement(literal: """
/// UPDATE player SET name = ?
/// """)
/// try makeUpdateStatement(literal: """
/// UPDATE player SET name = \("O'Brien")
/// """)
///
/// // NOT OK
/// try makeUpdateStatement(literal: """
/// UPDATE player SET name = ?, score = \(10)
/// """)
@available(*, deprecated, renamed: "makeStatement(literal:)")
public func makeUpdateStatement(literal sqlLiteral: SQL) throws -> Statement {
try makeStatement(literal: sqlLiteral)
}
/// Returns a prepared statement that can be reused.
@@ -91,15 +302,120 @@ extension Database {
/// contain values for its eventual arguments.
///
/// - parameter sql: An SQL query.
/// - returns: An UpdateStatement.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
public func cachedUpdateStatement(sql: String) throws -> UpdateStatement {
try publicStatementCache.updateStatement(sql)
@available(*, deprecated, renamed: "cachedStatement(sql:)")
public func cachedUpdateStatement(sql: String) throws -> Statement {
try cachedStatement(sql: sql)
}
/// Returns a cached statement that does not conflict with user's cached statements.
func internalCachedUpdateStatement(sql: String) throws -> UpdateStatement {
try internalStatementCache.updateStatement(sql)
/// Returns a new prepared statement that can be reused.
///
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A Statement.
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
/// - precondition: No argument must be set, or all arguments must be set.
/// An error is raised otherwise.
///
/// // OK
/// try cachedUpdateStatement(literal: """
/// UPDATE player SET name = ?
/// """)
/// try cachedUpdateStatement(literal: """
/// UPDATE player SET name = \("O'Brien")
/// """)
///
/// // NOT OK
/// try cachedUpdateStatement(literal: """
/// UPDATE player SET name = ?, score = \(10)
/// """)
@available(*, deprecated, renamed: "cachedStatement(sql:)")
public func cachedUpdateStatement(literal sqlLiteral: SQL) throws -> Statement {
try cachedStatement(literal: sqlLiteral)
}
/// Returns a cursor of all SQL statements separated by semi-colons.
///
/// let statements = try db.allStatements(sql: """
/// INSERT INTO player (name) VALUES (?);
/// INSERT INTO player (name) VALUES (?);
/// INSERT INTO player (name) VALUES (?);
/// """, arguments: ["Arthur", "Barbara", "O'Brien"])
/// while let statement = try statements.next() {
/// try statement.execute()
/// }
///
/// - parameters:
/// - sql: An SQL query.
/// - arguments: Statement arguments.
/// - returns: A cursor of `Statement`
/// - throws: A DatabaseError whenever an SQLite error occurs.
/// - precondition: Arguments must be nil, or all arguments must be set.
/// The returned cursor will throw an error otherwise.
///
/// // OK
/// try allStatements(sql: """
/// SELECT COUNT(*) FROM player WHERE score < ?;
/// SELECT COUNT(*) FROM player WHERE score > ?;
/// """)
/// try allStatements(sql: """
/// SELECT COUNT(*) FROM player WHERE score < ?;
/// SELECT COUNT(*) FROM player WHERE score > ?;
/// """, arguments: [1000, 1000])
///
/// // NOT OK
/// try allStatements(sql: """
/// SELECT COUNT(*) FROM player WHERE score < ?;
/// SELECT COUNT(*) FROM player WHERE score > ?;
/// """, arguments: [1000])
public func allStatements(sql: String, arguments: StatementArguments? = nil)
throws -> SQLStatementCursor
{
SQLStatementCursor(database: self, sql: sql, arguments: arguments)
}
/// Returns a cursor of all SQL statements separated by semi-colons.
///
/// Literals allow you to safely embed raw values in your SQL, without any
/// risk of syntax errors or SQL injection:
///
/// let statements = try db.allStatements(literal: """
/// INSERT INTO player (name) VALUES (\("Arthur"));
/// INSERT INTO player (name) VALUES (\("Barbara"));
/// INSERT INTO player (name) VALUES (\("O'Brien"));
/// """)
/// while let statement = try statements.next() {
/// try statement.execute()
/// }
///
/// - parameter sqlLiteral: An `SQL` literal.
/// - returns: A cursor of `Statement`
/// - throws: A DatabaseError whenever an SQLite error occurs.
/// - precondition: No argument must be set, or all arguments must be set.
/// The returned cursor will throw an error otherwise.
///
/// // OK
/// try allStatements(literal: """
/// SELECT COUNT(*) FROM player WHERE score < ?;
/// SELECT COUNT(*) FROM player WHERE score > ?;
/// """)
/// try allStatements(literal: """
/// SELECT COUNT(*) FROM player WHERE score < \(1000);
/// SELECT COUNT(*) FROM player WHERE score > \(1000);
/// """)
///
/// // NOT OK
/// try allStatements(literal: """
/// SELECT COUNT(*) FROM player WHERE score < \(1000);
/// SELECT COUNT(*) FROM player WHERE score > ?;
/// """)
public func allStatements(literal sqlLiteral: SQL) throws -> SQLStatementCursor {
let context = SQLGenerationContext(self)
let sql = try sqlLiteral.sql(context)
let arguments = context.arguments.isEmpty
? nil // builds statements without arguments
: context.arguments // force arguments to match
return SQLStatementCursor(database: self, sql: sql, arguments: arguments)
}
/// Executes one or several SQL statements, separated by semi-colons.
@@ -121,23 +437,17 @@ extension Database {
/// - arguments: Statement arguments.
/// - throws: A DatabaseError whenever an SQLite error occurs.
public func execute(sql: String, arguments: StatementArguments = StatementArguments()) throws {
try execute(literal: SQLLiteral(sql: sql, arguments: arguments))
try execute(literal: SQL(sql: sql, arguments: arguments))
}
/// Executes one or several SQL statements, separated by semi-colons.
///
/// try db.execute(literal: SQLLiteral(
/// sql: "INSERT INTO player (name) VALUES (:name)",
/// arguments: ["name": "Arthur"]))
/// Literals allow you to safely embed raw values in your SQL, without any
/// risk of syntax errors or SQL injection:
///
/// try db.execute(literal: SQLLiteral(sql: """
/// INSERT INTO player (name) VALUES (?);
/// INSERT INTO player (name) VALUES (?);
/// INSERT INTO player (name) VALUES (?);
/// """, arguments: ["Arthur", "Barbara", "O'Brien"]))
///
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
/// try db.execute(literal: """
/// INSERT INTO player (name) VALUES (\("Arthur"))
/// """)
///
/// try db.execute(literal: """
/// INSERT INTO player (name) VALUES (\("Arthur"));
@@ -147,86 +457,95 @@ extension Database {
///
/// This method may throw a DatabaseError.
///
/// - parameter sqlLiteral: An SQLLiteral.
/// - parameter sqlLiteral: An `SQL` literal.
/// - throws: A DatabaseError whenever an SQLite error occurs.
public func execute(literal sqlLiteral: SQLLiteral) throws {
// This method is like sqlite3_exec (https://www.sqlite.org/c3ref/exec.html)
// It adds support for arguments, and the tricky part is to consume
// arguments as statements are executed.
//
// This job is performed by StatementArguments.extractBindings(forStatement:allowingRemainingValues:)
//
// And before we return, we'll check that all arguments were consumed.
let context = SQLGenerationContext(self)
let sql = try sqlLiteral.sql(context)
var arguments = context.arguments
let initialValuesCount = arguments.values.count
// Build a C string (SQLite wants that), and execute SQL statements one
// after the other.
try sql.utf8CString.withUnsafeBufferPointer { buffer in
guard let sqlStart = buffer.baseAddress else { return }
let sqlEnd = sqlStart + buffer.count // past \0
var statementStart = sqlStart
while statementStart < sqlEnd {
var statementEnd: UnsafePointer<Int8>? = nil
let nextStatement: UpdateStatement?
// Compile
do {
let authorizer = StatementCompilationAuthorizer()
nextStatement = try withAuthorizer(authorizer) {
try UpdateStatement(
database: self,
statementStart: statementStart,
statementEnd: &statementEnd,
prepFlags: 0,
authorizer: authorizer)
}
}
guard let statement = nextStatement else {
// End of SQL string
break
}
// Extract statement arguments
let bindings = try arguments.extractBindings(forStatement: statement, allowingRemainingValues: true)
// unsafe is OK because we just extracted the correct number of arguments
statement.setUncheckedArguments(StatementArguments(bindings))
// Execute
try statement.execute()
// Next
statementStart = statementEnd!
}
public func execute(literal sqlLiteral: SQL) throws {
let statements = try allStatements(literal: sqlLiteral)
while let statement = try statements.next() {
try statement.execute()
}
}
}
public class SQLStatementCursor: Cursor {
private let database: Database
private let cString: ContiguousArray<CChar>
private let prepFlags: CInt
private let initialArgumentCount: Int?
// Mutated by iteration
private var offset: Int // offset in the C string
private var arguments: StatementArguments? // Nil when arguments are set later
init(database: Database, sql: String, arguments: StatementArguments?, prepFlags: CInt = 0) {
self.database = database
self.cString = sql.utf8CString
self.prepFlags = prepFlags
self.initialArgumentCount = arguments?.values.count
self.offset = 0
self.arguments = arguments
}
public func next() throws -> Statement? {
guard offset < cString.count - 1 /* trailing \0 */ else {
try checkArgumentsAreEmpty()
return nil
}
// Check that all arguments were consumed: it is a programmer error to
// provide arguments that do not match the statement.
if arguments.values.isEmpty == false {
return try cString.withUnsafeBufferPointer { buffer in
guard let baseAddress = buffer.baseAddress else {
// Should never happen since buffer contains at least
// the trailing \0
return nil
}
var statementEnd: UnsafePointer<Int8>? = nil
let compiledStatement = try Statement(
database: database,
statementStart: baseAddress + offset,
statementEnd: &statementEnd,
prepFlags: prepFlags)
offset = statementEnd! - baseAddress
guard let statement = compiledStatement else {
try checkArgumentsAreEmpty()
return nil
}
if arguments != nil {
// Extract statement arguments
let bindings = try arguments!.extractBindings(
forStatement: statement,
allowingRemainingValues: true)
// unchecked is OK because we just extracted the correct
// number of arguments
statement.setUncheckedArguments(StatementArguments(bindings))
}
return statement
}
}
/// Check that all arguments were consumed: it is a programmer error to
/// provide arguments that do not match the statements.
private func checkArgumentsAreEmpty() throws {
if let arguments = arguments,
let initialArgumentCount = initialArgumentCount,
arguments.values.isEmpty == false
{
throw DatabaseError(
resultCode: .SQLITE_MISUSE,
message: "wrong number of statement arguments: \(initialValuesCount)")
message: "wrong number of statement arguments: \(initialArgumentCount)")
}
}
}
extension Database {
func executeUpdateStatement(_ statement: UpdateStatement) throws {
// Two things must prevent the statement from executing: aborted
// transactions, and database suspension.
try checkForAbortedTransaction(sql: statement.sql, arguments: statement.arguments)
try checkForSuspensionViolation(from: statement)
if _isRecordingSelectedRegion {
_selectedRegion.formUnion(statement.databaseRegion)
}
let authorizer = observationBroker.updateStatementWillExecute(statement)
func executeStatement(_ statement: Statement) throws {
let authorizer = try statementWillExecute(statement)
let sqliteStatement = statement.sqliteStatement
var code: Int32 = SQLITE_OK
withAuthorizer(authorizer) {
while true {
@@ -259,40 +578,18 @@ extension Database {
// We can now move on further tasks.
if code == SQLITE_DONE {
try updateStatementDidExecute(statement)
try statementDidExecute(statement)
} else {
assert(code != SQLITE_ROW)
try updateStatementDidFail(statement)
throw DatabaseError(
resultCode: code,
message: lastErrorMessage,
sql: statement.sql,
arguments: statement.arguments)
try statementDidFail(statement, withResultCode: code)
}
}
private func updateStatementDidExecute(_ statement: UpdateStatement) throws {
if statement.invalidatesDatabaseSchemaCache {
clearSchemaCache()
}
try observationBroker.updateStatementDidExecute(statement)
}
private func updateStatementDidFail(_ statement: UpdateStatement) throws {
// Failed statements can not be reused, because sqlite3_reset won't
// be able to restore the statement to its initial state:
// https://www.sqlite.org/c3ref/reset.html
//
// So make sure we clear this statement from the cache.
internalStatementCache.remove(statement)
publicStatementCache.remove(statement)
try observationBroker.updateStatementDidFail(statement)
}
@inline(__always)
func selectStatementWillExecute(_ statement: SelectStatement) throws {
/// Returns the authorizer that should be used during statement execution
/// (this allows preventing the truncate optimization when there exists a
/// transaction observer for row deletion).
@usableFromInline
func statementWillExecute(_ statement: Statement) throws -> StatementAuthorizer? {
// Two things must prevent the statement from executing: aborted
// transactions, and database suspension.
try checkForAbortedTransaction(sql: statement.sql, arguments: statement.arguments)
@@ -301,9 +598,24 @@ extension Database {
if _isRecordingSelectedRegion {
_selectedRegion.formUnion(statement.databaseRegion)
}
return observationBroker.statementWillExecute(statement)
}
func selectStatementDidFail(_ statement: SelectStatement) {
/// May throw a cancelled commit error, if a transaction observer cancels
/// an empty transaction.
@usableFromInline
func statementDidExecute(_ statement: Statement) throws {
if statement.invalidatesDatabaseSchemaCache {
clearSchemaCache()
}
try observationBroker.statementDidExecute(statement)
}
/// Always throws an error
@usableFromInline
func statementDidFail(_ statement: Statement, withResultCode resultCode: Int32) throws -> Never {
// Failed statements can not be reused, because sqlite3_reset won't
// be able to restore the statement to its initial state:
// https://www.sqlite.org/c3ref/reset.html
@@ -311,21 +623,30 @@ extension Database {
// So make sure we clear this statement from the cache.
internalStatementCache.remove(statement)
publicStatementCache.remove(statement)
/// Exposes the user-provided cancelled commit error, if a transaction
/// observer has cancelled a transaction.
try observationBroker.statementDidFail(statement)
throw DatabaseError(
resultCode: resultCode,
message: lastErrorMessage,
sql: statement.sql,
arguments: statement.arguments)
}
}
/// A thread-unsafe statement cache
struct StatementCache {
unowned let db: Database
private var selectStatements: [String: SelectStatement] = [:]
private var updateStatements: [String: UpdateStatement] = [:]
private var statements: [String: Statement] = [:]
init(database: Database) {
self.db = database
}
mutating func selectStatement(_ sql: String) throws -> SelectStatement {
if let statement = selectStatements[sql] {
mutating func statement(_ sql: String) throws -> Statement {
if let statement = statements[sql] {
return statement
}
@@ -339,61 +660,26 @@ struct StatementCache {
// However SQLITE_PREPARE_PERSISTENT was only introduced in
// SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
#if GRDBCUSTOMSQLITE || GRDBCIPHER
let statement = try db.makeSelectStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
let statement = try db.makeStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
#else
let statement: SelectStatement
let statement: Statement
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
// SQLite 3.24.0 or more
statement = try db.makeSelectStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
statement = try db.makeStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
} else {
// SQLite 3.19.3 or less
statement = try db.makeSelectStatement(sql: sql)
statement = try db.makeStatement(sql: sql)
}
#endif
selectStatements[sql] = statement
return statement
}
mutating func updateStatement(_ sql: String) throws -> UpdateStatement {
if let statement = updateStatements[sql] {
return statement
}
// http://www.sqlite.org/c3ref/c_prepare_persistent.html#sqlitepreparepersistent
// > The SQLITE_PREPARE_PERSISTENT flag is a hint to the query
// > planner that the prepared statement will be retained for a long
// > time and probably reused many times.
//
// This looks like a perfect match for cached statements.
//
// However SQLITE_PREPARE_PERSISTENT was only introduced in
// SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
#if GRDBCUSTOMSQLITE || GRDBCIPHER
let statement = try db.makeUpdateStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
#else
let statement: UpdateStatement
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
// SQLite 3.24.0 or more
statement = try db.makeUpdateStatement(sql: sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
} else {
// SQLite 3.19.3 or less
statement = try db.makeUpdateStatement(sql: sql)
}
#endif
updateStatements[sql] = statement
statements[sql] = statement
return statement
}
mutating func clear() {
updateStatements = [:]
selectStatements = [:]
statements = [:]
}
mutating func remove(_ statement: SelectStatement) {
selectStatements.removeFirst { $0.value === statement }
}
mutating func remove(_ statement: UpdateStatement) {
updateStatements.removeFirst { $0.value === statement }
mutating func remove(_ statement: Statement) {
statements.removeFirst { $0.value === statement }
}
}
+143 -86
View File
@@ -26,13 +26,14 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// MARK: - SQLite C API
/// The raw SQLite connection, suitable for the SQLite C API.
public let sqliteConnection: SQLiteConnection
/// It is constant, until close() sets it to nil.
public var sqliteConnection: SQLiteConnection?
// MARK: - Configuration
/// The error logging function.
///
/// Quoting https://www.sqlite.org/errlog.html:
/// Quoting <https://www.sqlite.org/errlog.html>:
///
/// > SQLite can be configured to invoke a callback function containing an
/// > error code and a terse error message whenever anomalies occur. This
@@ -71,7 +72,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// If no row has ever been inserted using this database connection,
/// returns zero.
///
/// For more detailed information, see https://www.sqlite.org/c3ref/last_insert_rowid.html
/// For more detailed information, see <https://www.sqlite.org/c3ref/last_insert_rowid.html>
public var lastInsertedRowID: Int64 {
SchedulingWatchdog.preconditionValidQueue(self)
return sqlite3_last_insert_rowid(sqliteConnection)
@@ -80,7 +81,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// The number of rows modified, inserted or deleted by the most recent
/// successful INSERT, UPDATE or DELETE statement.
///
/// For more detailed information, see https://www.sqlite.org/c3ref/changes.html
/// For more detailed information, see <https://www.sqlite.org/c3ref/changes.html>
public var changesCount: Int {
SchedulingWatchdog.preconditionValidQueue(self)
return Int(sqlite3_changes(sqliteConnection))
@@ -90,7 +91,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// INSERT, UPDATE or DELETE statements since the database connection was
/// opened.
///
/// For more detailed information, see https://www.sqlite.org/c3ref/total_changes.html
/// For more detailed information, see <https://www.sqlite.org/c3ref/total_changes.html>
public var totalChangesCount: Int {
SchedulingWatchdog.preconditionValidQueue(self)
return Int(sqlite3_total_changes(sqliteConnection))
@@ -112,7 +113,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// > connection while this routine is running, then the return value
// > is undefined.
SchedulingWatchdog.preconditionValidQueue(self)
if isClosed { return false } // Support for SerializedDatabase.deinit
if sqliteConnection == nil { return false } // Support for SerializedDatabase.deinit
return sqlite3_get_autocommit(sqliteConnection) == 0
}
@@ -125,8 +126,27 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// MARK: - Internal properties
// Caches
struct SchemaCache {
var schemaIdentifiers: [SchemaIdentifier]?
fileprivate var schemas: [SchemaIdentifier: DatabaseSchemaCache] = [:]
subscript(schemaID: SchemaIdentifier) -> DatabaseSchemaCache { // internal so that it can be tested
get {
schemas[schemaID] ?? DatabaseSchemaCache()
}
set {
schemas[schemaID] = newValue
}
}
mutating func clear() {
schemaIdentifiers = nil
schemas.removeAll()
}
}
var _lastSchemaVersion: Int32? // Support for clearSchemaCacheIfNeeded()
var schemaCache: DatabaseSchemaCache // internal so that it can be tested
var schemaCache = SchemaCache()
lazy var internalStatementCache = StatementCache(database: self)
lazy var publicStatementCache = StatementCache(database: self)
@@ -142,8 +162,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
}
/// If true, select statement execution is recorded.
/// Use recordingSelectedRegion(_:), see `selectStatementWillExecute(_:)`
var _isRecordingSelectedRegion: Bool = false
/// Use recordingSelectedRegion(_:), see `statementWillExecute(_:)`
var _isRecordingSelectedRegion = false
var _selectedRegion = DatabaseRegion()
/// Support for checkForAbortedTransaction()
@@ -163,30 +183,27 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
private var functions = Set<DatabaseFunction>()
private var collations = Set<DatabaseCollation>()
private var _readOnlyDepth = 0 // Modify with beginReadOnly/endReadOnly
private var isClosed: Bool = false
// MARK: - Initializer
init(
path: String,
description: String,
configuration: Configuration,
schemaCache: DatabaseSchemaCache) throws
configuration: Configuration) throws
{
self.sqliteConnection = try Database.openConnection(path: path, flags: configuration.SQLiteOpenFlags)
self.description = description
self.configuration = configuration
self.schemaCache = schemaCache
}
deinit {
assert(isClosed)
assert(sqliteConnection == nil)
}
// MARK: - Database Opening
private static func openConnection(path: String, flags: Int32) throws -> SQLiteConnection {
// See https://www.sqlite.org/c3ref/open.html
// See <https://www.sqlite.org/c3ref/open.html>
var sqliteConnection: SQLiteConnection? = nil
let code = sqlite3_open_v2(path, &sqliteConnection, flags, nil)
guard code == SQLITE_OK else {
@@ -199,7 +216,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// https://www.sqlite.org/c3ref/close.html
// > Calling sqlite3_close() or sqlite3_close_v2() with a NULL
// > pointer argument is a harmless no-op.
sqlite3_close(sqliteConnection)
_ = sqlite3_close(sqliteConnection) // ignore result code
throw DatabaseError(resultCode: code)
}
if let sqliteConnection = sqliteConnection {
@@ -301,7 +318,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
//
// - DatabaseCursorTests.testIssue583()
// - http://sqlite.1065341.n5.nabble.com/Issue-report-sqlite3-set-authorizer-triggers-error-4-516-SQLITE-ABORT-ROLLBACK-during-statement-itern-td107972.html
// swiftlint:disable:previous line_length
let dbPointer = Unmanaged.passUnretained(self).toOpaque()
sqlite3_set_authorizer(
sqliteConnection,
@@ -347,41 +363,85 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
//
// So let's fail early if file is not a database, or encrypted with
// another passphrase.
try makeSelectStatement(sql: "SELECT * FROM sqlite_master LIMIT 1").makeCursor().next()
try makeStatement(sql: "SELECT * FROM sqlite_master LIMIT 1").makeCursor().next()
}
// MARK: - Database Closing
/// This method must be called before database deallocation
func close() {
/// Closes a connection with `sqlite3_close`. This method is intended for
/// the public `close()` function. It may fail.
func close() throws {
SchedulingWatchdog.preconditionValidQueue(self)
if isClosed {
guard let sqliteConnection = sqliteConnection else {
// Already closed
return
}
configuration.SQLiteConnectionWillClose?(sqliteConnection)
internalStatementCache.clear()
publicStatementCache.clear()
Database.closeConnection(sqliteConnection)
isClosed = true
// https://www.sqlite.org/c3ref/close.html
// > If the database connection is associated with unfinalized prepared
// > statements or unfinished sqlite3_backup objects then
// > sqlite3_close() will leave the database connection open and
// > return SQLITE_BUSY.
let code = sqlite3_close(sqliteConnection)
guard code == SQLITE_OK else {
if let log = Self.logError {
if code == SQLITE_BUSY {
// Let the user know about unfinalized statements that did
// prevent the connection from closing properly.
var stmt: SQLiteStatement? = sqlite3_next_stmt(sqliteConnection, nil)
while stmt != nil {
log(ResultCode(rawValue: code), "unfinalized statement: \(String(cString: sqlite3_sql(stmt)))")
stmt = sqlite3_next_stmt(sqliteConnection, stmt)
}
}
}
throw DatabaseError(resultCode: code, message: lastErrorMessage)
}
self.sqliteConnection = nil
configuration.SQLiteConnectionDidClose?()
}
private static func closeConnection(_ sqliteConnection: SQLiteConnection) {
/// Closes a connection with `sqlite3_close_v2`. This method is intended for
/// deallocated connections.
func close_v2() {
SchedulingWatchdog.preconditionValidQueue(self)
guard let sqliteConnection = sqliteConnection else {
// Already closed
return
}
configuration.SQLiteConnectionWillClose?(sqliteConnection)
internalStatementCache.clear()
publicStatementCache.clear()
// https://www.sqlite.org/c3ref/close.html
// > If sqlite3_close_v2() is called with unfinalized prepared
// > statements and/or unfinished sqlite3_backups, then the database
// > connection becomes an unusable "zombie" which will automatically
// > be deallocated when the last prepared statement is finalized or the
// > last sqlite3_backup is finished.
// >
// > The sqlite3_close_v2() interface is intended for use with host
// > languages that are garbage collected, and where the order in which
// > destructors are called is arbitrary.
let code = sqlite3_close_v2(sqliteConnection)
if code != SQLITE_OK, let log = logError {
if code != SQLITE_OK, let log = Self.logError {
// A rare situation where GRDB doesn't fatalError on
// unprocessed errors.
let message = String(cString: sqlite3_errmsg(sqliteConnection))
log(ResultCode(rawValue: code), "could not close database: \(message)")
}
self.sqliteConnection = nil
configuration.SQLiteConnectionDidClose?()
}
// MARK: - Limits
@@ -397,7 +457,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// try Player.deleteAll(db, keys: ids)
/// }
///
/// See https://www.sqlite.org/limits.html
/// See <https://www.sqlite.org/limits.html>
/// and `SQLITE_LIMIT_VARIABLE_NUMBER`.
public var maximumStatementArgumentCount: Int {
Int(sqlite3_limit(sqliteConnection, SQLITE_LIMIT_VARIABLE_NUMBER, -1))
@@ -449,7 +509,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
}, nil)
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
fatalError(DatabaseError(resultCode: code, message: lastErrorMessage).description)
fatalError(DatabaseError(resultCode: code, message: lastErrorMessage))
}
}
@@ -468,7 +528,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
func beginReadOnly() throws {
if configuration.readonly { return }
if _readOnlyDepth == 0 {
try internalCachedUpdateStatement(sql: "PRAGMA query_only = 1").execute()
try internalCachedStatement(sql: "PRAGMA query_only = 1").execute()
}
_readOnlyDepth += 1
}
@@ -477,7 +537,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
if configuration.readonly { return }
_readOnlyDepth -= 1
if _readOnlyDepth == 0 {
try internalCachedUpdateStatement(sql: "PRAGMA query_only = 0").execute()
try internalCachedStatement(sql: "PRAGMA query_only = 0").execute()
}
}
@@ -494,7 +554,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
#if SQLITE_ENABLE_SNAPSHOT
/// Returns a snapshot that must be freed with `sqlite3_snapshot_free`.
///
/// See https://www.sqlite.org/c3ref/snapshot.html
/// See <https://www.sqlite.org/c3ref/snapshot.html>
func takeVersionSnapshot() throws -> UnsafeMutablePointer<sqlite3_snapshot> {
var snapshot: UnsafeMutablePointer<sqlite3_snapshot>?
let code = withUnsafeMutablePointer(to: &snapshot) {
@@ -574,7 +634,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// // Stop tracing
/// db.trace(options: [])
///
/// See https://www.sqlite.org/c3ref/trace_v2.html for more information.
/// See <https://www.sqlite.org/c3ref/trace_v2.html> for more information.
///
/// - parameter options: The set of desired event kinds. Defaults to
/// `.statement`, which notifies all executed database statements.
@@ -682,8 +742,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// Runs a WAL checkpoint.
///
/// See https://www.sqlite.org/wal.html and
/// https://www.sqlite.org/c3ref/wal_checkpoint_v2.html for
/// See <https://www.sqlite.org/wal.html> and
/// <https://www.sqlite.org/c3ref/wal_checkpoint_v2.html> for
/// more information.
///
/// - parameter kind: The checkpoint mode (default passive)
@@ -713,7 +773,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// MARK: - Interrupt
// See https://www.sqlite.org/c3ref/interrupt.html
// See <https://www.sqlite.org/c3ref/interrupt.html>
func interrupt() {
sqlite3_interrupt(sqliteConnection)
}
@@ -734,7 +794,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// Suspends the database. A suspended database prevents database locks in
/// order to avoid the [`0xdead10cc`
/// exception](https://developer.apple.com/library/archive/technotes/tn2151/_index.html).
/// exception](https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report).
///
/// This method can be called from any thread.
///
@@ -755,7 +815,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// Interrupt the database because this may trigger an
// SQLITE_INTERRUPT error which may itself abort a transaction and
// release a lock. See https://www.sqlite.org/c3ref/interrupt.html
// release a lock. See <https://www.sqlite.org/c3ref/interrupt.html>
interrupt()
// Now what about the eventual remaining lock? We'll issue a
@@ -766,7 +826,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// Resumes the database. A resumed database stops preventing database locks
/// in order to avoid the [`0xdead10cc`
/// exception](https://developer.apple.com/library/archive/technotes/tn2151/_index.html).
/// exception](https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report).
///
/// This method can be called from any thread.
///
@@ -798,7 +858,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// Throws SQLITE_ABORT for suspended databases, if statement would lock
/// the database, in order to avoid the [`0xdead10cc`
/// exception](https://developer.apple.com/library/archive/technotes/tn2151/_index.html).
/// exception](https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report).
func checkForSuspensionViolation(from statement: Statement) throws {
try $isSuspended.read { isSuspended in
guard isSuspended else {
@@ -816,9 +876,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
return
}
if let updateStatement = statement as? UpdateStatement,
updateStatement.releasesDatabaseLock
{
if statement.releasesDatabaseLock {
// Accept statements that release locks:
// - COMMIT
// - ROLLBACK
@@ -866,7 +924,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
arguments: @autoclosure () -> StatementArguments? = nil)
throws
{
if isInsideTransactionBlock && !isInsideTransaction {
if isInsideTransactionBlock && sqlite3_get_autocommit(sqliteConnection) != 0 {
throw DatabaseError(
resultCode: .SQLITE_ABORT,
message: "Transaction was aborted",
@@ -892,7 +950,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .deferred. See https://www.sqlite.org/lang_transaction.html
/// defaults to .deferred. See <https://www.sqlite.org/lang_transaction.html>
/// for more information.
/// - block: A block that executes SQL statements and return either
/// .commit or .rollback.
@@ -950,6 +1008,21 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
}
}
/// Runs the block with an isolation level equal or greater than
/// snapshot isolation.
func isolated<T>(readOnly: Bool = false, _ block: () throws -> T) throws -> T {
var result: T?
try inSavepoint {
if readOnly {
result = try self.readOnly(block)
} else {
result = try block()
}
return .commit
}
return result!
}
/// Executes a block inside a savepoint.
///
/// try dbQueue.inDatabase do {
@@ -993,11 +1066,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
return
}
// If the savepoint is top-level, we'll use ROLLBACK TRANSACTION in
// order to perform the special error handling of rollbacks (see
// the rollback method).
let topLevelSavepoint = !isInsideTransaction
// Begin savepoint
//
// We use a single name for savepoints because there is no need
@@ -1031,7 +1099,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
isInsideTransactionBlock = wasInsideTransactionBlock
try execute(sql: "RELEASE SAVEPOINT grdb")
assert(!topLevelSavepoint || !isInsideTransaction)
assert(sqlite3_get_autocommit(sqliteConnection) == 0)
needsRollback = false
case .rollback:
needsRollback = true
@@ -1043,15 +1111,11 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
if needsRollback {
do {
if topLevelSavepoint {
try rollback()
} else {
// Rollback, and release the savepoint.
// Rollback alone is not enough to clear the savepoint from
// the SQLite savepoint stack.
try execute(sql: "ROLLBACK TRANSACTION TO SAVEPOINT grdb")
try execute(sql: "RELEASE SAVEPOINT grdb")
}
// Rollback, and release the savepoint.
// Rollback alone is not enough to clear the savepoint from
// the SQLite savepoint stack.
try execute(sql: "ROLLBACK TRANSACTION TO SAVEPOINT grdb")
try execute(sql: "RELEASE SAVEPOINT grdb")
} catch {
if firstError == nil {
firstError = error
@@ -1068,13 +1132,13 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
///
/// - parameter kind: The transaction type (default nil). If nil, the
/// transaction type is configuration.defaultTransactionKind, which itself
/// defaults to .deferred. See https://www.sqlite.org/lang_transaction.html
/// defaults to .deferred. See <https://www.sqlite.org/lang_transaction.html>
/// for more information.
/// - throws: The error thrown by the block.
public func beginTransaction(_ kind: TransactionKind? = nil) throws {
let kind = kind ?? configuration.defaultTransactionKind
try execute(sql: "BEGIN \(kind.rawValue) TRANSACTION")
assert(isInsideTransaction)
assert(sqlite3_get_autocommit(sqliteConnection) == 0)
}
/// Rollbacks a database transaction.
@@ -1121,13 +1185,13 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
if isInsideTransaction {
try execute(sql: "ROLLBACK TRANSACTION")
}
assert(!isInsideTransaction)
assert(sqlite3_get_autocommit(sqliteConnection) != 0)
}
/// Commits a database transaction.
public func commit() throws {
try execute(sql: "COMMIT TRANSACTION")
assert(!isInsideTransaction)
assert(sqlite3_get_autocommit(sqliteConnection) != 0)
}
// MARK: - Memory Management
@@ -1246,7 +1310,7 @@ extension Database {
}
try usePassphrase(data)
}
/// Sets the passphrase used to crypt and decrypt an SQLCipher database.
///
/// Call this method from `Configuration.prepareDatabase`,
@@ -1275,7 +1339,7 @@ extension Database {
}
try changePassphrase(data)
}
/// Changes the passphrase used by an SQLCipher encrypted database.
public func changePassphrase(_ passphrase: Data) throws {
// FIXME: sqlite3_rekey is discouraged.
@@ -1287,7 +1351,6 @@ extension Database {
// > options and using sqlcipher_export() to migrate the contents and
// > schema of the original db into the new one:
// > https://discuss.zetetic.net/t/how-to-encrypt-a-plaintext-sqlite-database-to-use-sqlcipher-and-avoid-file-is-encrypted-or-is-not-a-database-errors/
// swiftlint:disable:previous line_length
let code = passphrase.withUnsafeBytes {
sqlite3_rekey(sqliteConnection, $0.baseAddress, Int32($0.count))
}
@@ -1302,7 +1365,7 @@ extension Database {
// MARK: - Database-Related Types
/// See BusyMode and https://www.sqlite.org/c3ref/busy_handler.html
/// See BusyMode and <https://www.sqlite.org/c3ref/busy_handler.html>
public typealias BusyCallback = (_ numberOfTries: Int) -> Bool
/// When there are several connections to a database, a connection may try
@@ -1327,10 +1390,10 @@ extension Database {
///
/// Relevant SQLite documentation:
///
/// - https://www.sqlite.org/c3ref/busy_timeout.html
/// - https://www.sqlite.org/c3ref/busy_handler.html
/// - https://www.sqlite.org/lang_transaction.html
/// - https://www.sqlite.org/wal.html
/// - <https://www.sqlite.org/c3ref/busy_timeout.html>
/// - <https://www.sqlite.org/c3ref/busy_handler.html>
/// - <https://www.sqlite.org/lang_transaction.html>
/// - <https://www.sqlite.org/wal.html>
public enum BusyMode {
/// The SQLITE_BUSY error is immediately returned to the connection that
/// tries to access the locked database.
@@ -1341,7 +1404,7 @@ extension Database {
case timeout(TimeInterval)
/// A custom callback that is called when a database is locked.
/// See https://www.sqlite.org/c3ref/busy_handler.html
/// See <https://www.sqlite.org/c3ref/busy_handler.html>
case callback(BusyCallback)
}
@@ -1362,7 +1425,7 @@ extension Database {
/// A built-in SQLite collation.
///
/// See https://www.sqlite.org/datatype3.html#collation
/// See <https://www.sqlite.org/datatype3.html#collation>
public struct CollationName: RawRepresentable, Hashable {
/// :nodoc:
public let rawValue: String
@@ -1389,7 +1452,7 @@ extension Database {
/// t.column("title", .text)
/// }
///
/// See https://www.sqlite.org/datatype3.html
/// See <https://www.sqlite.org/datatype3.html>
public struct ColumnType: RawRepresentable, Hashable {
/// :nodoc:
public let rawValue: String
@@ -1426,7 +1489,7 @@ extension Database {
/// An SQLite conflict resolution.
///
/// See https://www.sqlite.org/lang_conflict.html.
/// See <https://www.sqlite.org/lang_conflict.html>
public enum ConflictResolution: String {
/// The `ROLLBACK` conflict resolution
case rollback = "ROLLBACK"
@@ -1446,7 +1509,7 @@ extension Database {
/// A foreign key action.
///
/// See https://www.sqlite.org/foreignkeys.html
/// See <https://www.sqlite.org/foreignkeys.html>
public enum ForeignKeyAction: String {
/// The `CASCADE` foreign key action
case cascade = "CASCADE"
@@ -1468,13 +1531,13 @@ extension Database {
public struct TracingOptions: OptionSet {
/// The raw "Trace Event Code".
///
/// See https://www.sqlite.org/c3ref/c_trace.html
/// See <https://www.sqlite.org/c3ref/c_trace.html>
public let rawValue: CInt
/// Creates a `TracingOptions` from a raw "Trace Event Code".
///
/// See:
/// - https://www.sqlite.org/c3ref/c_trace.html
/// - <https://www.sqlite.org/c3ref/c_trace.html>
/// - `Database.trace(options:_:)`
public init(rawValue: CInt) {
self.rawValue = rawValue
@@ -1575,15 +1638,8 @@ extension Database {
/// An event reported by `TracingOptions.statement`.
case statement(Statement)
#if GRDBCUSTOMSQLITE || GRDBCIPHER || os(iOS)
/// An event reported by `TracingOptions.profile`.
case profile(statement: Statement, duration: TimeInterval)
#elseif os(Linux)
#else
/// An event reported by `TracingOptions.profile`.
@available(OSX 10.12, tvOS 10.0, watchOS 3.0, *)
case profile(statement: Statement, duration: TimeInterval)
#endif
public var description: String {
switch self {
@@ -1597,6 +1653,7 @@ extension Database {
}
/// Confirms or cancels the changes performed by a transaction or savepoint.
@frozen
public enum TransactionCompletion {
/// Confirms changes
case commit
@@ -1605,7 +1662,7 @@ extension Database {
case rollback
}
/// An SQLite transaction kind. See https://www.sqlite.org/lang_transaction.html
/// An SQLite transaction kind. See <https://www.sqlite.org/lang_transaction.html>
public enum TransactionKind: String {
/// The `DEFERRED` transaction kind
case deferred = "DEFERRED"
@@ -1617,7 +1674,7 @@ extension Database {
case exclusive = "EXCLUSIVE"
}
/// An SQLite threading mode. See https://www.sqlite.org/threadsafe.html.
/// An SQLite threading mode. See <https://www.sqlite.org/threadsafe.html>.
enum ThreadingMode {
case `default`
case multiThread
+1 -1
View File
@@ -51,7 +51,7 @@ extension DatabaseCollation: Hashable {
/// Two collations are equal if they share the same name (case insensitive)
/// :nodoc:
public static func == (lhs: DatabaseCollation, rhs: DatabaseCollation) -> Bool {
// See https://www.sqlite.org/c3ref/create_collation.html
// See <https://www.sqlite.org/c3ref/create_collation.html>
return sqlite3_stricmp(lhs.name, rhs.name) == 0
}
}
+16 -5
View File
@@ -2,7 +2,7 @@ import Foundation
/// An SQLite result code.
///
/// See https://www.sqlite.org/rescode.html
/// See <https://www.sqlite.org/rescode.html>
public struct ResultCode: RawRepresentable, Equatable, CustomStringConvertible {
/// The raw SQLite result code
public let rawValue: CInt
@@ -13,7 +13,7 @@ public struct ResultCode: RawRepresentable, Equatable, CustomStringConvertible {
}
/// A result code limited to the least significant 8 bits of the receiver.
/// See https://www.sqlite.org/rescode.html for more information.
/// See <https://www.sqlite.org/rescode.html> for more information.
///
/// let resultCode = .SQLITE_CONSTRAINT_FOREIGNKEY
/// resultCode.primaryResultCode == .SQLITE_CONSTRAINT // true
@@ -193,7 +193,7 @@ extension ResultCode {
public struct DatabaseError: Error, CustomStringConvertible, CustomNSError {
/// The SQLite error code (see
/// https://www.sqlite.org/rescode.html#primary_result_code_list).
/// <https://www.sqlite.org/rescode.html#primary_result_code_list>).
///
/// do {
/// ...
@@ -203,7 +203,7 @@ public struct DatabaseError: Error, CustomStringConvertible, CustomNSError {
///
/// This property returns a "primary result code", that is to say the least
/// significant 8 bits of any SQLite result code. See
/// https://www.sqlite.org/rescode.html for more information.
/// <https://www.sqlite.org/rescode.html> for more information.
///
/// See also `extendedResultCode`.
public var resultCode: ResultCode {
@@ -211,7 +211,7 @@ public struct DatabaseError: Error, CustomStringConvertible, CustomNSError {
}
/// The SQLite extended error code (see
/// https://www.sqlite.org/rescode.html#extended_result_code_list).
/// <https://www.sqlite.org/rescode.html#extended_result_code_list>).
///
/// do {
/// ...
@@ -248,9 +248,20 @@ public struct DatabaseError: Error, CustomStringConvertible, CustomNSError {
///
/// This initializer is not public because library user is not supposed to
/// be exposed to raw result codes.
@usableFromInline
init(resultCode: CInt, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
self.init(resultCode: ResultCode(rawValue: resultCode), message: message, sql: sql, arguments: arguments)
}
static func noSuchTable(_ tableName: String) -> Self {
DatabaseError(message: "no such table: \(tableName)")
}
}
extension DatabaseError {
static func connectionIsClosed() -> Self {
DatabaseError(resultCode: .SQLITE_MISUSE, message: "Connection is closed")
}
}
// Support for `catch DatabaseError.SQLITE_XXX`
+25 -13
View File
@@ -107,8 +107,20 @@ public final class DatabaseFunction: Hashable {
self.kind = .aggregate { Aggregate() }
}
/// Returns an SQL expression that applies the function.
///
/// See <https://github.com/groue/GRDB.swift/#sql-functions>
public func callAsFunction(_ arguments: SQLExpressible...) -> SQLExpression {
switch kind {
case .aggregate:
return .function(name, arguments.map(\.sqlExpression))
case .function:
return .aggregate(name, arguments.map(\.sqlExpression))
}
}
/// Calls sqlite3_create_function_v2
/// See https://sqlite.org/c3ref/create_function.html
/// See <https://sqlite.org/c3ref/create_function.html>
func install(in db: Database) {
// Retain the function definition
let definition = kind.definition
@@ -130,12 +142,12 @@ public final class DatabaseFunction: Hashable {
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage))
}
}
/// Calls sqlite3_create_function_v2
/// See https://sqlite.org/c3ref/create_function.html
/// See <https://sqlite.org/c3ref/create_function.html>
func uninstall(in db: Database) {
let code = sqlite3_create_function_v2(
db.sqliteConnection,
@@ -146,13 +158,13 @@ public final class DatabaseFunction: Hashable {
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage))
}
}
/// The way to compute the result of a function.
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
private class FunctionDefinition {
let compute: (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?
init(compute: @escaping (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?) {
@@ -162,7 +174,7 @@ public final class DatabaseFunction: Hashable {
/// The way to start an aggregate.
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
private class AggregateDefinition {
let makeAggregate: () -> DatabaseAggregate
init(makeAggregate: @escaping () -> DatabaseAggregate) {
@@ -180,7 +192,7 @@ public final class DatabaseFunction: Hashable {
}
/// A function kind: an "SQL function" or an "aggregate".
/// See http://sqlite.org/capi3ref.html#sqlite3_create_function
/// See <http://sqlite.org/capi3ref.html#sqlite3_create_function>
private enum Kind {
/// A regular function: SELECT f(1)
case function((Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?)
@@ -189,7 +201,7 @@ public final class DatabaseFunction: Hashable {
case aggregate(() -> DatabaseAggregate)
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
var definition: AnyObject {
switch self {
case .function(let compute):
@@ -200,7 +212,7 @@ public final class DatabaseFunction: Hashable {
}
/// Feeds the `xFunc` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
var xFunc: (@convention(c) (OpaquePointer?, Int32, UnsafeMutablePointer<OpaquePointer?>?) -> Void)? {
guard case .function = self else { return nil }
return { (sqliteContext, argc, argv) in
@@ -218,7 +230,7 @@ public final class DatabaseFunction: Hashable {
}
/// Feeds the `xStep` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
var xStep: (@convention(c) (OpaquePointer?, Int32, UnsafeMutablePointer<OpaquePointer?>?) -> Void)? {
guard case .aggregate = self else { return nil }
return { (sqliteContext, argc, argv) in
@@ -238,7 +250,7 @@ public final class DatabaseFunction: Hashable {
}
/// Feeds the `xFinal` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
/// <http://sqlite.org/capi3ref.html#sqlite3_create_function>
var xFinal: (@convention(c) (OpaquePointer?) -> Void)? {
guard case .aggregate = self else { return nil }
return { (sqliteContext) in
@@ -266,8 +278,8 @@ public final class DatabaseFunction: Hashable {
///
/// The result must be released when the aggregate concludes.
///
/// See https://sqlite.org/c3ref/context.html
/// See https://sqlite.org/c3ref/aggregate_context.html
/// See <https://sqlite.org/c3ref/context.html>
/// See <https://sqlite.org/c3ref/aggregate_context.html>
private static func unmanagedAggregateContext(_ sqliteContext: OpaquePointer?) -> Unmanaged<AggregateContext> {
// > The first time the sqlite3_aggregate_context(C,N) routine is called
// > for a particular aggregate function, SQLite allocates N of memory,
+99 -181
View File
@@ -7,7 +7,10 @@ import UIKit
/// A DatabasePool grants concurrent accesses to an SQLite database.
public final class DatabasePool: DatabaseWriter {
private let writer: SerializedDatabase
private var readerPool: Pool<SerializedDatabase>!
/// The pool of reader connections.
/// It is constant, until close() sets it to nil.
private var readerPool: Pool<SerializedDatabase>?
@LockedBox var databaseSnapshotCount = 0
@@ -42,7 +45,6 @@ public final class DatabasePool: DatabaseWriter {
writer = try SerializedDatabase(
path: path,
configuration: configuration,
schemaCache: DatabaseSchemaCache(),
defaultLabel: "GRDB.DatabasePool",
purpose: "writer")
@@ -60,7 +62,6 @@ public final class DatabasePool: DatabaseWriter {
return try SerializedDatabase(
path: path,
configuration: readerConfiguration,
schemaCache: DatabaseSchemaCache(),
defaultLabel: "GRDB.DatabasePool",
purpose: "reader.\(readerCount)")
})
@@ -155,7 +156,7 @@ public final class DatabasePool: DatabaseWriter {
/// executed the *body* block.
fileprivate func forEachConnection(_ body: (Database) -> Void) {
writer.sync(body)
readerPool.forEach { $0.sync(body) }
readerPool?.forEach { $0.sync(body) }
}
}
@@ -171,8 +172,8 @@ extension DatabasePool {
// Release writer memory
writer.sync { $0.releaseMemory() }
// Release readers memory by closing all connections
readerPool.barrier {
readerPool.removeAll()
readerPool?.barrier {
readerPool?.removeAll()
}
}
@@ -224,11 +225,34 @@ extension DatabasePool {
extension DatabasePool: DatabaseReader {
public func close() throws {
try readerPool?.barrier {
// Close writer connection first. If we can't close it,
// don't close readers.
//
// This allows us to exit this method as fully closed (read and
// writes fail), or not closed at all (reads and writes succeed).
//
// Unfortunately, this introduces a regression for
// https://github.com/groue/GRDB.swift/issues/739.
// TODO: fix this regression.
try writer.sync { try $0.close() }
// OK writer is closed. Now close readers and
// eventually prevent any future read access
defer { readerPool = nil }
try readerPool?.forEach { reader in
try reader.sync { try $0.close() }
}
}
}
// MARK: - Interrupting Database Operations
public func interrupt() {
writer.interrupt()
readerPool.forEach { $0.interrupt() }
readerPool?.forEach { $0.interrupt() }
}
// MARK: - Database Suspension
@@ -279,66 +303,22 @@ extension DatabasePool: DatabaseReader {
// MARK: - Reading from Database
/// Synchronously executes a read-only block in a protected dispatch queue,
/// and returns its result. The block is wrapped in a deferred transaction.
///
/// let players = try dbPool.read { db in
/// try Player.fetchAll(...)
/// }
///
/// The block is completely isolated. Eventual concurrent database updates
/// are *not visible* inside the block:
///
/// try dbPool.read { db in
/// // Those two values are guaranteed to be equal, even if the
/// // `wine` table is modified between the two requests:
/// let count1 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// let count2 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// }
///
/// try dbPool.read { db in
/// // Now this value may be different:
/// let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// happen while establishing the read access to the database.
public func read<T>(_ block: (Database) throws -> T) throws -> T {
public func read<T>(_ value: (Database) throws -> T) throws -> T {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
guard let readerPool = readerPool else {
throw DatabaseError.connectionIsClosed()
}
return try readerPool.get { reader in
try reader.sync { db in
var result: T? = nil
// The block isolation comes from the DEFERRED transaction.
// See DatabasePoolTests.testReadMethodIsolationOfBlock().
try db.inTransaction(.deferred) {
try db.isolated {
try db.clearSchemaCacheIfNeeded()
result = try block(db)
return .commit
return try value(db)
}
return result!
}
}
}
/// Asynchronously executes a read-only block in a protected dispatch queue.
///
/// let players = try dbQueue.asyncRead { dbResult in
/// do {
/// let db = try dbResult.get()
/// let count = try Player.fetchCount(db)
/// } catch {
/// // Handle error
/// }
/// }
///
/// Attempts to write in the database from this method throw a DatabaseError
/// of resultCode `SQLITE_READONLY`.
///
/// - parameter block: A block that accesses the database.
public func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void) {
public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void) {
// First async jump in order to grab a reader connection.
// Honor configuration dispatching (qos/targetQueue).
let label = configuration.identifier(
@@ -348,7 +328,10 @@ extension DatabasePool: DatabaseReader {
.makeDispatchQueue(label: label)
.async {
do {
let (reader, releaseReader) = try self.readerPool.get()
guard let readerPool = self.readerPool else {
throw DatabaseError.connectionIsClosed()
}
let (reader, releaseReader) = try readerPool.get()
// Second async jump because sync could deadlock if
// configuration has a serial targetQueue.
@@ -361,19 +344,19 @@ extension DatabasePool: DatabaseReader {
// The block isolation comes from the DEFERRED transaction.
try db.beginTransaction(.deferred)
try db.clearSchemaCacheIfNeeded()
block(.success(db))
value(.success(db))
} catch {
block(.failure(error))
value(.failure(error))
}
}
} catch {
block(.failure(error))
value(.failure(error))
}
}
}
/// :nodoc:
public func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void) {
public func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void) {
// First async jump in order to grab a reader connection.
// Honor configuration dispatching (qos/targetQueue).
let label = configuration.identifier(
@@ -383,18 +366,21 @@ extension DatabasePool: DatabaseReader {
.makeDispatchQueue(label: label)
.async { [weak self] in
guard let self = self else {
block(nil)
value(nil)
return
}
do {
let (reader, releaseReader) = try self.readerPool.get()
guard let readerPool = self.readerPool else {
throw DatabaseError.connectionIsClosed()
}
let (reader, releaseReader) = try readerPool.get()
// Second async jump because sync could deadlock if
// configuration has a serial targetQueue.
reader.weakAsync { db in
guard let db = db else {
block(nil)
value(nil)
return
}
@@ -406,101 +392,54 @@ extension DatabasePool: DatabaseReader {
// The block isolation comes from the DEFERRED transaction.
try db.beginTransaction(.deferred)
try db.clearSchemaCacheIfNeeded()
block(.success(db))
value(.success(db))
} catch {
block(.failure(error))
value(.failure(error))
}
}
} catch {
block(.failure(error))
value(.failure(error))
}
}
}
/// Synchronously executes a read-only block in a protected dispatch queue,
/// and returns its result.
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
///
/// try dbPool.unsafeRead { db in
/// // Those two values may be different because some other thread
/// // may have inserted or deleted a wine between the two requests:
/// let count1 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// let count2 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// }
///
/// Cursor iteration is safe, though:
///
/// try dbPool.unsafeRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, sql: "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// happen while establishing the read access to the database.
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
guard let readerPool = readerPool else {
throw DatabaseError.connectionIsClosed()
}
return try readerPool.get { reader in
try reader.sync { db in
try db.clearSchemaCacheIfNeeded()
return try block(db)
return try value(db)
}
}
}
/// Synchronously executes a read-only block in a protected dispatch queue,
/// and returns its result.
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
///
/// try dbPool.unsafeReentrantRead { db in
/// // Those two values may be different because some other thread
/// // may have inserted or deleted a wine between the two requests:
/// let count1 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// let count2 = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM wine")!
/// }
///
/// Cursor iteration is safe, though:
///
/// try dbPool.unsafeReentrantRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, sql: "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// This method is reentrant. It is unsafe because it fosters dangerous
/// concurrency practices.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// happen while establishing the read access to the database.
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T {
if let reader = currentReader {
return try reader.reentrantSync(block)
return try reader.reentrantSync(value)
} else {
guard let readerPool = readerPool else {
throw DatabaseError.connectionIsClosed()
}
return try readerPool.get { reader in
try reader.sync { db in
try db.clearSchemaCacheIfNeeded()
return try block(db)
return try value(db)
}
}
}
}
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
// The semaphore that blocks until futureResult is defined:
let futureSemaphore = DispatchSemaphore(value: 0)
var futureResult: Result<T, Error>? = nil
asyncConcurrentRead { dbResult in
// Fetch and release the future
futureResult = dbResult.flatMap { db in Result { try block(db) } }
futureResult = dbResult.flatMap { db in Result { try value(db) } }
futureSemaphore.signal()
}
@@ -514,18 +453,19 @@ extension DatabasePool: DatabaseReader {
/// Performs the same job as asyncConcurrentRead.
///
/// :nodoc:
public func spawnConcurrentRead(_ block: @escaping (Result<Database, Error>) -> Void) {
asyncConcurrentRead(block)
public func spawnConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void) {
asyncConcurrentRead(value)
}
/// Asynchronously executes a read-only block in a protected dispatch queue.
/// Asynchronously executes a read-only function in a protected
/// dispatch queue.
///
/// This method must be called from a writing dispatch queue, outside of any
/// transaction. You'll get a fatal error otherwise.
///
/// The *block* argument is guaranteed to see the database in the last
/// committed state at the moment this method is called. Eventual concurrent
/// database updates are *not visible* inside the block.
/// The `value` function is guaranteed to see the database in the last
/// committed state at the moment this method is called. Eventual
/// concurrent database updates are not visible from the function.
///
/// This method returns as soon as the isolation guarantees described above
/// are established.
@@ -552,8 +492,8 @@ extension DatabasePool: DatabaseReader {
/// try Player(...).insert(db)
/// }
///
/// - parameter block: A block that accesses the database.
public func asyncConcurrentRead(_ block: @escaping (Result<Database, Error>) -> Void) {
/// - parameter value: A function that accesses the database.
public func asyncConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void) {
// Check that we're on the writer queue...
writer.execute { db in
// ... and that no transaction is opened.
@@ -570,6 +510,9 @@ extension DatabasePool: DatabaseReader {
let isolationSemaphore = DispatchSemaphore(value: 0)
do {
guard let readerPool = readerPool else {
throw DatabaseError.connectionIsClosed()
}
let (reader, releaseReader) = try readerPool.get()
reader.async { db in
defer {
@@ -627,7 +570,7 @@ extension DatabasePool: DatabaseReader {
try db.clearSchemaCacheIfNeeded()
} catch {
isolationSemaphore.signal()
block(.failure(error))
value(.failure(error))
return
}
@@ -635,11 +578,11 @@ extension DatabasePool: DatabaseReader {
// can release the writer queue.
isolationSemaphore.signal()
block(.success(db))
value(.success(db))
}
} catch {
isolationSemaphore.signal()
block(.failure(error))
value(.failure(error))
}
// Block the writer queue until snapshot isolation success or error
@@ -654,12 +597,16 @@ extension DatabasePool: DatabaseReader {
/// Eventual concurrent read-only accesses are not invalidated: they will
/// proceed until completion.
public func invalidateReadOnlyConnections() {
readerPool.removeAll()
readerPool?.removeAll()
}
/// Returns a reader that can be used from the current dispatch queue,
/// if any.
private var currentReader: SerializedDatabase? {
guard let readerPool = readerPool else {
return nil
}
var readers: [SerializedDatabase] = []
readerPool.forEach { reader in
// We can't check for reader.onValidQueue here because
@@ -681,42 +628,24 @@ extension DatabasePool: DatabaseReader {
// MARK: - Writing in Database
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Eventual concurrent database updates are postponed until the updates
/// are completed.
///
/// Eventual concurrent reads may see partial updates unless you wrap them
/// in a transaction.
///
/// This method is *not* reentrant.
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Updates are guaranteed an exclusive access to the database. They wait
/// until all pending writes and reads are completed. They postpone all
/// other writes and reads until they are completed.
///
/// This method is *not* reentrant.
///
/// - important: Reads executed by concurrent *database snapshots* are not
/// considered: they can run concurrently with the barrier updates.
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try readerPool.barrier {
// TODO: throw instead of crashing when the database is closed
try readerPool!.barrier {
try writer.sync(updates)
}
}
public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void) {
// TODO: throw instead of crashing when the database is closed
readerPool!.asyncBarrier {
self.writer.sync(updates)
}
}
/// Synchronously executes database updates in a protected dispatch queue,
/// wrapped inside a transaction, and returns the result.
///
@@ -740,7 +669,7 @@ extension DatabasePool: DatabaseReader {
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .deferred. See https://www.sqlite.org/lang_transaction.html
/// defaults to .deferred. See <https://www.sqlite.org/lang_transaction.html>
/// for more information.
/// - updates: The updates to the database.
/// - throws: The error thrown by the updates, or by the
@@ -757,17 +686,6 @@ extension DatabasePool: DatabaseReader {
}
}
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Eventual concurrent database updates are postponed until the updates
/// are completed.
///
/// Eventual concurrent reads may see partial updates unless you wrap them
/// in a transaction.
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.reentrantSync(updates)
}
@@ -1058,7 +976,7 @@ extension DatabasePool {
/// You can create as many snapshots as you need, regardless of the maximum
/// number of reader connections in the pool.
///
/// For more information, read about "snapshot isolation" at https://sqlite.org/isolation.html
/// For more information, read about "snapshot isolation" at <https://sqlite.org/isolation.html>
public func makeSnapshot() throws -> DatabaseSnapshot {
// Sanity check
if writer.onValidQueue {
+49 -117
View File
@@ -36,7 +36,6 @@ public final class DatabaseQueue: DatabaseWriter {
writer = try SerializedDatabase(
path: path,
configuration: configuration,
schemaCache: DatabaseSchemaCache(),
defaultLabel: "GRDB.DatabaseQueue")
setupSuspension()
@@ -60,7 +59,6 @@ public final class DatabaseQueue: DatabaseWriter {
writer = try! SerializedDatabase(
path: ":memory:",
configuration: configuration,
schemaCache: DatabaseSchemaCache(),
defaultLabel: "GRDB.DatabaseQueue")
}
@@ -71,6 +69,10 @@ public final class DatabaseQueue: DatabaseWriter {
// Explicit unregistration is required before OS X 10.11.
NotificationCenter.default.removeObserver(self)
}
public func close() throws {
try writer.sync { try $0.close() }
}
}
extension DatabaseQueue {
@@ -176,121 +178,76 @@ extension DatabaseQueue {
// MARK: - Reading from Database
/// Synchronously executes a read-only block in a protected dispatch queue,
/// and returns its result.
///
/// let players = try dbQueue.read { db in
/// try Player.fetchAll(db)
/// }
///
/// This method is *not* reentrant.
///
/// Attempts to write in the database from this method throw a DatabaseError
/// of resultCode `SQLITE_READONLY`.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try writer.sync { db in
try db.readOnly { try block(db) }
try db.isolated(readOnly: true) {
try value(db)
}
}
}
/// Asynchronously executes a read-only block in a protected dispatch queue.
///
/// let players = try dbQueue.asyncRead { dbResult in
/// do {
/// let db = try dbResult.get()
/// let count = try Player.fetchCount(db)
/// } catch {
/// // Handle error
/// }
/// }
///
/// Attempts to write in the database from this method throw a DatabaseError
/// of resultCode `SQLITE_READONLY`.
///
/// - parameter block: A block that accesses the database.
public func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void) {
public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void) {
writer.async { db in
do {
// The transaction guarantees snapshot isolation against eventual
// external connection.
try db.beginTransaction(.deferred)
try db.beginReadOnly()
} catch {
block(.failure(error))
value(.failure(error))
return
}
block(.success(db))
value(.success(db))
// Ignore error because we can not notify it.
try? db.endReadOnly()
try? db.commit()
}
}
/// :nodoc:
public func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void) {
public func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void) {
writer.weakAsync { db in
guard let db = db else {
block(nil)
value(nil)
return
}
do {
// The transaction guarantees snapshot isolation against eventual
// external connection.
try db.beginTransaction(.deferred)
try db.beginReadOnly()
} catch {
block(.failure(error))
value(.failure(error))
return
}
block(.success(db))
value(.success(db))
// Ignore error because we can not notify it.
try? db.endReadOnly()
try? db.commit()
}
}
/// Synchronously executes a block in a protected dispatch queue, and
/// returns its result.
///
/// let players = try dbQueue.unsafeRead { db in
/// try Player.fetchAll(db)
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
///
/// :nodoc:
public func unsafeRead<T>(_ block: (Database) throws -> T) rethrows -> T {
try writer.sync(block)
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
try writer.sync(value)
}
/// Synchronously executes a block in a protected dispatch queue, and
/// returns its result.
///
/// let players = try dbQueue.unsafeReentrantRead { db in
/// try Player.fetchAll(db)
/// }
///
/// This method is reentrant. It is unsafe because it fosters dangerous
/// concurrency practices.
///
/// :nodoc:
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) rethrows -> T {
try writer.reentrantSync(block)
public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) rethrows -> T {
try writer.reentrantSync(value)
}
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
// DatabaseQueue can't perform parallel reads.
// Perform a blocking read instead.
return DatabaseFuture(Result {
// Check that we're on the writer queue...
// Check that we're on the writer queue, as documented
try writer.execute { db in
// ... and that no transaction is opened.
GRDBPrecondition(!db.isInsideTransaction, "must not be called from inside a transaction.")
return try db.readOnly {
try block(db)
try db.isolated(readOnly: true) {
try value(db)
}
}
})
@@ -299,23 +256,25 @@ extension DatabaseQueue {
/// Performs the same job as asyncConcurrentRead.
///
/// :nodoc:
public func spawnConcurrentRead(_ block: @escaping (Result<Database, Error>) -> Void) {
public func spawnConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void) {
// Check that we're on the writer queue...
writer.execute { db in
// ... and that no transaction is opened.
GRDBPrecondition(!db.isInsideTransaction, "must not be called from inside a transaction.")
do {
try db.beginTransaction(.deferred)
try db.beginReadOnly()
} catch {
block(.failure(error))
value(.failure(error))
return
}
block(.success(db))
value(.success(db))
// Ignore error because we can not notify it.
try? db.endReadOnly()
try? db.commit()
}
}
@@ -341,7 +300,7 @@ extension DatabaseQueue {
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .deferred. See https://www.sqlite.org/lang_transaction.html
/// defaults to .deferred. See <https://www.sqlite.org/lang_transaction.html>
/// for more information.
/// - updates: The updates to the database.
/// - throws: The error thrown by the updates, or by the
@@ -358,66 +317,39 @@ extension DatabaseQueue {
}
}
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Eventual concurrent database accesses are postponed until the updates
/// are completed.
///
/// This method is *not* reentrant.
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void) {
writer.async(updates)
}
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Eventual concurrent database accesses are postponed until the updates
/// Eventual concurrent database updates are postponed until the updates
/// are completed.
///
/// Eventual concurrent reads may see partial updates unless you wrap them
/// in a transaction.
///
/// This method is *not* reentrant.
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
/// Synchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// // INSERT INTO player ...
/// let players = try dbQueue.inDatabase { db in
/// try Player(...).insert(db)
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func inDatabase<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
/// Synchronously executes database updates in a protected dispatch queue, and
/// returns the result.
///
/// // INSERT INTO player ...
/// try dbQueue.unsafeReentrantWrite { db in
/// try Player(...).insert(db)
/// }
///
/// This method is reentrant. It is unsafe because it fosters dangerous
/// concurrency practices.
public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.reentrantSync(updates)
}
/// Asynchronously executes database updates in a protected dispatch queue,
/// outside of any transaction.
public func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void) {
writer.async(updates)
}
+119 -71
View File
@@ -24,6 +24,28 @@ public protocol DatabaseReader: AnyObject {
/// The database configuration
var configuration: Configuration { get }
/// Closes the database connection with the `sqlite3_close()` function.
///
/// **Note**: You DO NOT HAVE to call this method, and you SHOULD NOT call
/// it unless the correct execution of your program depends on precise
/// database closing. Database connections are automatically closed when
/// they are deinitialized, and this is sufficient for most applications.
///
/// If this method does not throw, then the database is properly closed, and
/// every future database access will throw a `DatabaseError` of
/// code `SQLITE_MISUSE`.
///
/// Otherwise, there exists concurrent database accesses or living prepared
/// statements that prevent the database from closing, and this method
/// throws a `DatabaseError` of code `SQLITE_BUSY`.
/// See <https://www.sqlite.org/c3ref/close.html> for more information.
///
/// After an error has been thrown, the database may still be opened, and
/// you can keep on accessing it. It may also remain in a "zombie" state,
/// in which case it will throw `SQLITE_MISUSE` for all future
/// database accesses.
func close() throws
// MARK: - Interrupting Database Operations
/// This method causes any pending database operation to abort and return at
@@ -87,15 +109,22 @@ public protocol DatabaseReader: AnyObject {
// MARK: - Read From Database
/// Synchronously executes a read-only block that takes a database
/// Synchronously executes a read-only function that accepts a database
/// connection, and returns its result.
///
/// Guarantee 1: the block argument is isolated. Eventual concurrent
/// database updates are not visible inside the block:
/// For example:
///
/// let count = try reader.read { db in
/// try Player.fetchCount(db)
/// }
///
/// The `value` function runs in an isolated fashion: eventual concurrent
/// database updates are not visible from the function:
///
/// try reader.read { db in
/// // Those two values are guaranteed to be equal, even if the
/// // `player` table is modified between the two requests:
/// // `player` table is modified, between the two requests, by
/// // some other database connection or some other thread.
/// let count1 = try Player.fetchCount(db)
/// let count2 = try Player.fetchCount(db)
/// }
@@ -105,25 +134,34 @@ public protocol DatabaseReader: AnyObject {
/// let count = try Player.fetchCount(db)
/// }
///
/// Guarantee 2: attempts to write in the database throw a DatabaseError
/// whose resultCode is `SQLITE_READONLY`.
/// Attempts to write in the database throw a DatabaseError with
/// resultCode `SQLITE_READONLY`.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// It is a programmer error to call this method from another database
/// access method:
///
/// try reader.read { db in
/// // Raises a fatal error
/// try reader.read { ... )
/// }
///
/// - parameter value: A function that accesses the database.
/// - throws: The error thrown by `value`, or any `DatabaseError` that would
/// happen while establishing the read access to the database.
func read<T>(_ block: (Database) throws -> T) throws -> T
func read<T>(_ value: (Database) throws -> T) throws -> T
/// Asynchronously executes a read-only block that takes a
/// Asynchronously executes a read-only function that accepts a
/// database connection.
///
/// Guarantee 1: the block argument is isolated. Eventual concurrent
/// database updates are not visible inside the block:
/// The `value` function runs in an isolated fashion: eventual concurrent
/// database updates are not visible from the function:
///
/// try reader.asyncRead { dbResult in
/// do (
/// reader.asyncRead { dbResult in
/// do {
/// let db = try dbResult.get()
/// // Those two values are guaranteed to be equal, even if the
/// // `player` table is modified between the two requests:
/// // `player` table is modified, between the two requests, by
/// // some other database connection or some other thread.
/// let count1 = try Player.fetchCount(db)
/// let count2 = try Player.fetchCount(db)
/// } catch {
@@ -131,81 +169,83 @@ public protocol DatabaseReader: AnyObject {
/// }
/// }
///
/// Guarantee 2: attempts to write in the database throw a DatabaseError
/// whose resultCode is `SQLITE_READONLY`.
/// Attempts to write in the database throw a DatabaseError with
/// resultCode `SQLITE_READONLY`.
///
/// - parameter block: A block that accesses the database.
func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void)
/// - parameter value: A function that accesses the database. Its argument
/// is a `Result` that provides the database connection, or the failure
/// that would prevent establishing the read access to the database.
func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void)
/// Same as asyncRead, but without retaining self
///
/// :nodoc:
func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void)
func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void)
/// Synchronously executes a read-only block that takes a database
/// Synchronously executes a function that accepts a database
/// connection, and returns its result.
///
/// The two guarantees of the safe `read` method are lifted:
/// For example:
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
/// let count = try reader.unsafeRead { db in
/// try Player.fetchCount(db)
/// }
///
/// The guarantees of the `read` method are lifted:
///
/// the `value` function is not isolated: eventual concurrent database
/// updates are visible from the function:
///
/// try reader.unsafeRead { db in
/// // Those two values may be different because some other thread
/// // may have inserted or deleted a player between the two requests:
/// // Those two values can be different, because some other
/// // database connection or some other thread may modify the
/// // database between the two requests.
/// let count1 = try Player.fetchCount(db)
/// let count2 = try Player.fetchCount(db)
/// }
///
/// Cursor iterations are isolated, though:
///
/// try reader.unsafeRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, sql: "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// The block argument is not prevented from writing (DatabaseQueue, in
/// The `value` function is not prevented from writing (DatabaseQueue, in
/// particular, will accept database modifications in `unsafeRead`).
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// It is a programmer error to call this method from another database
/// access method:
///
/// try reader.read { db in
/// // Raises a fatal error
/// try reader.unsafeRead { ... )
/// }
///
/// - parameter value: A function that accesses the database.
/// - throws: The error thrown by `value`, or any `DatabaseError` that would
/// happen while establishing the read access to the database.
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T
func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
/// Synchronously executes a block that takes a database connection, and
/// returns its result.
/// Synchronously executes a function that accepts a database
/// connection, and returns its result.
///
/// The two guarantees of the safe `read` method are lifted:
/// The guarantees of the safe `read` method are lifted:
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
/// the `value` function is not isolated: eventual concurrent database
/// updates are visible from the function:
///
/// try reader.unsafeReentrantRead { db in
/// // Those two values may be different because some other thread
/// // may have inserted or deleted a player between the two requests:
/// // Those two values can be different, because some other
/// // database connection or some other thread may modify the
/// // database between the two requests.
/// let count1 = try Player.fetchCount(db)
/// let count2 = try Player.fetchCount(db)
/// }
///
/// Cursor iterations are isolated, though:
///
/// try reader.unsafeReentrantRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, sql: "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// The block argument is not prevented from writing (DatabaseQueue, in
/// particular, will accept database modifications in `unsafeReentrantRead`).
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block, or any DatabaseError that would
/// happen while establishing the read access to the database.
/// The `value` function is not prevented from writing (DatabaseQueue, in
/// particular, will accept database modifications in `unsafeRead`).
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T
///
/// - parameter value: A function that accesses the database.
/// - throws: The error thrown by `value`, or any `DatabaseError` that would
/// happen while establishing the read access to the database.
func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T
// MARK: - Value Observation
@@ -353,7 +393,11 @@ extension DatabaseReader {
{
if scheduler.immediateInitialValue() {
do {
let value = try unsafeReentrantRead(observation.fetchValue)
let value = try unsafeReentrantRead { db in
try db.isolated(readOnly: true) {
try observation.fetchValue(db)
}
}
onChange(value)
} catch {
observation.events.didFail?(error)
@@ -400,6 +444,10 @@ public final class AnyDatabaseReader: DatabaseReader {
base.configuration
}
public func close() throws {
try base.close()
}
// MARK: - Interrupting Database Operations
public func interrupt() {
@@ -408,25 +456,25 @@ public final class AnyDatabaseReader: DatabaseReader {
// MARK: - Reading from Database
public func read<T>(_ block: (Database) throws -> T) throws -> T {
try base.read(block)
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try base.read(value)
}
public func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void) {
base.asyncRead(block)
public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void) {
base.asyncRead(value)
}
/// :nodoc:
public func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void) {
base._weakAsyncRead(block)
public func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void) {
base._weakAsyncRead(value)
}
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
try base.unsafeRead(block)
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeRead(value)
}
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
try base.unsafeReentrantRead(block)
public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeReentrantRead(value)
}
// MARK: - Value Observation
+53 -24
View File
@@ -20,9 +20,9 @@
///
/// - `DatabaseRegion(table:)`: the region that covers one database table.
///
/// - `SelectStatement.databaseRegion`:
/// - `Statement.databaseRegion`:
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name, score FROM player")
/// let statement = try db.makeStatement(sql: "SELECT name, score FROM player")
/// let region = statement.databaseRegion
///
/// - `FetchRequest.databaseRegion(_:)`
@@ -30,9 +30,9 @@
/// let request = Player.filter(key: 1)
/// let region = try request.databaseRegion(db)
public struct DatabaseRegion: CustomStringConvertible, Equatable {
private let tableRegions: [String: TableRegion]?
private let tableRegions: [CaseInsensitiveIdentifier: TableRegion]?
private init(tableRegions: [String: TableRegion]?) {
private init(tableRegions: [CaseInsensitiveIdentifier: TableRegion]?) {
self.tableRegions = tableRegions
}
@@ -60,20 +60,25 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
self.init(tableRegions: [:])
}
// TODO: @available(*, deprecated, message: "In order to specify a table region, prefer `Table(tableName)`")
/// Creates a region that spans all rows and columns of a database table.
///
/// - parameter table: A table name.
public init(table: String) {
let table = CaseInsensitiveIdentifier(rawValue: table)
self.init(tableRegions: [table: TableRegion(columns: nil, rowIds: nil)])
}
/// Full columns in a table: (some columns in a table) × (all rows)
init(table: String, columns: Set<String>) {
let table = CaseInsensitiveIdentifier(rawValue: table)
let columns = Set(columns.map(CaseInsensitiveIdentifier.init))
self.init(tableRegions: [table: TableRegion(columns: columns, rowIds: nil)])
}
/// Full rows in a table: (all columns in a table) × (some rows)
init(table: String, rowIds: Set<Int64>) {
let table = CaseInsensitiveIdentifier(rawValue: table)
self.init(tableRegions: [table: TableRegion(columns: nil, rowIds: rowIds)])
}
@@ -86,7 +91,7 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
guard let tableRegions = tableRegions else { return other }
guard let otherTableRegions = other.tableRegions else { return self }
var tableRegionsIntersection: [String: TableRegion] = [:]
var tableRegionsIntersection: [CaseInsensitiveIdentifier: TableRegion] = [:]
for (table, tableRegion) in tableRegions {
guard let otherTableRegion = otherTableRegions
.first(where: { (otherTable, _) in otherTable == table })?
@@ -105,6 +110,7 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
return DatabaseRegion(table: table, rowIds: rowIds)
}
let table = CaseInsensitiveIdentifier(rawValue: table)
guard let tableRegion = tableRegions[table] else {
return self
}
@@ -123,7 +129,7 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
guard let tableRegions = tableRegions else { return .fullDatabase }
guard let otherTableRegions = other.tableRegions else { return .fullDatabase }
var tableRegionsUnion: [String: TableRegion] = [:]
var tableRegionsUnion: [CaseInsensitiveIdentifier: TableRegion] = [:]
let tableNames = Set(tableRegions.keys).union(Set(otherTableRegions.keys))
for table in tableNames {
let tableRegion = tableRegions[table]
@@ -148,24 +154,39 @@ public struct DatabaseRegion: CustomStringConvertible, Equatable {
self = union(other)
}
/// Returns a region suitable for database observation by removing views.
/// Returns a region suitable for database observation
func observableRegion(_ db: Database) throws -> DatabaseRegion {
// SQLite does not expose schema changes to the
// TransactionObserver protocol. By removing internal SQLite tables from
// the observed region, we optimize database observation.
//
// And by canonicalizing table names, we remove views, and help the
// `isModified` methods.
try ignoringInternalSQLiteTables().canonicalTables(db)
}
/// Returns a region only made of actual tables with their canonical names.
/// Canonical names help the `isModified` methods.
///
/// We can do it because modifications only happen in actual tables. And we
/// want to do it because we have a fast path for regions that span a
/// single table.
func ignoringViews(_ db: Database) throws -> DatabaseRegion {
/// This method removes views (assuming no table exists with the same name
/// as a view).
private func canonicalTables(_ db: Database) throws -> DatabaseRegion {
guard let tableRegions = tableRegions else { return .fullDatabase }
let viewNames = try db.schema().names(ofType: .view)
guard viewNames.isEmpty == false else { return self }
let filteredRegions = tableRegions.filter { viewNames.contains($0.key) == false }
return DatabaseRegion(tableRegions: filteredRegions)
var region = DatabaseRegion()
for (table, tableRegion) in tableRegions {
if let canonicalTableName = try db.canonicalTableName(table.rawValue) {
let table = CaseInsensitiveIdentifier(rawValue: canonicalTableName)
region.formUnion(DatabaseRegion(tableRegions: [table: tableRegion]))
}
}
return region
}
/// Returns a region which doesn't contain any SQLite internal table.
func ignoringInternalSQLiteTables() -> DatabaseRegion {
private func ignoringInternalSQLiteTables() -> DatabaseRegion {
guard let tableRegions = tableRegions else { return .fullDatabase }
let filteredRegions = tableRegions.filter {
!Database.isSQLiteInternalTable($0.key)
!Database.isSQLiteInternalTable($0.key.rawValue)
}
return DatabaseRegion(tableRegions: filteredRegions)
}
@@ -192,7 +213,7 @@ extension DatabaseRegion {
return true
}
guard let tableRegion = tableRegions[event.tableName] else {
guard let tableRegion = tableRegions[CaseInsensitiveIdentifier(rawValue: event.tableName)] else {
// FTS4 (and maybe other virtual tables) perform unadvertised
// changes. For example, an "INSERT INTO document ..." statement
// advertises an insertion in the `document` table, but the
@@ -240,11 +261,11 @@ extension DatabaseRegion {
return "empty"
}
return tableRegions
.sorted(by: { (l, r) in l.key < r.key })
.sorted(by: { (l, r) in l.key.rawValue < r.key.rawValue })
.map({ (table, tableRegion) in
var desc = table
var desc = table.rawValue
if let columns = tableRegion.columns {
desc += "(" + columns.sorted().joined(separator: ",") + ")"
desc += "(" + columns.map(\.rawValue).sorted().joined(separator: ",") + ")"
} else {
desc += "(*)"
}
@@ -258,7 +279,7 @@ extension DatabaseRegion {
}
private struct TableRegion: Equatable {
var columns: Set<String>? // nil means "all columns"
var columns: Set<CaseInsensitiveIdentifier>? // nil means "all columns"
var rowIds: Set<Int64>? // nil means "all rowids"
var isEmpty: Bool {
@@ -268,7 +289,7 @@ private struct TableRegion: Equatable {
}
func intersection(_ other: TableRegion) -> TableRegion {
let columnsIntersection: Set<String>?
let columnsIntersection: Set<CaseInsensitiveIdentifier>?
switch (self.columns, other.columns) {
case let (nil, columns), let (columns, nil):
columnsIntersection = columns
@@ -288,7 +309,7 @@ private struct TableRegion: Equatable {
}
func union(_ other: TableRegion) -> TableRegion {
let columnsUnion: Set<String>?
let columnsUnion: Set<CaseInsensitiveIdentifier>?
switch (self.columns, other.columns) {
case (nil, _), (_, nil):
columnsUnion = nil
@@ -328,6 +349,14 @@ public protocol DatabaseRegionConvertible {
func databaseRegion(_ db: Database) throws -> DatabaseRegion
}
#if compiler(>=5.5)
extension DatabaseRegionConvertible where Self == DatabaseRegion {
/// The region that covers the full database: all columns and all rows
/// from all tables.
public static var fullDatabase: Self { DatabaseRegion.fullDatabase }
}
#endif
extension DatabaseRegion: DatabaseRegionConvertible {
/// :nodoc:
public func databaseRegion(_ db: Database) throws -> DatabaseRegion {
+1 -1
View File
@@ -91,7 +91,7 @@ extension DatabaseRegionObservation {
// Use unsafeReentrantWrite so that observation can start from any
// dispatch queue.
return try dbWriter.unsafeReentrantWrite { db -> TransactionObserver in
let region = try observedRegion(db).ignoringViews(db)
let region = try observedRegion(db).observableRegion(db)
let observer = DatabaseRegionObserver(region: region, onChange: onChange)
db.add(transactionObserver: observer, extent: extent)
return observer
+32 -12
View File
@@ -1,10 +1,30 @@
/// A thread-unsafe database schema cache
struct DatabaseSchemaCache {
/// A cached value
///
/// We cache both hits and misses, because we often query both the temp
/// schema and the main schema: not remembering misses would have us
/// perform too many database queries.
enum Presence<T> {
/// Value does not exist in the schema.
case missing
/// Value exists in the schema.
case value(T)
var value: T? {
switch self {
case .missing: return nil
case let .value(value): return value
}
}
}
var schemaInfo: SchemaInfo?
private var primaryKeys: [String: PrimaryKeyInfo] = [:]
private var columns: [String: [ColumnInfo]] = [:]
private var indexes: [String: [IndexInfo]] = [:]
private var foreignKeys: [String: [ForeignKeyInfo]] = [:]
private var primaryKeys: [String: Presence<PrimaryKeyInfo>] = [:]
private var columns: [String: Presence<[ColumnInfo]>] = [:]
private var indexes: [String: Presence<[IndexInfo]>] = [:]
private var foreignKeys: [String: Presence<[ForeignKeyInfo]>] = [:]
mutating func clear() {
primaryKeys = [:]
@@ -14,35 +34,35 @@ struct DatabaseSchemaCache {
schemaInfo = nil
}
func primaryKey(_ table: String) -> PrimaryKeyInfo? {
func primaryKey(_ table: String) -> Presence<PrimaryKeyInfo>? {
primaryKeys[table]
}
mutating func set(primaryKey: PrimaryKeyInfo, forTable table: String) {
mutating func set(primaryKey: Presence<PrimaryKeyInfo>, forTable table: String) {
primaryKeys[table] = primaryKey
}
func columns(in table: String) -> [ColumnInfo]? {
func columns(in table: String) -> Presence<[ColumnInfo]>? {
columns[table]
}
mutating func set(columns: [ColumnInfo], forTable table: String) {
mutating func set(columns: Presence<[ColumnInfo]>, forTable table: String) {
self.columns[table] = columns
}
func indexes(on table: String) -> [IndexInfo]? {
func indexes(on table: String) -> Presence<[IndexInfo]>? {
indexes[table]
}
mutating func set(indexes: [IndexInfo], forTable table: String) {
mutating func set(indexes: Presence<[IndexInfo]>, forTable table: String) {
self.indexes[table] = indexes
}
func foreignKeys(on table: String) -> [ForeignKeyInfo]? {
func foreignKeys(on table: String) -> Presence<[ForeignKeyInfo]>? {
foreignKeys[table]
}
mutating func set(foreignKeys: [ForeignKeyInfo], forTable table: String) {
mutating func set(foreignKeys: Presence<[ForeignKeyInfo]>, forTable table: String) {
self.foreignKeys[table] = foreignKeys
}
}
+14 -34
View File
@@ -5,7 +5,7 @@ import Dispatch
///
/// See DatabasePool.makeSnapshot()
///
/// For more information, read about "snapshot isolation" at https://sqlite.org/isolation.html
/// For more information, read about "snapshot isolation" at <https://sqlite.org/isolation.html>
public class DatabaseSnapshot: DatabaseReader {
private var serializedDatabase: SerializedDatabase
@@ -26,7 +26,6 @@ public class DatabaseSnapshot: DatabaseReader {
serializedDatabase = try SerializedDatabase(
path: path,
configuration: configuration,
schemaCache: DatabaseSchemaCache(),
defaultLabel: defaultLabel,
purpose: purpose)
@@ -41,7 +40,7 @@ public class DatabaseSnapshot: DatabaseReader {
try db.beginTransaction(.deferred)
// Acquire snapshot isolation
try db.internalCachedSelectStatement(sql: "SELECT rootpage FROM sqlite_master LIMIT 1").makeCursor().next()
try db.internalCachedStatement(sql: "SELECT rootpage FROM sqlite_master LIMIT 1").makeCursor().next()
#if SQLITE_ENABLE_SNAPSHOT
// We must expect an error: https://www.sqlite.org/c3ref/snapshot_get.html
@@ -62,6 +61,10 @@ public class DatabaseSnapshot: DatabaseReader {
try? db.commit()
}
}
public func close() throws {
try serializedDatabase.sync { try $0.close() }
}
}
// DatabaseReader
@@ -75,48 +78,25 @@ extension DatabaseSnapshot {
// MARK: - Reading from Database
/// Synchronously executes a read-only block that takes a database
/// connection, and returns its result.
///
/// let players = try snapshot.read { db in
/// try Player.fetchAll(...)
/// }
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
try serializedDatabase.sync(block)
}
/// Asynchronously executes a read-only block in a protected dispatch queue.
///
/// let players = try snapshot.asyncRead { dbResult in
/// do {
/// let db = try dbResult.get()
/// let count = try Player.fetchCount(db)
/// } catch {
/// // Handle error
/// }
/// }
///
/// - parameter block: A block that accesses the database.
public func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void) {
serializedDatabase.async { block(.success($0)) }
public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void) {
serializedDatabase.async { value(.success($0)) }
}
/// :nodoc:
public func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void) {
serializedDatabase.weakAsync { block($0.map { .success($0) }) }
public func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void) {
serializedDatabase.weakAsync { value($0.map { .success($0) }) }
}
/// :nodoc:
public func unsafeRead<T>(_ block: (Database) throws -> T) rethrows -> T {
try serializedDatabase.sync(block)
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
try serializedDatabase.sync(value)
}
/// :nodoc:
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
try serializedDatabase.reentrantSync(block)
public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T {
try serializedDatabase.reentrantSync(value)
}
// MARK: - Database Observation
+17 -63
View File
@@ -4,8 +4,8 @@ import Foundation
/// DatabaseValue is the intermediate type between SQLite and your values.
///
/// See https://www.sqlite.org/datatype3.html
public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueConvertible, SQLExpression {
/// See <https://www.sqlite.org/datatype3.html>
public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueConvertible, SQLSpecificExpressible {
/// The SQLite storage
public let storage: Storage
@@ -13,6 +13,7 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
public static let null = DatabaseValue(storage: .null)
/// An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).
@frozen
public enum Storage: Equatable {
/// The NULL storage class.
case null
@@ -137,69 +138,23 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
fatalError("Unexpected SQLite column type: \(type)")
}
}
// MARK: SQLExpression
/// :nodoc:
public func _expressionSQL(_ context: SQLGenerationContext, wrappedInParenthesis: Bool) throws -> String {
if isNull {
// fast path for NULL
return "NULL"
} else if context.append(arguments: [self]) {
// Use statement arguments
return "?"
} else {
// Quoting needed: just use SQLite, which knows better.
return try String.fetchOne(context.db, sql: "SELECT QUOTE(?)", arguments: [self])!
}
}
/// :nodoc:
public func _identifyingRowIDs(_ db: Database, for alias: TableAlias) throws -> Set<Int64>? {
if isNull || self == false.databaseValue {
// Those requests select no row:
// - WHERE NULL
// - WHERE 0
return []
}
return nil
}
// Specific boolean checks for null, true, and false
/// :nodoc:
public func _is(_ test: _SQLBooleanTest) -> SQLExpression {
}
extension DatabaseValue: StatementBinding {
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
switch storage {
case .null:
return DatabaseValue.null
case .int64(let int64) where int64 == 0 || int64 == 1:
switch test {
case .true:
return (int64 == 1).sqlExpression
case .false, .falsey:
return (int64 == 0).sqlExpression
}
default:
switch test {
case .true:
return SQLExpressionEqual(.equal, self, true.sqlExpression)
case .false:
return SQLExpressionEqual(.equal, self, false.sqlExpression)
case .falsey:
return SQLExpressionNot(self)
}
return sqlite3_bind_null(sqliteStatement, index)
case .int64(let int64):
return int64.bind(to: sqliteStatement, at: index)
case .double(let double):
return double.bind(to: sqliteStatement, at: index)
case .string(let string):
return string.bind(to: sqliteStatement, at: index)
case .blob(let data):
return data.bind(to: sqliteStatement, at: index)
}
}
/// :nodoc:
public var _isConstantInRequest: Bool { true }
/// :nodoc:
public var _isTrue: Bool { self == true.databaseValue }
/// :nodoc:
public func _qualifiedExpression(with alias: TableAlias) -> SQLExpression { self }
}
// MARK: - Hashable & Equatable
@@ -276,9 +231,8 @@ extension DatabaseValue {
// SQLExpressible
extension DatabaseValue {
/// :nodoc:
public var sqlExpression: SQLExpression {
self
.databaseValue(self)
}
}
-315
View File
@@ -1,315 +0,0 @@
// MARK: - Conversion Context and Errors
/// A type that helps the user understanding value conversion errors
struct ValueConversionContext: Refinable {
private enum Column {
case columnIndex(Int)
case columnName(String)
}
var row: Row?
var sql: String?
var arguments: StatementArguments?
private var column: Column?
func atColumn(_ columnIndex: Int) -> Self {
with(\.column, .columnIndex(columnIndex))
}
func atColumn(_ columnName: String) -> Self {
with(\.column, .columnName(columnName))
}
var columnIndex: Int? {
guard let column = column else { return nil }
switch column {
case .columnIndex(let index):
return index
case .columnName(let name):
return row?.index(forColumn: name)
}
}
var columnName: String? {
guard let column = column else { return nil }
switch column {
case .columnIndex(let index):
guard let row = row else { return nil }
return Array(row.columnNames)[index]
case .columnName(let name):
return name
}
}
}
extension ValueConversionContext {
init(_ statement: SelectStatement) {
self.init(
row: Row(statement: statement).copy(),
sql: statement.sql,
arguments: statement.arguments,
column: nil)
}
init(_ row: Row) {
if let statement = row.statement {
self.init(
row: row.copy(),
sql: statement.sql,
arguments: statement.arguments,
column: nil)
} else if let sqliteStatement = row.sqliteStatement {
let sql = String(cString: sqlite3_sql(sqliteStatement)).trimmingCharacters(in: .sqlStatementSeparators)
self.init(
row: row.copy(),
sql: sql,
arguments: nil,
column: nil)
} else {
self.init(
row: row.copy(),
sql: nil,
arguments: nil,
column: nil)
}
}
}
/// The canonical conversion error message
///
/// - parameter dbValue: nil means "missing column"
func conversionErrorMessage<T>(
to: T.Type,
from dbValue: DatabaseValue?,
conversionContext: ValueConversionContext?)
-> String
{
var message: String
var extras: [String] = []
if let dbValue = dbValue {
message = "could not convert database value \(dbValue) to \(T.self)"
if let columnName = conversionContext?.columnName {
extras.append("column: `\(columnName)`")
}
if let columnIndex = conversionContext?.columnIndex {
extras.append("column index: \(columnIndex)")
}
} else {
message = "could not read \(T.self) from missing column"
if let columnName = conversionContext?.columnName {
message += " `\(columnName)`"
}
}
if let row = conversionContext?.row {
extras.append("row: \(row)")
}
if let sql = conversionContext?.sql {
extras.append("sql: `\(sql)`")
if let arguments = conversionContext?.arguments, arguments.isEmpty == false {
extras.append("arguments: \(arguments)")
}
}
if extras.isEmpty == false {
message += " (" + extras.joined(separator: ", ") + ")"
}
return message
}
/// The canonical conversion fatal error
///
/// - parameter dbValue: nil means "missing column", for consistency with (row["missing"] as DatabaseValue? == nil)
func fatalConversionError<T>(
to: T.Type,
from dbValue: DatabaseValue?,
conversionContext: ValueConversionContext?,
file: StaticString = #file,
line: UInt = #line)
-> Never
{
fatalError(
conversionErrorMessage(
to: T.self,
from: dbValue,
conversionContext: conversionContext),
file: file,
line: line)
}
@usableFromInline
func fatalConversionError<T>(
to: T.Type,
from dbValue: DatabaseValue?,
in row: Row,
atColumn columnName: String,
file: StaticString = #file,
line: UInt = #line)
-> Never
{
fatalConversionError(
to: T.self,
from: dbValue,
conversionContext: ValueConversionContext(row).atColumn(columnName))
}
@usableFromInline
func fatalConversionError<T>(
to: T.Type,
sqliteStatement: SQLiteStatement,
index: Int32,
file: StaticString = #file,
line: UInt = #line)
-> Never
{
let row = Row(sqliteStatement: sqliteStatement)
fatalConversionError(
to: T.self,
from: DatabaseValue(sqliteStatement: sqliteStatement, index: index),
conversionContext: ValueConversionContext(row).atColumn(Int(index)))
}
@usableFromInline
func fatalConversionError<T>(
to: T.Type,
from dbValue: DatabaseValue?,
sqliteStatement: SQLiteStatement,
index: Int32,
file: StaticString = #file,
line: UInt = #line)
-> Never
{
let row = Row(sqliteStatement: sqliteStatement)
fatalConversionError(
to: T.self,
from: dbValue,
conversionContext: ValueConversionContext(row).atColumn(Int(index)))
}
// MARK: - DatabaseValueConvertible
/// Lossless conversions from database values and rows
extension DatabaseValueConvertible {
@usableFromInline
static func decode(from sqliteStatement: SQLiteStatement, atUncheckedIndex index: Int32) -> Self {
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: index)
if let value = fromDatabaseValue(dbValue) {
return value
} else {
fatalConversionError(to: Self.self, from: dbValue, sqliteStatement: sqliteStatement, index: index)
}
}
static func decode(
from dbValue: DatabaseValue,
conversionContext: @autoclosure () -> ValueConversionContext?)
-> Self
{
if let value = fromDatabaseValue(dbValue) {
return value
} else {
fatalConversionError(to: Self.self, from: dbValue, conversionContext: conversionContext())
}
}
@usableFromInline
static func decode(from row: Row, atUncheckedIndex index: Int) -> Self {
decode(
from: row.impl.databaseValue(atUncheckedIndex: index),
conversionContext: ValueConversionContext(row).atColumn(index))
}
@usableFromInline
static func decodeIfPresent(from sqliteStatement: SQLiteStatement, atUncheckedIndex index: Int32) -> Self? {
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: index)
if let value = fromDatabaseValue(dbValue) {
return value
} else if dbValue.isNull {
return nil
} else {
fatalConversionError(to: Self.self, from: dbValue, sqliteStatement: sqliteStatement, index: index)
}
}
static func decodeIfPresent(
from dbValue: DatabaseValue,
conversionContext: @autoclosure () -> ValueConversionContext?)
-> Self?
{
// Use fromDatabaseValue before checking for null: this allows DatabaseValue to convert NULL to .null.
if let value = fromDatabaseValue(dbValue) {
return value
} else if dbValue.isNull {
return nil
} else {
fatalConversionError(to: Self.self, from: dbValue, conversionContext: conversionContext())
}
}
@usableFromInline
static func decodeIfPresent(from row: Row, atUncheckedIndex index: Int) -> Self? {
decodeIfPresent(
from: row.impl.databaseValue(atUncheckedIndex: index),
conversionContext: ValueConversionContext(row).atColumn(index))
}
}
// MARK: - DatabaseValueConvertible & StatementColumnConvertible
/// Lossless conversions from database values and rows
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
@inlinable
static func fastDecode(from sqliteStatement: SQLiteStatement, atUncheckedIndex index: Int32) -> Self {
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
fatalConversionError(to: Self.self, sqliteStatement: sqliteStatement, index: index)
}
return self.init(sqliteStatement: sqliteStatement, index: index)
}
@inlinable
static func fastDecode(from row: Row, atUncheckedIndex index: Int) -> Self {
if let sqliteStatement = row.sqliteStatement {
return fastDecode(from: sqliteStatement, atUncheckedIndex: Int32(index))
}
return row.fastDecode(Self.self, atUncheckedIndex: index)
}
@inlinable
static func fastDecodeIfPresent(from sqliteStatement: SQLiteStatement, atUncheckedIndex index: Int32) -> Self? {
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
return nil
}
return self.init(sqliteStatement: sqliteStatement, index: index)
}
@inlinable
static func fastDecodeIfPresent(from row: Row, atUncheckedIndex index: Int) -> Self? {
if let sqliteStatement = row.sqliteStatement {
return fastDecodeIfPresent(from: sqliteStatement, atUncheckedIndex: Int32(index))
}
return row.fastDecodeIfPresent(Self.self, atUncheckedIndex: index)
}
}
// Support for @inlinable decoding
extension Row {
@usableFromInline
func fastDecode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int)
-> Value
{
impl.fastDecode(type, atUncheckedIndex: index)
}
@usableFromInline
func fastDecodeIfPresent<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int)
-> Value?
{
impl.fastDecodeIfPresent(type, atUncheckedIndex: index)
}
}
+194 -56
View File
@@ -8,27 +8,115 @@
/// try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...) // [String]
/// try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...) // String?
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// try String.fetchCursor(statement, arguments:...) // Cursor of String
/// try String.fetchAll(statement, arguments:...) // [String]
/// try String.fetchOne(statement, arguments:...) // String?
///
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
public protocol DatabaseValueConvertible: SQLExpressible {
public protocol DatabaseValueConvertible: SQLExpressible, StatementBinding {
/// Returns a value that can be stored in the database.
var databaseValue: DatabaseValue { get }
/// Returns a value initialized from *dbValue*, if possible.
/// Returns a value initialized from `dbValue`, if possible.
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
}
extension DatabaseValueConvertible {
/// :nodoc:
public var sqlExpression: SQLExpression {
databaseValue
.databaseValue(databaseValue)
}
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
databaseValue.bind(to: sqliteStatement, at: index)
}
}
// MARK: - Conversions
extension DatabaseValueConvertible {
static func decode(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
if let value = fromDatabaseValue(dbValue) {
return value
} else {
throw RowDecodingError.valueMismatch(Self.self, context: context(), databaseValue: dbValue)
}
}
static func decode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: index)
return try decode(fromDatabaseValue: dbValue, context: context())
}
@usableFromInline
static func decode(fromRow row: Row, atUncheckedIndex index: Int) throws -> Self {
if let sqliteStatement = row.sqliteStatement {
return try decode(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
return try decode(
fromDatabaseValue: row.impl.databaseValue(atUncheckedIndex: index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
static func decodeIfPresent(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Self?
{
// Use fromDatabaseValue before checking for null: this allows DatabaseValue to convert NULL to .null.
if let value = fromDatabaseValue(dbValue) {
return value
} else if dbValue.isNull {
return nil
} else {
throw RowDecodingError.valueMismatch(Self.self, context: context(), databaseValue: dbValue)
}
}
static func decodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Self?
{
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: index)
if let value = fromDatabaseValue(dbValue) {
return value
} else if dbValue.isNull {
return nil
} else {
throw RowDecodingError.valueMismatch(Self.self, context: context(), databaseValue: dbValue)
}
}
@usableFromInline
static func decodeIfPresent(fromRow row: Row, atUncheckedIndex index: Int) throws -> Self? {
if let sqliteStatement = row.sqliteStatement {
return try decodeIfPresent(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
return try decodeIfPresent(
fromDatabaseValue: row.impl.databaseValue(atUncheckedIndex: index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
}
// MARK: - Cursors
/// A cursor of database values extracted from a single column.
/// For example:
///
@@ -39,12 +127,16 @@ extension DatabaseValueConvertible {
/// }
/// }
public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor {
@usableFromInline let _statement: SelectStatement
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline let _columnIndex: Int32
@usableFromInline var _done = false
private enum _State {
case idle, busy, done, failed
}
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
private let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private let _columnIndex: Int32
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
_sqliteStatement = statement.sqliteStatement
if let adapter = adapter {
@@ -53,33 +145,54 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor
} else {
_columnIndex = 0
}
_statement.reset(withArguments: arguments)
// Assume cursor is created for iteration
try statement.database.selectStatementWillExecute(statement)
// Assume cursor is created for immediate iteration: reset and set arguments
statement.reset(withArguments: arguments)
}
deinit {
if _state == .busy {
try? _statement.database.statementDidExecute(_statement)
}
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? _statement.reset()
}
@inlinable
public func next() throws -> Value? {
if _done {
switch _state {
case .done:
// make sure this instance never yields a value again, even if the
// statement is reset by another cursor.
return nil
case .idle:
guard try _statement.database.statementWillExecute(_statement) == nil else {
throw DatabaseError(
resultCode: SQLITE_MISUSE,
message: "Can't run statement that requires a customized authorizer from a cursor",
sql: _statement.sql,
arguments: _statement.arguments)
}
_state = .busy
default:
break
}
switch sqlite3_step(_sqliteStatement) {
case SQLITE_DONE:
_done = true
_state = .done
try _statement.database.statementDidExecute(_statement)
return nil
case SQLITE_ROW:
return Value.decode(from: _sqliteStatement, atUncheckedIndex: _columnIndex)
// TODO GRDB6: don't crash on decoding errors
return try! Value.decode(
fromStatement: _sqliteStatement,
atUncheckedIndex: _columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(_columnIndex)))
case let code:
try _statement.didFail(withResultCode: code)
_state = .failed
try _statement.database.statementDidFail(_statement, withResultCode: code)
}
}
}
@@ -94,12 +207,16 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor
/// }
/// }
public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor {
@usableFromInline let _statement: SelectStatement
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline let _columnIndex: Int32
@usableFromInline var _done = false
private enum _State {
case idle, busy, done, failed
}
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
private let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private let _columnIndex: Int32
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
_sqliteStatement = statement.sqliteStatement
if let adapter = adapter {
@@ -108,33 +225,54 @@ public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>:
} else {
_columnIndex = 0
}
_statement.reset(withArguments: arguments)
// Assume cursor is created for iteration
try statement.database.selectStatementWillExecute(statement)
// Assume cursor is created for immediate iteration: reset and set arguments
statement.reset(withArguments: arguments)
}
deinit {
if _state == .busy {
try? _statement.database.statementDidExecute(_statement)
}
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? _statement.reset()
}
@inlinable
public func next() throws -> Value?? {
if _done {
switch _state {
case .done:
// make sure this instance never yields a value again, even if the
// statement is reset by another cursor.
return nil
case .idle:
guard try _statement.database.statementWillExecute(_statement) == nil else {
throw DatabaseError(
resultCode: SQLITE_MISUSE,
message: "Can't run statement that requires a customized authorizer from a cursor",
sql: _statement.sql,
arguments: _statement.arguments)
}
_state = .busy
default:
break
}
switch sqlite3_step(_sqliteStatement) {
case SQLITE_DONE:
_done = true
_state = .done
try _statement.database.statementDidExecute(_statement)
return nil
case SQLITE_ROW:
return Value.decodeIfPresent(from: _sqliteStatement, atUncheckedIndex: _columnIndex)
// TODO GRDB6: don't crash on decoding errors
return try! Value.decodeIfPresent(
fromStatement: _sqliteStatement,
atUncheckedIndex: _columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(_columnIndex)))
case let code:
try _statement.didFail(withResultCode: code)
_state = .failed
try _statement.database.statementDidFail(_statement, withResultCode: code)
}
}
}
@@ -146,7 +284,7 @@ public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>:
/// try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...) // [String]
/// try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...) // String?
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// try String.fetchCursor(statement, arguments:...) // Cursor of String
/// try String.fetchAll(statement, arguments:...) // [String]
/// try String.fetchOne(statement, arguments:...) // String
@@ -154,11 +292,11 @@ public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>:
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
extension DatabaseValueConvertible {
// MARK: Fetching From SelectStatement
// MARK: Fetching From Prepared Statement
/// Returns a cursor over values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchCursor(statement) // Cursor of String
/// while let name = try names.next() { // String
/// ...
@@ -176,7 +314,7 @@ extension DatabaseValueConvertible {
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> DatabaseValueCursor<Self>
@@ -186,7 +324,7 @@ extension DatabaseValueConvertible {
/// Returns an array of values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchAll(statement) // [String]
///
/// - parameters:
@@ -196,7 +334,7 @@ extension DatabaseValueConvertible {
/// - returns: An array.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> [Self]
@@ -209,7 +347,7 @@ extension DatabaseValueConvertible {
/// The result is nil if the query returns no row, or if no value can be
/// extracted from the first row.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let name = try String.fetchOne(statement) // String?
///
/// - parameters:
@@ -219,7 +357,7 @@ extension DatabaseValueConvertible {
/// - returns: An optional value.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Self?
@@ -233,7 +371,7 @@ extension DatabaseValueConvertible {
extension DatabaseValueConvertible where Self: Hashable {
/// Returns a set of values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchSet(statement) // Set<String>
///
/// - parameters:
@@ -243,7 +381,7 @@ extension DatabaseValueConvertible where Self: Hashable {
/// - returns: A set.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchSet(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Set<Self>
@@ -282,7 +420,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> DatabaseValueCursor<Self>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
@@ -303,7 +441,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> [Self]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
@@ -327,7 +465,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> Self?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -350,7 +488,7 @@ extension DatabaseValueConvertible where Self: Hashable {
adapter: RowAdapter? = nil)
throws -> Set<Self>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -504,18 +642,18 @@ extension FetchRequest where RowDecoder: DatabaseValueConvertible & Hashable {
/// try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...", arguments:...) // [String?]
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// try Optional<String>.fetchCursor(statement, arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(statement, arguments:...) // [String?]
///
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
extension Optional where Wrapped: DatabaseValueConvertible {
// MARK: Fetching From SelectStatement
// MARK: Fetching From Prepared Statement
/// Returns a cursor over optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
@@ -533,7 +671,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> NullableDatabaseValueCursor<Wrapped>
@@ -543,7 +681,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
/// Returns an array of optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchAll(statement) // [String?]
///
/// - parameters:
@@ -553,7 +691,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
/// - returns: An array of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
@@ -565,7 +703,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
extension Optional where Wrapped: DatabaseValueConvertible & Hashable {
/// Returns a set of optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchSet(statement) // Set<String?>
///
/// - parameters:
@@ -575,7 +713,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & Hashable {
/// - returns: A set of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchSet(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
@@ -614,7 +752,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> NullableDatabaseValueCursor<Wrapped>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
@@ -635,7 +773,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -658,7 +796,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & Hashable {
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
+96 -41
View File
@@ -35,7 +35,13 @@ public protocol DatabaseWriter: DatabaseReader {
/// Eventual concurrent reads are guaranteed to not see any partial updates
/// of the database until the transaction has completed.
///
/// This method is *not* reentrant.
/// It is a programmer error to call this method from another database
/// access method:
///
/// try writer.write { db in
/// // Raises a fatal error
/// try writer.write { ... )
/// }
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates, or by the
@@ -51,7 +57,13 @@ public protocol DatabaseWriter: DatabaseReader {
/// Eventual concurrent reads may see partial updates unless you wrap them
/// in a transaction.
///
/// This method is *not* reentrant.
/// It is a programmer error to call this method from another database
/// access method:
///
/// try writer.write { db in
/// // Raises a fatal error
/// try writer.writeWithoutTransaction { ... )
/// }
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
@@ -64,12 +76,28 @@ public protocol DatabaseWriter: DatabaseReader {
/// until all pending writes and reads are completed. They postpone all
/// other writes and reads until they are completed.
///
/// This method is *not* reentrant.
/// It is a programmer error to call this method from another database
/// access method:
///
/// try writer.write { db in
/// // Raises a fatal error
/// try writer.barrierWriteWithoutTransaction { ... )
/// }
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates.
func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
/// Asynchronously executes database updates in a protected dispatch queue,
/// outside of any transaction, and returns the result.
///
/// Updates are guaranteed an exclusive access to the database. They wait
/// until all pending writes and reads are completed. They postpone all
/// other writes and reads until they are completed.
///
/// - parameter updates: The updates to the database.
func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
/// Asynchronously executes database updates in a protected dispatch queue,
/// wrapped inside a transaction.
///
@@ -154,7 +182,7 @@ public protocol DatabaseWriter: DatabaseReader {
/// // Guaranteed to be zero
/// let count = try future.wait()
/// }
func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> DatabaseFuture<T>
func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T>
// Exposed for RxGRDB and GRBCombine. Naming is not stabilized.
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
@@ -192,28 +220,11 @@ public protocol DatabaseWriter: DatabaseReader {
///
/// - parameter block: A block that accesses the database.
/// :nodoc:
func spawnConcurrentRead(_ block: @escaping (Result<Database, Error>) -> Void)
func spawnConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void)
}
extension DatabaseWriter {
/// Synchronously executes database updates in a protected dispatch queue,
/// wrapped inside a transaction, and returns the result.
///
/// If the updates throw an error, the transaction is rollbacked and the
/// error is rethrown.
///
/// Eventual concurrent database updates are postponed until the transaction
/// has completed.
///
/// Eventual concurrent reads are guaranteed to not see any partial updates
/// of the database until the transaction has completed.
///
/// This method is *not* reentrant.
///
/// - parameter updates: The updates to the database.
/// - throws: The error thrown by the updates, or by the
/// wrapping transaction.
public func write<T>(_ updates: (Database) throws -> T) throws -> T {
try writeWithoutTransaction { db in
var result: T?
@@ -293,11 +304,8 @@ extension DatabaseWriter {
// MARK: - Erasing the content of the database
/// Erases the content of the database.
///
/// - precondition: database is not accessed concurrently during the
/// execution of this method.
public func erase() throws {
try writeWithoutTransaction { try $0.erase() }
try barrierWriteWithoutTransaction { try $0.erase() }
}
// MARK: - Claiming Disk Space
@@ -305,11 +313,50 @@ extension DatabaseWriter {
/// Rebuilds the database file, repacking it into a minimal amount of
/// disk space.
///
/// See https://www.sqlite.org/lang_vacuum.html for more information.
/// See <https://www.sqlite.org/lang_vacuum.html> for more information.
public func vacuum() throws {
try writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
}
// VACUUM INTO was introduced in SQLite 3.27.0:
// https://www.sqlite.org/releaselog/3_27_0.html
//
// Old versions of SQLCipher won't have it, but I don't know how to perform
// availability checks that depend on the version of the SQLCipher CocoaPod
// chosen by the application. So let's just have the method fail at runtime.
//
// This method is declared on DatabaseWriter instead of DatabaseReader,
// so that it is not available on DatabaseSnaphot. VACUUM INTO is not
// available inside the transaction that is kept open by DatabaseSnaphot.
#if GRDBCUSTOMSQLITE || GRDBCIPHER
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
///
/// Databases encrypted with SQLCipher are copied with the same password
/// and configuration as the original database.
///
/// See <https://www.sqlite.org/lang_vacuum.html#vacuuminto> for more information.
///
/// - Parameter filePath: file path for new database
public func vacuum(into filePath: String) throws {
try writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#else
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
/// See <https://www.sqlite.org/lang_vacuum.html#vacuuminto> for more information.
///
/// - Parameter filePath: file path for new database
@available(OSX 10.16, iOS 14, tvOS 14, watchOS 7, *)
public func vacuum(into filePath: String) throws {
try writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#endif
// MARK: - Database Observation
/// A write-only observation only uses the serialized writer
@@ -568,6 +615,10 @@ public final class AnyDatabaseWriter: DatabaseWriter {
base.configuration
}
public func close() throws {
try base.close()
}
// MARK: - Interrupting Database Operations
public func interrupt() {
@@ -576,34 +627,34 @@ public final class AnyDatabaseWriter: DatabaseWriter {
// MARK: - Reading from Database
public func read<T>(_ block: (Database) throws -> T) throws -> T {
try base.read(block)
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try base.read(value)
}
public func asyncRead(_ block: @escaping (Result<Database, Error>) -> Void) {
base.asyncRead(block)
public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void) {
base.asyncRead(value)
}
/// :nodoc:
public func _weakAsyncRead(_ block: @escaping (Result<Database, Error>?) -> Void) {
base._weakAsyncRead(block)
public func _weakAsyncRead(_ value: @escaping (Result<Database, Error>?) -> Void) {
base._weakAsyncRead(value)
}
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
try base.unsafeRead(block)
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeRead(value)
}
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
try base.unsafeReentrantRead(block)
public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeReentrantRead(value)
}
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
base.concurrentRead(block)
public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T> {
base.concurrentRead(value)
}
/// :nodoc:
public func spawnConcurrentRead(_ block: @escaping (Result<Database, Error>) -> Void) {
base.spawnConcurrentRead(block)
public func spawnConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void) {
base.spawnConcurrentRead(value)
}
// MARK: - Writing in Database
@@ -620,6 +671,10 @@ public final class AnyDatabaseWriter: DatabaseWriter {
try base.barrierWriteWithoutTransaction(updates)
}
public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void) {
base.asyncBarrierWriteWithoutTransaction(updates)
}
public func asyncWrite<T>(
_ updates: @escaping (Database) throws -> T,
completion: @escaping (Database, Result<T, Error>) -> Void)
+12 -113
View File
@@ -1,53 +1,5 @@
// MARK: - FetchRequest
/// Implementation details of `FetchRequest`.
///
/// :nodoc:
public protocol _FetchRequest {
/// The number of columns selected by the request.
///
/// This method makes it possible to find the columns of a CTE in a request
/// that includes a CTE association:
///
/// // WITH cte AS (SELECT 1 AS a, 2 AS b)
/// // SELECT player.*, cte.*
/// // FROM player
/// // JOIN cte
/// let cte = CommonTableExpression<Void>(named: "cte", sql: "SELECT 1 AS a, 2 AS b")
/// let request = Player
/// .with(cte)
/// .including(required: Player.association(to: cte))
/// let row = try Row.fetchOne(db, request)!
///
/// // We know that "SELECT 1 AS a, 2 AS b" selects two columns,
/// // so we can find cte columns in the row:
/// row.scopes["cte"] // [a:1, b:2]
///
/// :nodoc:
func _selectedColumnCount(_ db: Database) throws -> Int
/// Returns the request SQL.
///
/// This method makes it possible to embed a request as a subquery:
///
/// // SELECT *
/// // FROM "player"
/// // WHERE "score" = (SELECT MAX("score") FROM "player")
/// let maxScore = Player.select(max(Column("score")))
/// let players = try Player
/// .filter(Column("score") == maxScore)
/// .fetchAll(db)
///
/// - parameter context: An SQL generation context.
/// - parameter singleResult: A hint that a single result row will be
/// consumed. Implementations can optionally use it to optimize the
/// generated SQL, for example by adding a `LIMIT 1` SQL clause.
/// - returns: An SQL string.
///
/// :nodoc:
func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String
}
/// The protocol for all requests that fetch database rows, and tell how those
/// rows should be interpreted.
///
@@ -58,7 +10,7 @@ public protocol _FetchRequest {
/// try request.fetchSet(db) // Set<Player>
/// try request.fetchOne(db) // Player?
/// try request.fetchCount(db) // Int
public protocol FetchRequest: _FetchRequest, DatabaseRegionConvertible, SQLExpression, SQLCollection {
public protocol FetchRequest: SQLSubqueryable, DatabaseRegionConvertible {
/// The type that tells how fetched database rows should be interpreted.
associatedtype RowDecoder
@@ -84,45 +36,12 @@ public protocol FetchRequest: _FetchRequest, DatabaseRegionConvertible, SQLExpre
}
extension FetchRequest {
// MARK: DatabaseRegionConvertible
/// Returns the database region that the request feeds from.
///
/// - parameter db: A database connection.
public func databaseRegion(_ db: Database) throws -> DatabaseRegion {
try makePreparedRequest(db, forSingleResult: false).statement.databaseRegion
}
// MARK: SQLCollection
/// :nodoc:
public var _collectionExpressions: [SQLExpression]? { nil }
/// :nodoc:
public func _collectionSQL(_ context: SQLGenerationContext) throws -> String {
try "("
+ _requestSQL(context, forSingleResult: false)
+ ")"
}
public func contains(_ value: SQLExpressible) -> SQLExpression {
SQLExpressionContains(value, self)
}
/// :nodoc:
public func _qualifiedCollection(with alias: TableAlias) -> SQLCollection { self }
// MARK: SQLExpression
/// :nodoc:
public func _expressionSQL(_ context: SQLGenerationContext, wrappedInParenthesis: Bool) throws -> String {
try "("
+ _requestSQL(context, forSingleResult: false)
+ ")"
}
/// :nodoc:
public func _qualifiedExpression(with alias: TableAlias) -> SQLExpression { self }
}
// MARK: - PreparedRequest
@@ -130,7 +49,7 @@ extension FetchRequest {
/// A PreparedRequest is a request that is ready to be executed.
public struct PreparedRequest {
/// A prepared statement
public var statement: SelectStatement
public var statement: Statement
/// An eventual adapter for rows fetched by the select statement
public var adapter: RowAdapter?
@@ -139,7 +58,7 @@ public struct PreparedRequest {
var supplementaryFetch: ((Database, [Row]) throws -> Void)?
init(
statement: SelectStatement,
statement: Statement,
adapter: RowAdapter?,
supplementaryFetch: ((Database, [Row]) throws -> Void)? = nil)
{
@@ -174,6 +93,10 @@ public struct AdaptedFetchRequest<Base: FetchRequest>: FetchRequest {
self.adapter = adapter
}
public var sqlSubquery: SQLSubquery {
base.sqlSubquery
}
public func fetchCount(_ db: Database) throws -> Int {
try base.fetchCount(db)
}
@@ -193,16 +116,6 @@ public struct AdaptedFetchRequest<Base: FetchRequest>: FetchRequest {
return preparedRequest
}
/// :nodoc:
public func _selectedColumnCount(_ db: Database) throws -> Int {
try base._selectedColumnCount(db)
}
/// :nodoc:
public func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String {
try base._requestSQL(context, forSingleResult: singleResult)
}
}
// MARK: - AnyFetchRequest
@@ -222,9 +135,8 @@ public struct AnyFetchRequest<RowDecoder>: FetchRequest {
AnyFetchRequest<RowDecoder>(request: request)
}
/// :nodoc:
public func _selectedColumnCount(_ db: Database) throws -> Int {
try request._selectedColumnCount(db)
public var sqlSubquery: SQLSubquery {
request.sqlSubquery
}
public func fetchCount(_ db: Database) throws -> Int {
@@ -238,11 +150,6 @@ public struct AnyFetchRequest<RowDecoder>: FetchRequest {
{
try request.makePreparedRequest(db, forSingleResult: singleResult)
}
/// :nodoc:
public func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String {
try request._requestSQL(context, forSingleResult: singleResult)
}
}
extension AnyFetchRequest {
@@ -258,7 +165,7 @@ extension AnyFetchRequest {
private class FetchRequestEraser: FetchRequest {
typealias RowDecoder = Void
func _selectedColumnCount(_ db: Database) throws -> Int {
var sqlSubquery: SQLSubquery {
fatalError("subclass must override")
}
@@ -269,10 +176,6 @@ private class FetchRequestEraser: FetchRequest {
func fetchCount(_ db: Database) throws -> Int {
fatalError("subclass must override")
}
func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String {
fatalError("subclass must override")
}
}
private final class ConcreteFetchRequestEraser<Request: FetchRequest>: FetchRequestEraser {
@@ -282,8 +185,8 @@ private final class ConcreteFetchRequestEraser<Request: FetchRequest>: FetchRequ
self.request = request
}
override func _selectedColumnCount(_ db: Database) throws -> Int {
try request._selectedColumnCount(db)
override var sqlSubquery: SQLSubquery {
request.sqlSubquery
}
override func fetchCount(_ db: Database) throws -> Int {
@@ -293,8 +196,4 @@ private final class ConcreteFetchRequestEraser<Request: FetchRequest>: FetchRequ
override func makePreparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest {
try request.makePreparedRequest(db, forSingleResult: singleResult)
}
override func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String {
try request._requestSQL(context, forSingleResult: singleResult)
}
}
+645 -171
View File
File diff suppressed because it is too large. Load diff
+14 -7
View File
@@ -141,7 +141,7 @@ public protocol _RowLayout {
func _layoutIndex(ofColumn name: String) -> Int?
}
extension SelectStatement: _RowLayout {
extension Statement: _RowLayout {
/// :nodoc:
public var _layoutColumns: [(Int, String)] {
Array(columnNames.enumerated())
@@ -494,23 +494,30 @@ struct AdaptedRowImpl: RowImpl {
func fastDecode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int) -> Value
atUncheckedIndex index: Int)
throws -> Value
{
let mappedIndex = mapping.baseColumnIndex(atMappingIndex: index)
return Value.fastDecode(from: base, atUncheckedIndex: mappedIndex)
return try Value.fastDecode(fromRow: base, atUncheckedIndex: mappedIndex)
}
func fastDecodeIfPresent<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int) -> Value?
atUncheckedIndex index: Int)
throws -> Value?
{
let mappedIndex = mapping.baseColumnIndex(atMappingIndex: index)
return Value.fastDecodeIfPresent(from: base, atUncheckedIndex: mappedIndex)
return try Value.fastDecodeIfPresent(fromRow: base, atUncheckedIndex: mappedIndex)
}
func dataNoCopy(atUncheckedIndex index: Int) -> Data? {
func fastDecodeDataNoCopy(atUncheckedIndex index: Int) throws -> Data {
let mappedIndex = mapping.baseColumnIndex(atMappingIndex: index)
return base.impl.dataNoCopy(atUncheckedIndex: mappedIndex)
return try base.impl.fastDecodeDataNoCopy(atUncheckedIndex: mappedIndex)
}
func fastDecodeDataNoCopyIfPresent(atUncheckedIndex index: Int) throws -> Data? {
let mappedIndex = mapping.baseColumnIndex(atMappingIndex: index)
return try base.impl.fastDecodeDataNoCopyIfPresent(atUncheckedIndex: mappedIndex)
}
func columnName(atUncheckedIndex index: Int) -> String {
+203
View File
@@ -0,0 +1,203 @@
/// A key that is used to decode a value in a row
@usableFromInline
enum RowKey: Hashable {
/// A column name
case columnName(String)
/// A column index
case columnIndex(Int)
/// A scope
case scope(String)
/// A key of prefetched rows
case prefetchKey(String)
}
/// A decoding error
@usableFromInline
enum RowDecodingError: Error {
@usableFromInline
struct Context: CustomDebugStringConvertible {
/// A description of what went wrong, for debugging purposes.
@usableFromInline
let debugDescription: String
/// The row that could not be decoded
let row: Row
/// Nil for RowDecodingError.keyNotFound, in order to avoid redundancy
let key: RowKey?
/// The SQL query
let sql: String?
/// The SQL query arguments
let statementArguments: StatementArguments?
init(decodingContext: RowDecodingContext, debugDescription: String) {
self.debugDescription = debugDescription
self.row = decodingContext.row
self.key = decodingContext.key
self.sql = decodingContext.sql
self.statementArguments = decodingContext.statementArguments
}
}
case keyNotFound(RowKey, Context)
case valueMismatch(Any.Type, Context)
var context: Context {
switch self {
case .keyNotFound(_, let context),
.valueMismatch(_, let context):
return context
}
}
/// Convenience method that builds the
/// `could not decode <Type> from database value <value>` error message.
static func valueMismatch(
_ type: Any.Type,
context: RowDecodingContext,
databaseValue: DatabaseValue)
-> Self
{
valueMismatch(
type,
RowDecodingError.Context(decodingContext: context, debugDescription: """
could not decode \(type) from database value \(databaseValue)
"""))
}
/// Convenience method that builds the
/// `could not decode <Type> from database value <value>` error message.
@usableFromInline
static func valueMismatch(
_ type: Any.Type,
sqliteStatement: SQLiteStatement,
index: Int32,
context: RowDecodingContext)
-> Self
{
valueMismatch(
type,
context: context,
databaseValue: DatabaseValue(sqliteStatement: sqliteStatement, index: index))
}
/// Convenience method that builds the
/// `could not decode <Type> from database value <value>` error message.
static func valueMismatch(
_ type: Any.Type,
statement: Statement,
index: Int)
-> Self
{
valueMismatch(
type,
context: RowDecodingContext(statement: statement, index: index),
databaseValue: DatabaseValue(sqliteStatement: statement.sqliteStatement, index: Int32(index)))
}
/// Convenience method that builds the `column not found: <column>`
/// error message.
@usableFromInline
static func columnNotFound(_ columnName: String, context: RowDecodingContext) -> Self {
keyNotFound(
.columnName(columnName),
RowDecodingError.Context(decodingContext: context, debugDescription: """
column not found: \(String(reflecting: columnName))
"""))
}
}
@usableFromInline
struct RowDecodingContext {
/// The row that is decoded
let row: Row
let key: RowKey?
/// The SQL query
let sql: String?
/// The SQL query arguments
let statementArguments: StatementArguments?
@usableFromInline
init(row: Row, key: RowKey? = nil) {
if let statement = row.statement {
self.key = key
self.row = row.copy()
self.sql = statement.sql
self.statementArguments = statement.arguments
} else if let sqliteStatement = row.sqliteStatement {
self.key = key
self.row = row.copy()
self.sql = String(cString: sqlite3_sql(sqliteStatement)).trimmingCharacters(in: .sqlStatementSeparators)
self.statementArguments = nil // Can't rebuild them
} else {
self.key = key
self.row = row.copy()
self.sql = nil
self.statementArguments = nil
}
}
/// Convenience initializer
@usableFromInline
init(statement: Statement, index: Int) {
self.key = .columnIndex(index)
self.row = Row(copiedFromSQLiteStatement: statement.sqliteStatement, statement: statement)
self.sql = statement.sql
self.statementArguments = statement.arguments
}
}
extension RowDecodingError: CustomStringConvertible {
@usableFromInline
var description: String {
let context = self.context
let row = context.row
var chunks: [String] = []
if let key = context.key {
switch key {
case let .columnIndex(columnIndex):
let rowIndex = row.index(row.startIndex, offsetBy: columnIndex)
let columnName = row.columnNames[rowIndex]
chunks.append("column: \(String(reflecting: columnName))")
chunks.append("column index: \(columnIndex)")
case let .columnName(columnName):
if let columnIndex = row.index(forColumn: columnName) {
chunks.append("column: \(String(reflecting: columnName))")
chunks.append("column index: \(columnIndex)")
} else {
// column name is already mentionned in context.debugDescription
}
case .prefetchKey:
// key is already mentionned in context.debugDescription
break
case .scope:
// scope is already mentionned in context.debugDescription
break
}
}
chunks.append("row: \(row.description)")
if let sql = context.sql {
chunks.append("sql: `\(sql)`")
}
if let statementArguments = context.statementArguments {
chunks.append("arguments: \(statementArguments)")
}
return "\(context.debugDescription) - \(chunks.joined(separator: ", "))"
}
}
+259
View File
@@ -0,0 +1,259 @@
/// `SQL` helps you build SQL literal with
/// [SQL Interpolation](https://github.com/groue/GRDB.swift/blob/master/Documentation/SQLInterpolation.md).
///
/// For example:
///
/// try dbQueue.write { db in
/// let name: String = ...
/// let id: Int64 = ...
/// let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
/// try db.execute(literal: query)
/// }
public struct SQL {
/// `SQL` is an array of elements which can be qualified with table
/// aliases. This is how `SQL` can blend well in the query interface.
enum Element {
// Can't be qualified with a table alias
case sql(String, StatementArguments = StatementArguments())
// Does not need to be qualified with a table alias
case subquery(SQLSubquery)
// Cases below can be qualified with a table alias
case expression(SQLExpression)
case selection(SQLSelection)
case ordering(SQLOrdering)
var isEmpty: Bool {
switch self {
case let .sql(sql, _):
return sql.isEmpty
default:
return false
}
}
fileprivate func sql(_ context: SQLGenerationContext) throws -> String {
switch self {
case let .sql(sql, arguments):
if context.append(arguments: arguments) == false {
// We don't know how to look for `?` in sql and
// replace them with literals.
fatalError("Not implemented: turning an SQL parameter into an SQL literal value")
}
return sql
case let .subquery(subquery):
return try subquery.sql(context)
case let .expression(expression):
return try expression.sql(context)
case let .selection(selection):
return try selection.sql(context)
case let .ordering(ordering):
return try ordering.sql(context)
}
}
fileprivate func qualified(with alias: TableAlias) -> Element {
switch self {
case .sql:
// Can't qualify raw SQL string
return self
case .subquery:
// Subqueries don't need table alias
return self
case let .expression(expression):
return .expression(expression.qualified(with: alias))
case let .selection(selection):
return .selection(selection.qualified(with: alias))
case let .ordering(ordering):
return .ordering(ordering.qualified(with: alias))
}
}
}
private(set) var elements: [Element]
init(elements: [Element]) {
self.elements = elements
}
/// Creates an `SQL` literal from a plain SQL string, and
/// eventual arguments.
///
/// For example:
///
/// let query = SQL(
/// sql: "UPDATE player SET name = ? WHERE id = ?",
/// arguments: [name, id])
public init(sql: String, arguments: StatementArguments = StatementArguments()) {
self.init(elements: [.sql(sql, arguments)])
}
/// Creates an `SQL` literal from an SQL expression.
///
/// For example:
///
/// let columnLiteral = SQL(Column("username"))
/// let suffixLiteral = SQL("@example.com".databaseValue)
/// let emailLiteral = [columnLiteral, suffixLiteral].joined(separator: " || ")
/// let request = User.select(emailLiteral.sqlExpression)
/// let emails = try String.fetchAll(db, request)
public init(_ expression: SQLSpecificExpressible) {
self.init(elements: [.expression(expression.sqlExpression)])
}
/// Returns true if this literal generates an empty SQL string
public var isEmpty: Bool {
elements.allSatisfy(\.isEmpty)
}
/// Turn a `SQL` literal into raw SQL and arguments.
///
/// - parameter db: A database connection.
/// - returns: A tuple made of a raw SQL string, and statement arguments.
public func build(_ db: Database) throws -> (sql: String, arguments: StatementArguments) {
let context = SQLGenerationContext(db)
let sql = try self.sql(context)
return (sql: sql, arguments: context.arguments)
}
/// Returns the literal SQL string given an SQL generation context.
func sql(_ context: SQLGenerationContext) throws -> String {
try elements.map { try $0.sql(context) }.joined()
}
func qualified(with alias: TableAlias) -> SQL {
SQL(elements: elements.map { $0.qualified(with: alias) })
}
}
extension SQL {
/// Returns the `SQL` literal produced by the concatenation of two literals.
///
/// let name = "O'Brien"
/// let selection: SQL = "SELECT * FROM player "
/// let condition: SQL = "WHERE name = \(name)"
/// let query = selection + condition
public static func + (lhs: SQL, rhs: SQL) -> SQL {
var result = lhs
result += rhs
return result
}
/// Appends an `SQL` literal to the receiver.
///
/// let name = "O'Brien"
/// var query: SQL = "SELECT * FROM player "
/// query += "WHERE name = \(name)"
public static func += (lhs: inout SQL, rhs: SQL) {
lhs.elements += rhs.elements
}
/// Appends an `SQL` literal to the receiver.
///
/// let name = "O'Brien"
/// var query: SQL = "SELECT * FROM player "
/// query.append(literal: "WHERE name = \(name)")
public mutating func append(literal sqlLiteral: SQL) {
self += sqlLiteral
}
/// Appends a plain SQL string to the receiver, and eventual arguments.
///
/// let name = "O'Brien"
/// var query: SQL = "SELECT * FROM player "
/// query.append(sql: "WHERE name = ?", arguments: [name])
public mutating func append(sql: String, arguments: StatementArguments = StatementArguments()) {
self += SQL(sql: sql, arguments: arguments)
}
}
extension SQL: SQLSpecificExpressible {
/// Creates a literal SQL expression.
///
/// Use this property when you need an explicit `SQLExpression`.
/// For example:
///
/// func date(_ value: SQLExpressible) -> SQLExpression {
/// SQL("DATE(\(value))").sqlExpression
/// }
///
/// // SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
/// let createdAt = Column("createdAt")
/// let request = Player.filter(date(createdAt) == "2020-01-23")
public var sqlExpression: SQLExpression {
.literal(self)
}
}
extension SQL: SQLSelectable {
public var sqlSelection: SQLSelection {
.literal(self)
}
}
extension SQL: SQLOrderingTerm {
public var sqlOrdering: SQLOrdering {
.literal(self)
}
}
extension Sequence where Element == SQL {
/// Returns the concatenated `SQL` literal of this sequence of literals,
/// inserting the given separator between each element.
///
/// let components: [SQL] = [
/// "UPDATE player",
/// "SET name = \(name)",
/// "WHERE id = \(id)"
/// ]
/// let query = components.joined(separator: " ")
public func joined(separator: String = "") -> SQL {
if separator.isEmpty {
return SQL(elements: flatMap(\.elements))
} else {
return SQL(elements: Array(map(\.elements).joined(separator: CollectionOfOne(.sql(separator)))))
}
}
}
extension Collection where Element == SQL {
/// Returns the concatenated `SQL` literal of this collection of literals,
/// inserting the given SQL separator between each element.
///
/// let components: [SQL] = [
/// "UPDATE player",
/// "SET name = \(name)",
/// "WHERE id = \(id)"
/// ]
/// let query = components.joined(separator: " ")
public func joined(separator: String = "") -> SQL {
if separator.isEmpty {
return SQL(elements: flatMap(\.elements))
} else {
return SQL(elements: Array(map(\.elements).joined(separator: CollectionOfOne(.sql(separator)))))
}
}
}
// MARK: - ExpressibleByStringInterpolation
extension SQL: ExpressibleByStringInterpolation {
/// :nodoc
public init(unicodeScalarLiteral: String) {
self.init(sql: unicodeScalarLiteral, arguments: [])
}
/// :nodoc:
public init(extendedGraphemeClusterLiteral: String) {
self.init(sql: extendedGraphemeClusterLiteral, arguments: [])
}
/// :nodoc:
public init(stringLiteral: String) {
self.init(sql: stringLiteral, arguments: [])
}
/// :nodoc:
public init(stringInterpolation sqlInterpolation: SQLInterpolation) {
self.init(elements: sqlInterpolation.elements)
}
}
+33 -5
View File
@@ -1,24 +1,52 @@
/// :nodoc:
public struct SQLInterpolation: StringInterpolationProtocol {
var elements: [SQLLiteral.Element]
var elements: [SQL.Element]
public init(literalCapacity: Int, interpolationCount: Int) {
elements = []
elements.reserveCapacity(interpolationCount + 1)
}
/// "SELECT * FROM player"
public mutating func appendLiteral(_ sql: String) {
if sql.isEmpty { return }
elements.append(.sql(sql))
}
/// "SELECT * FROM \(sql: "player")"
/// Appends a raw SQL snippet, with eventual arguments.
///
/// For example:
///
/// "SELECT * FROM \(sql: "player")"
/// "SELECT * FROM player WHERE \(sql: "name = ?", arguments: ["O'Brien"])"
public mutating func appendInterpolation(sql: String, arguments: StatementArguments = StatementArguments()) {
elements.append(.sql(sql, arguments))
}
/// "SELECT * FROM player WHERE \(literal: condition)"
public mutating func appendInterpolation(literal sqlLiteral: SQLLiteral) {
/// Appends a raw `SQL` literal.
///
/// For example:
///
/// "SELECT * FROM \(SQL("player"))"
/// "SELECT * FROM player WHERE \(SQL("name = \("O'Brien")"))"
public mutating func appendInterpolation(_ sqlLiteral: SQL) {
elements.append(contentsOf: sqlLiteral.elements)
}
/// Appends a String expression.
///
/// For example:
///
/// "SELECT * FROM player WHERE name = \("O'Brien")"
public mutating func appendInterpolation<S: StringProtocol>(_ string: S) {
elements.append(.expression(String(string).sqlExpression))
}
/// Appends a raw `SQL` literal.
///
/// For example:
///
/// "SELECT * FROM player WHERE \(literal: "name = \("O'Brien")")"
public mutating func appendInterpolation(literal sqlLiteral: SQL) {
elements.append(contentsOf: sqlLiteral.elements)
}
}
-368
View File
@@ -1,368 +0,0 @@
/// SQLLiteral is a type which support [SQL
/// Interpolation](https://github.com/groue/GRDB.swift/blob/master/Documentation/SQLInterpolation.md).
///
/// For example:
///
/// try dbQueue.write { db in
/// let name: String = ...
/// let id: Int64 = ...
/// let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
/// try db.execute(literal: query)
/// }
public struct SQLLiteral {
/// SQLLiteral is an array of elements which can be qualified with
/// table aliases.
enum Element {
// Can't be qualified with a table alias
case sql(String, StatementArguments = StatementArguments())
// Does not need to be qualified with a table alias
case subquery(DatabasePromise<_FetchRequest>)
// Cases below can be qualified with a table alias
case expression(SQLExpression)
case selectable(SQLSelectable)
case orderingTerm(SQLOrderingTerm)
var isEmpty: Bool {
switch self {
case let .sql(sql, _):
return sql.isEmpty
default:
return false
}
}
fileprivate func sql(_ context: SQLGenerationContext) throws -> String {
switch self {
case let .sql(sql, arguments):
if context.append(arguments: arguments) == false {
// We don't know how to look for `?` in sql and
// replace them with literals.
fatalError("Not implemented: turning an SQL parameter into an SQL literal value")
}
return sql
case let .subquery(requestPromise):
return try requestPromise.resolve(context.db)._requestSQL(context, forSingleResult: false)
case let .expression(expression):
return try expression._expressionSQL(context, wrappedInParenthesis: false)
case let .selectable(selectable):
return try selectable._resultColumnSQL(context)
case let .orderingTerm(orderingTerm):
return try orderingTerm._orderingTermSQL(context)
}
}
fileprivate func qualified(with alias: TableAlias) -> Element {
switch self {
case .sql:
// Can't qualify raw SQL string
return self
case .subquery:
// Subqueries don't need table alias
return self
case let .expression(expression):
return .expression(expression._qualifiedExpression(with: alias))
case let .selectable(selectable):
return .selectable(selectable._qualifiedSelectable(with: alias))
case let .orderingTerm(orderingTerm):
return .orderingTerm(orderingTerm._qualifiedOrdering(with: alias))
}
}
}
private(set) var elements: [Element]
init(elements: [Element]) {
self.elements = elements
}
/// Creates an SQLLiteral from a plain SQL string, and eventual arguments.
///
/// For example:
///
/// let query = SQLLiteral(
/// sql: "UPDATE player SET name = ? WHERE id = ?",
/// arguments: [name, id])
public init(sql: String, arguments: StatementArguments = StatementArguments()) {
self.init(elements: [.sql(sql, arguments)])
}
/// Creates an SQLLiteral from an SQL expression.
///
/// For example:
///
/// let columnLiteral = SQLLiteral(Column("username"))
/// let suffixLiteral = SQLLiteral("@example.com".databaseValue)
/// let emailLiteral = [columnLiteral, suffixLiteral].joined(separator: " || ")
/// let request = User.select(emailLiteral.sqlExpression)
/// let emails = try String.fetchAll(db, request)
public init(_ expression: SQLExpression) {
self.init(elements: [.expression(expression)])
}
/// Returns true if this literal generates an empty SQL string
public var isEmpty: Bool {
elements.allSatisfy(\.isEmpty)
}
/// Turn a SQLLiteral into raw SQL and arguments.
///
/// - parameter db: A database connection.
/// - returns: A tuple made of a raw SQL string, and statement arguments.
public func build(_ db: Database) throws -> (sql: String, arguments: StatementArguments) {
let context = SQLGenerationContext(db)
let sql = try self.sql(context)
return (sql: sql, arguments: context.arguments)
}
/// Returns the literal SQL string given an SQL generation context.
func sql(_ context: SQLGenerationContext) throws -> String {
try elements.map { try $0.sql(context) }.joined()
}
func qualified(with alias: TableAlias) -> SQLLiteral {
SQLLiteral(elements: elements.map { $0.qualified(with: alias) })
}
}
extension SQLLiteral {
/// Returns the SQLLiteral produced by the concatenation of two literals.
///
/// let name = "O'Brien"
/// let selection: SQLLiteral = "SELECT * FROM player "
/// let condition: SQLLiteral = "WHERE name = \(name)"
/// let query = selection + condition
public static func + (lhs: SQLLiteral, rhs: SQLLiteral) -> SQLLiteral {
var result = lhs
result += rhs
return result
}
/// Appends an SQLLiteral to the receiver.
///
/// let name = "O'Brien"
/// var query: SQLLiteral = "SELECT * FROM player "
/// query += "WHERE name = \(name)"
public static func += (lhs: inout SQLLiteral, rhs: SQLLiteral) {
lhs.elements += rhs.elements
}
/// Appends an SQLLiteral to the receiver.
///
/// let name = "O'Brien"
/// var query: SQLLiteral = "SELECT * FROM player "
/// query.append(literal: "WHERE name = \(name)")
public mutating func append(literal sqlLiteral: SQLLiteral) {
self += sqlLiteral
}
/// Appends a plain SQL string to the receiver, and eventual arguments.
///
/// let name = "O'Brien"
/// var query: SQLLiteral = "SELECT * FROM player "
/// query.append(sql: "WHERE name = ?", arguments: [name])
public mutating func append(sql: String, arguments: StatementArguments = StatementArguments()) {
self += SQLLiteral(sql: sql, arguments: arguments)
}
}
extension SQLLiteral {
/// Creates a literal SQL expression.
///
/// SQLLiteral(sql: "1 + 2").sqlExpression
/// SQLLiteral(sql: "? + ?", arguments: [1, 2]).sqlExpression
/// SQLLiteral(sql: ":one + :two", arguments: ["one": 1, "two": 2]).sqlExpression
public var sqlExpression: SQLExpression {
SQLExpressionLiteral(sqlLiteral: self)
}
var sqlSelectable: SQLSelectable {
SQLSelectionLiteral(sqlLiteral: self)
}
var sqlOrderingTerm: SQLOrderingTerm {
SQLOrderingLiteral(sqlLiteral: self)
}
}
extension Sequence where Element == SQLLiteral {
/// Returns the concatenated SQLLiteral of this sequence of literals,
/// inserting the given separator between each element.
///
/// let components: [SQLLiteral] = [
/// "UPDATE player",
/// "SET name = \(name)",
/// "WHERE id = \(id)"
/// ]
/// let query = components.joined(separator: " ")
public func joined(separator: String = "") -> SQLLiteral {
if separator.isEmpty {
return SQLLiteral(elements: flatMap(\.elements))
} else {
return SQLLiteral(elements: Array(map(\.elements).joined(separator: CollectionOfOne(.sql(separator)))))
}
}
}
extension Collection where Element == SQLLiteral {
/// Returns the concatenated SQLLiteral of this collection of literals,
/// inserting the given SQL separator between each element.
///
/// let components: [SQLLiteral] = [
/// "UPDATE player",
/// "SET name = \(name)",
/// "WHERE id = \(id)"
/// ]
/// let query = components.joined(separator: " ")
public func joined(separator: String = "") -> SQLLiteral {
if separator.isEmpty {
return SQLLiteral(elements: flatMap(\.elements))
} else {
return SQLLiteral(elements: Array(map(\.elements).joined(separator: CollectionOfOne(.sql(separator)))))
}
}
}
// MARK: - ExpressibleByStringInterpolation
extension SQLLiteral: ExpressibleByStringInterpolation {
/// :nodoc
public init(unicodeScalarLiteral: String) {
self.init(sql: unicodeScalarLiteral, arguments: [])
}
/// :nodoc:
public init(extendedGraphemeClusterLiteral: String) {
self.init(sql: extendedGraphemeClusterLiteral, arguments: [])
}
/// :nodoc:
public init(stringLiteral: String) {
self.init(sql: stringLiteral, arguments: [])
}
/// :nodoc:
public init(stringInterpolation sqlInterpolation: SQLInterpolation) {
self.init(elements: sqlInterpolation.elements)
}
}
// MARK: - SQLExpressionLiteral
// TODO: remove public qualifier when GRDB5 fixits are removed.
/// `SQLExpressionLiteral` is an expression built from a raw SQL snippet.
///
/// To build one, use the `SQLiteral.sqlExpression` property:
///
/// let name = "O'Brien"
/// let column = Column("name")
/// let literal: SQLLiteral = "\(column) = \(name)"
/// let expression = literal.sqlExpression
///
/// Such expressions can feed query interface requests:
///
/// try dbQueue.read { db in
/// // SELECT * FROM player WHERE name = 'O''Brien'
/// let players = try Player
/// .filter(expression)
/// .fetchAll(db)
///
/// // SELECT player.*, team.*
/// // FROM player
/// // JOIN team WHERE team.id = player.teamID
/// // WHERE player.name = 'O''Brien'
/// let players = try Player
/// .including(required: Player.team)
/// .filter(expression)
/// .fetchAll(db)
/// }
///
/// See SQLLiteral for more information.
///
/// :nodoc:
public struct SQLExpressionLiteral: SQLExpression {
let sqlLiteral: SQLLiteral
// Prefer SQLLiteral.sqlExpression
fileprivate init(sqlLiteral: SQLLiteral) {
self.sqlLiteral = sqlLiteral
}
/// :nodoc:
public func _expressionSQL(_ context: SQLGenerationContext, wrappedInParenthesis: Bool) throws -> String {
var resultSQL = try sqlLiteral.sql(context)
if wrappedInParenthesis {
resultSQL = "(\(resultSQL))"
}
return resultSQL
}
/// :nodoc:
public func _qualifiedExpression(with alias: TableAlias) -> SQLExpression {
sqlLiteral.qualified(with: alias).sqlExpression
}
}
// MARK: - SQLSelectionLiteral
struct SQLSelectionLiteral: SQLSelectable {
let sqlLiteral: SQLLiteral
// Prefer SQLLiteral.sqlSelectable
fileprivate init(sqlLiteral: SQLLiteral) {
self.sqlLiteral = sqlLiteral
}
func _columnCount(_ db: Database) throws -> Int {
fatalError("""
Selection literals don't known how many columns they contain. \
To resolve this error, select one or several literal expressions instead. \
See SQLLiteral.sqlExpression.
""")
}
func _count(distinct: Bool) -> _SQLCount? { nil }
func _countedSQL(_ context: SQLGenerationContext) throws -> String {
fatalError("""
Selection literals can't be counted. \
To resolve this error, select one or several literal expressions instead. \
See SQLLiteral.sqlExpression.
""")
}
func _qualifiedSelectable(with alias: TableAlias) -> SQLSelectable {
sqlLiteral.qualified(with: alias).sqlSelectable
}
func _resultColumnSQL(_ context: SQLGenerationContext) throws -> String {
try sqlLiteral.sql(context)
}
}
// MARK: - SQLOrderingLiteral
struct SQLOrderingLiteral: SQLOrderingTerm {
let sqlLiteral: SQLLiteral
// Prefer SQLLiteral.sqlOrderingTerm
fileprivate init(sqlLiteral: SQLLiteral) {
self.sqlLiteral = sqlLiteral
}
func _orderingTermSQL(_ context: SQLGenerationContext) throws -> String {
try sqlLiteral.sql(context)
}
func _qualifiedOrdering(with alias: TableAlias) -> SQLOrderingTerm {
sqlLiteral.qualified(with: alias).sqlOrderingTerm
}
var _reversed: SQLOrderingTerm {
fatalError("""
Ordering literals can't be reversed. \
To resolve this error, order by expression literals instead.
""")
}
}
+82 -55
View File
@@ -15,9 +15,22 @@ public struct SQLRequest<RowDecoder> {
/// The request adapter
public var adapter: RowAdapter?
private(set) var sqlLiteral: SQLLiteral
private(set) var sqlLiteral: SQL
let cache: Cache?
private init(
literal sqlLiteral: SQL,
adapter: RowAdapter?,
fromCache cache: Cache?,
type: RowDecoder.Type)
{
self.sqlLiteral = sqlLiteral
self.adapter = adapter
self.cache = cache
}
}
extension SQLRequest {
/// Creates a request from an SQL string, optional arguments, and
/// optional row adapter.
///
@@ -42,66 +55,95 @@ public struct SQLRequest<RowDecoder> {
cached: Bool = false)
{
self.init(
literal: SQLLiteral(sql: sql, arguments: arguments),
literal: SQL(sql: sql, arguments: arguments),
adapter: adapter,
fromCache: cached ? .public : nil)
fromCache: cached ? .public : nil,
type: RowDecoder.self)
}
/// Creates a request from an SQLLiteral, and optional row adapter.
/// Creates a request from an `SQL` literal, and optional row adapter.
///
/// let request = SQLRequest<String>(literal: SQLLiteral(sql: """
/// SELECT name FROM player
/// """))
/// let request = SQLRequest<Player>(literal: SQLLiteral(sql: """
/// SELECT * FROM player WHERE name = ?
/// """, arguments: ["O'Brien"]))
///
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
/// Literals allow you to safely embed raw values in your SQL, without any
/// risk of syntax errors or SQL injection:
///
/// let name = "O'brien"
/// let request = SQLRequest<Player>(literal: """
/// SELECT * FROM player WHERE name = \("O'brien")
/// SELECT * FROM player WHERE name = \(name)
/// """)
///
/// - parameters:
/// - sqlLiteral: An SQLLiteral.
/// - sqlLiteral: An `SQL` literal.
/// - adapter: Optional RowAdapter.
/// - cached: Defaults to false. If true, the request reuses a cached
/// prepared statement.
/// - returns: A SQLRequest
public init(literal sqlLiteral: SQLLiteral, adapter: RowAdapter? = nil, cached: Bool = false) {
self.init(literal: sqlLiteral, adapter: adapter, fromCache: cached ? .public : nil)
public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false) {
self.init(
literal: sqlLiteral,
adapter: adapter,
fromCache: cached ? .public : nil,
type: RowDecoder.self)
}
}
extension SQLRequest where RowDecoder == Row {
/// Creates a request from an SQL string, optional arguments, and
/// optional row adapter.
///
/// let request = SQLRequest(sql: """
/// SELECT * FROM player WHERE id = ?
/// """, arguments: [1])
///
/// - parameters:
/// - sql: An SQL query.
/// - arguments: Statement arguments.
/// - adapter: Optional RowAdapter.
/// - cached: Defaults to false. If true, the request reuses a cached
/// prepared statement.
/// - returns: A SQLRequest
public init(
sql: String,
arguments: StatementArguments = StatementArguments(),
adapter: RowAdapter? = nil,
cached: Bool = false)
{
self.init(
literal: SQL(sql: sql, arguments: arguments),
adapter: adapter,
fromCache: cached ? .public : nil,
type: Row.self)
}
/// Creates a request from an SQLLiteral, and optional row adapter.
/// Creates a request from an `SQL` literal, and optional row adapter.
///
/// let request = SQLRequest<String>(literal: SQLLiteral(sql: """
/// SELECT name FROM player
/// """))
/// let request = SQLRequest<Player>(literal: SQLLiteral(sql: """
/// SELECT * FROM player WHERE name = ?
/// """, arguments: ["O'Brien"]))
/// Literals allow you to safely embed raw values in your SQL, without any
/// risk of syntax errors or SQL injection:
///
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let request = SQLRequest<Player>(literal: """
/// SELECT * FROM player WHERE name = \("O'brien")
/// let name = "O'brien"
/// let request = SQLRequest(literal: """
/// SELECT * FROM player WHERE name = \(name)
/// """)
///
/// - parameters:
/// - sqlLiteral: An SQLLiteral.
/// - sqlLiteral: An `SQL` literal.
/// - adapter: Optional RowAdapter.
/// - cache: The eventual cache
/// - cached: Defaults to false. If true, the request reuses a cached
/// prepared statement.
/// - returns: A SQLRequest
init(literal sqlLiteral: SQLLiteral, adapter: RowAdapter? = nil, fromCache cache: Cache?) {
self.sqlLiteral = sqlLiteral
self.adapter = adapter
self.cache = cache
public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false) {
self.init(
literal: sqlLiteral,
adapter: adapter,
fromCache: cached ? .public : nil,
type: Row.self)
}
}
extension SQLRequest: FetchRequest {
public var sqlSubquery: SQLSubquery {
.literal(sqlLiteral)
}
public func fetchCount(_ db: Database) throws -> Int {
try SQLRequest<Int>("SELECT COUNT(*) FROM (\(self))").fetchOne(db)!
}
@@ -113,33 +155,18 @@ extension SQLRequest: FetchRequest {
{
let context = SQLGenerationContext(db)
let sql = try sqlLiteral.sql(context)
let statement: SelectStatement
let statement: Statement
switch cache {
case .none:
statement = try db.makeSelectStatement(sql: sql)
statement = try db.makeStatement(sql: sql)
case .public?:
statement = try db.cachedSelectStatement(sql: sql)
statement = try db.cachedStatement(sql: sql)
case .internal?:
statement = try db.internalCachedSelectStatement(sql: sql)
statement = try db.internalCachedStatement(sql: sql)
}
try statement.setArguments(context.arguments)
return PreparedRequest(statement: statement, adapter: adapter)
}
/// :nodoc
public func _selectedColumnCount(_ db: Database) throws -> Int {
// Compile request. We can freely use the statement cache because we
// do not execute the statement or modify its arguments.
let context = SQLGenerationContext(db)
let sql = try _requestSQL(context, forSingleResult: false)
let statement = try db.cachedSelectStatement(sql: sql)
return statement.columnCount
}
/// :nodoc:
public func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String {
try sqlLiteral.sql(context)
}
}
extension SQLRequest: ExpressibleByStringInterpolation {
@@ -160,6 +187,6 @@ extension SQLRequest: ExpressibleByStringInterpolation {
/// :nodoc:
public init(stringInterpolation sqlInterpolation: SQLInterpolation) {
self.init(literal: SQLLiteral(stringInterpolation: sqlInterpolation))
self.init(literal: SQL(stringInterpolation: sqlInterpolation))
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ import Dispatch
///
/// Generally speaking, each connection has its own dispatch queue. But it's not
/// enough: users need to use two database connections at the same time:
/// https://github.com/groue/GRDB.swift/issues/55. To support this use case, a
/// <https://github.com/groue/GRDB.swift/issues/55>. To support this use case, a
/// single dispatch queue can be temporarily shared by two or more connections.
///
/// - SchedulingWatchdog.makeSerializedQueue(allowingDatabase:) creates a
+3 -5
View File
@@ -17,7 +17,6 @@ final class SerializedDatabase {
init(
path: String,
configuration: Configuration = Configuration(),
schemaCache: DatabaseSchemaCache,
defaultLabel: String,
purpose: String? = nil)
throws
@@ -47,8 +46,7 @@ final class SerializedDatabase {
self.db = try Database(
path: path,
description: identifier,
configuration: config,
schemaCache: schemaCache)
configuration: config)
self.queue = configuration.makeDispatchQueue(label: identifier)
SchedulingWatchdog.allowDatabase(db, onQueue: queue)
try queue.sync {
@@ -61,7 +59,7 @@ final class SerializedDatabase {
//
// So let's close the database now. The deinitializer
// will only close the database if needed.
db.close()
db.close_v2()
throw error
}
}
@@ -70,7 +68,7 @@ final class SerializedDatabase {
deinit {
// Database may be deallocated in its own queue: allow reentrancy
reentrantSync { db in
db.close()
db.close_v2()
}
}
+145 -240
View File
@@ -9,34 +9,65 @@ extension CharacterSet {
}
/// A statement represents an SQL query.
///
/// It is the base class of UpdateStatement that executes *update statements*,
/// and SelectStatement that fetches rows.
public class Statement {
public final class Statement {
enum TransactionEffect {
case beginTransaction
case commitTransaction
case rollbackTransaction
case beginSavepoint(String)
case releaseSavepoint(String)
case rollbackSavepoint(String)
}
/// The raw SQLite statement, suitable for the SQLite C API.
public let sqliteStatement: SQLiteStatement
/// The SQL query
public var sql: String {
SchedulingWatchdog.preconditionValidQueue(database)
// trim white space and semicolumn for homogeneous output
return String(cString: sqlite3_sql(sqliteStatement))
.trimmingCharacters(in: .sqlStatementSeparators)
}
/// The column names, ordered from left to right.
public lazy var columnNames: [String] = {
let sqliteStatement = self.sqliteStatement
return (0..<Int32(self.columnCount)).map { String(cString: sqlite3_column_name(sqliteStatement, $0)) }
}()
// Database region is computed during statement compilation, and maybe
// extended for select statements compiled by QueryInterfaceRequest, in
// order to perform focused database observation. See
// SQLQueryGenerator.makeSelectStatement(_:)
// SQLQueryGenerator.makeStatement(_:)
/// The database region that the statement looks into.
public internal(set) var databaseRegion = DatabaseRegion()
var isReadonly: Bool {
/// If true, the database schema cache gets invalidated after this statement
/// is executed.
private(set) var invalidatesDatabaseSchemaCache = false
private(set) var transactionEffect: TransactionEffect?
private(set) var databaseEventKinds: [DatabaseEventKind] = []
/// Returns true if and only if the prepared statement makes no direct
/// changes to the content of the database file.
///
/// See <https://www.sqlite.org/c3ref/stmt_readonly.html>.
public var isReadonly: Bool {
sqlite3_stmt_readonly(sqliteStatement) != 0
}
@usableFromInline
unowned let database: Database
/// Cache for index(ofColumn:). Keys are lowercase.
private lazy var columnIndexes: [String: Int] = {
Dictionary(
self.columnNames.enumerated().map { ($0.element.lowercased(), $0.offset) },
uniquingKeysWith: { (left, _) in left }) // keep leftmost indexes
}()
/// Creates a prepared statement. Returns nil if the compiled string is
/// blank or empty.
///
@@ -46,34 +77,34 @@ public class Statement {
/// - parameter statementEnd: Upon success, the pointer to the next
/// statement in the C string.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
/// - parameter authorizer: A StatementCompilationAuthorizer
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
/// - throws: DatabaseError in case of compilation error.
required init?(
database: Database,
statementStart: UnsafePointer<Int8>,
statementEnd: UnsafeMutablePointer<UnsafePointer<Int8>?>,
prepFlags: Int32,
authorizer: StatementCompilationAuthorizer) throws
prepFlags: Int32) throws
{
SchedulingWatchdog.preconditionValidQueue(database)
let authorizer = StatementCompilationAuthorizer()
var sqliteStatement: SQLiteStatement? = nil
// sqlite3_prepare_v3 was introduced in SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
#if GRDBCUSTOMSQLITE || GRDBCIPHER
let code = sqlite3_prepare_v3(
database.sqliteConnection, statementStart, -1, UInt32(bitPattern: prepFlags),
&sqliteStatement, statementEnd)
#else
let code: Int32
if #available(iOS 12.0, OSX 10.14, tvOS 12.0, watchOS 5.0, *) {
code = sqlite3_prepare_v3(
let code: Int32 = database.withAuthorizer(authorizer) {
// sqlite3_prepare_v3 was introduced in SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
#if GRDBCUSTOMSQLITE || GRDBCIPHER
return sqlite3_prepare_v3(
database.sqliteConnection, statementStart, -1, UInt32(bitPattern: prepFlags),
&sqliteStatement, statementEnd)
} else {
code = sqlite3_prepare_v2(database.sqliteConnection, statementStart, -1, &sqliteStatement, statementEnd)
#else
if #available(iOS 12.0, OSX 10.14, tvOS 12.0, watchOS 5.0, *) {
return sqlite3_prepare_v3(
database.sqliteConnection, statementStart, -1, UInt32(bitPattern: prepFlags),
&sqliteStatement, statementEnd)
} else {
return sqlite3_prepare_v2(database.sqliteConnection, statementStart, -1, &sqliteStatement, statementEnd)
}
#endif
}
#endif
guard code == SQLITE_OK else {
throw DatabaseError(
@@ -89,6 +120,9 @@ public class Statement {
self.database = database
self.sqliteStatement = statement
self.databaseRegion = authorizer.selectedRegion
self.invalidatesDatabaseSchemaCache = authorizer.invalidatesDatabaseSchemaCache
self.transactionEffect = authorizer.transactionEffect
self.databaseEventKinds = authorizer.databaseEventKinds
}
deinit {
@@ -106,8 +140,9 @@ public class Statement {
// MARK: Arguments
var argumentsNeedValidation = true
var _arguments = StatementArguments()
private var argumentsNeedValidation = true
private var _arguments = StatementArguments()
lazy var sqliteArgumentCount: Int = {
Int(sqlite3_bind_parameter_count(self.sqliteStatement))
@@ -115,8 +150,8 @@ public class Statement {
// Returns ["id", nil", "name"] for "INSERT INTO table VALUES (:id, ?, :name)"
fileprivate lazy var sqliteArgumentNames: [String?] = {
(0..<self.sqliteArgumentCount).map {
guard let cString = sqlite3_bind_parameter_name(self.sqliteStatement, Int32($0 + 1)) else {
(0..<Int32(self.sqliteArgumentCount)).map {
guard let cString = sqlite3_bind_parameter_name(self.sqliteStatement, $0 + 1) else {
return nil
}
return String(String(cString: cString).dropFirst()) // Drop initial ":", "@", "$"
@@ -188,8 +223,6 @@ public class Statement {
bind(value, at: index)
} else if let value = valuesIterator.next() {
bind(value, at: index)
} else {
bind(.null, at: index)
}
}
}
@@ -224,157 +257,59 @@ public class Statement {
}
// 1-based index
private func bind(_ dbValue: DatabaseValue, at index: Int32) {
let code: Int32
switch dbValue.storage {
case .null:
code = sqlite3_bind_null(sqliteStatement, index)
case .int64(let int64):
code = sqlite3_bind_int64(sqliteStatement, index, int64)
case .double(let double):
code = sqlite3_bind_double(sqliteStatement, index, double)
case .string(let string):
code = sqlite3_bind_text(sqliteStatement, index, string, -1, SQLITE_TRANSIENT)
case .blob(let data):
code = data.withUnsafeBytes {
sqlite3_bind_blob(sqliteStatement, index, $0.baseAddress, Int32($0.count), SQLITE_TRANSIENT)
}
}
func bind<T: StatementBinding>(_ value: T, at index: CInt) {
let code = value.bind(to: sqliteStatement, at: index)
// It looks like sqlite3_bind_xxx() functions do not access the file system.
// They should thus succeed, unless a GRDB bug: there is no point throwing any error.
guard code == SQLITE_OK else {
fatalError(DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql).description)
fatalError(DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql))
}
}
// Don't make this one public unless we keep the arguments property in sync.
private func clearBindings() {
func clearBindings() {
// It looks like sqlite3_clear_bindings() does not access the file system.
// This function call should thus succeed, unless a GRDB bug: there is
// no point throwing any error.
let code = sqlite3_clear_bindings(sqliteStatement)
guard code == SQLITE_OK else {
fatalError(DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql).description)
fatalError(DatabaseError(resultCode: code, message: database.lastErrorMessage, sql: sql))
}
}
fileprivate func prepare(withArguments arguments: StatementArguments?) {
func reset(withArguments arguments: StatementArguments?) {
// Force arguments validity: it is a programmer error to provide
// arguments that do not match the statement.
if let arguments = arguments {
try! setArguments(arguments)
} else if argumentsNeedValidation {
try! reset()
try! validateArguments(self.arguments)
}
}
}
// MARK: - Statement Preparation
@available(*, deprecated, renamed: "Statement")
public typealias SelectStatement = Statement
extension Statement {
// Static method instead of an initializer because initializer can't run
// inside `sqlCodeUnits.withUnsafeBufferPointer`.
static func prepare(_ db: Database, sql: String, prepFlags: Int32) throws -> Self {
let authorizer = StatementCompilationAuthorizer()
return try db.withAuthorizer(authorizer) {
try sql.utf8CString.withUnsafeBufferPointer { buffer in
let statementStart = buffer.baseAddress!
var statementEnd: UnsafePointer<Int8>? = nil
guard let statement = try self.init(
database: db,
statementStart: statementStart,
statementEnd: &statementEnd,
prepFlags: prepFlags,
authorizer: authorizer) else
{
throw DatabaseError(
resultCode: .SQLITE_ERROR,
message: "empty statement",
sql: sql)
}
let remainingSQL = String(cString: statementEnd!).trimmingCharacters(in: .sqlStatementSeparators)
guard remainingSQL.isEmpty else {
throw DatabaseError(
resultCode: .SQLITE_MISUSE,
message: """
Multiple statements found. To execute multiple statements, \
use Database.execute(sql:) instead.
""",
sql: sql)
}
return statement
}
}
@available(*, deprecated, renamed: "Statement")
public typealias UpdateStatement = Statement
extension Statement: CustomStringConvertible {
public var description: String {
"SQL: \(sql), Arguments: \(arguments)"
}
}
// MARK: - SelectStatement
// MARK: - Select Statements
/// A subclass of Statement that fetches database rows.
///
/// You create SelectStatement with the Database.makeSelectStatement() method:
///
/// try dbQueue.read { db in
/// let statement = try db.makeSelectStatement(sql: "SELECT COUNT(*) FROM player WHERE score > ?")
/// let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])!
/// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
/// }
public final class SelectStatement: Statement {
/// Creates a prepared statement. Returns nil if the compiled string is
/// blank or empty.
///
/// - parameter database: A database connection.
/// - parameter statementStart: A pointer to a UTF-8 encoded C string
/// containing SQL.
/// - parameter statementEnd: Upon success, the pointer to the next
/// statement in the C string.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
/// - parameter authorizer: A StatementCompilationAuthorizer
/// - throws: DatabaseError in case of compilation error.
required init?(
database: Database,
statementStart: UnsafePointer<Int8>,
statementEnd: UnsafeMutablePointer<UnsafePointer<Int8>?>,
prepFlags: Int32,
authorizer: StatementCompilationAuthorizer) throws
{
try super.init(
database: database,
statementStart: statementStart,
statementEnd: statementEnd,
prepFlags: prepFlags,
authorizer: authorizer)
GRDBPrecondition(
authorizer.invalidatesDatabaseSchemaCache == false,
"Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
GRDBPrecondition(
authorizer.transactionEffect == nil,
"Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
}
extension Statement {
/// The number of columns in the resulting rows.
public var columnCount: Int {
Int(sqlite3_column_count(self.sqliteStatement))
}
/// The column names, ordered from left to right.
public lazy var columnNames: [String] = {
let sqliteStatement = self.sqliteStatement
return (0..<Int32(self.columnCount)).map { String(cString: sqlite3_column_name(sqliteStatement, $0)) }
}()
/// Cache for index(ofColumn:). Keys are lowercase.
private lazy var columnIndexes: [String: Int] = {
Dictionary(
self.columnNames.enumerated().map { ($0.element.lowercased(), $0.offset) },
uniquingKeysWith: { (left, _) in left }) // keep leftmost indexes
}()
/// Returns the index of the leftmost column named `name`, in a
/// case-insensitive way.
public func index(ofColumn name: String) -> Int? {
@@ -387,23 +322,6 @@ public final class SelectStatement: Statement {
func makeCursor(arguments: StatementArguments? = nil) throws -> StatementCursor {
try StatementCursor(statement: self, arguments: arguments)
}
/// Utility function for cursors
func reset(withArguments arguments: StatementArguments? = nil) {
prepare(withArguments: arguments)
try! reset()
}
/// Utility function for cursors
@usableFromInline
func didFail(withResultCode resultCode: Int32) throws -> Never {
database.selectStatementDidFail(self)
throw DatabaseError(
resultCode: resultCode,
message: database.lastErrorMessage,
sql: sql,
arguments: arguments)
}
}
/// A cursor that iterates a database statement without producing any value.
@@ -412,81 +330,75 @@ public final class SelectStatement: Statement {
/// For example:
///
/// try dbQueue.read { db in
/// let statement = db.makeSelectStatement(sql: "SELECT performSideEffect()")
/// let statement = db.makeStatement(sql: "SELECT performSideEffect()")
/// let cursor = statement.makeCursor()
/// try cursor.next()
/// }
final class StatementCursor: Cursor {
let _statement: SelectStatement
let _sqliteStatement: SQLiteStatement
var _done = false
private enum _State {
case idle, busy, done, failed
}
// Use SelectStatement.makeCursor() instead
init(statement: SelectStatement, arguments: StatementArguments? = nil) throws {
/* private, internal for testability */ let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private var _state = _State.idle
// Use Statement.makeCursor() instead
init(statement: Statement, arguments: StatementArguments? = nil) throws {
_statement = statement
_sqliteStatement = statement.sqliteStatement
_statement.reset(withArguments: arguments)
// Assume cursor is created for iteration
try statement.database.selectStatementWillExecute(statement)
// Assume cursor is created for immediate iteration: reset and set arguments
statement.reset(withArguments: arguments)
}
deinit {
if _state == .busy {
try? _statement.database.statementDidExecute(_statement)
}
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? _statement.reset()
}
/// :nodoc:
@inlinable
func next() throws -> Void? {
if _done {
switch _state {
case .done:
// make sure this instance never yields a value again, even if the
// statement is reset by another cursor.
return nil
case .idle:
guard try _statement.database.statementWillExecute(_statement) == nil else {
throw DatabaseError(
resultCode: SQLITE_MISUSE,
message: "Can't run statement that requires a customized authorizer from a cursor",
sql: _statement.sql,
arguments: _statement.arguments)
}
_state = .busy
default:
break
}
switch sqlite3_step(_sqliteStatement) {
case SQLITE_DONE:
_done = true
_state = .done
try _statement.database.statementDidExecute(_statement)
return nil
case SQLITE_ROW:
return .some(())
case let code:
try _statement.didFail(withResultCode: code)
_state = .failed
try _statement.database.statementDidFail(_statement, withResultCode: code)
}
}
}
// MARK: - Update Statements
// MARK: - UpdateStatement
/// A subclass of Statement that executes SQL queries.
///
/// You create UpdateStatement with the Database.makeUpdateStatement() method:
///
/// try dbQueue.inTransaction { db in
/// let statement = try db.makeUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)")
/// try statement.execute(arguments: ["Arthur"])
/// try statement.execute(arguments: ["Barbara"])
/// return .commit
/// }
public final class UpdateStatement: Statement {
enum TransactionEffect {
case beginTransaction
case commitTransaction
case rollbackTransaction
case beginSavepoint(String)
case releaseSavepoint(String)
case rollbackSavepoint(String)
}
/// If true, the database schema cache gets invalidated after this statement
/// is executed.
private(set) var invalidatesDatabaseSchemaCache: Bool = false
private(set) var transactionEffect: TransactionEffect?
private(set) var databaseEventKinds: [DatabaseEventKind] = []
extension Statement {
var releasesDatabaseLock: Bool {
guard let transactionEffect = transactionEffect else {
return false
@@ -506,58 +418,38 @@ public final class UpdateStatement: Statement {
}
}
/// Creates a prepared statement. Returns nil if the compiled string is
/// blank or empty.
///
/// - parameter database: A database connection.
/// - parameter statementStart: A pointer to a UTF-8 encoded C string
/// containing SQL.
/// - parameter statementEnd: Upon success, the pointer to the next
/// statement in the C string.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
/// - parameter authorizer: A StatementCompilationAuthorizer
/// - throws: DatabaseError in case of compilation error.
required init?(
database: Database,
statementStart: UnsafePointer<Int8>,
statementEnd: UnsafeMutablePointer<UnsafePointer<Int8>?>,
prepFlags: Int32,
authorizer: StatementCompilationAuthorizer) throws
{
try super.init(
database: database,
statementStart: statementStart,
statementEnd: statementEnd,
prepFlags: prepFlags,
authorizer: authorizer)
self.invalidatesDatabaseSchemaCache = authorizer.invalidatesDatabaseSchemaCache
self.transactionEffect = authorizer.transactionEffect
self.databaseEventKinds = authorizer.databaseEventKinds
}
/// Executes the SQL query.
/// Executes the prepared statement.
///
/// - parameter arguments: Optional statement arguments.
/// - throws: A DatabaseError whenever an SQLite error occurs.
public func execute(arguments: StatementArguments? = nil) throws {
SchedulingWatchdog.preconditionValidQueue(database)
prepare(withArguments: arguments)
try reset()
reset(withArguments: arguments)
// Statement does not know how to execute itself, because it does not
// know how to handle its errors, or if truncate optimisation should be
// prevented or not. Database knows.
try database.executeUpdateStatement(self)
try database.executeStatement(self)
}
}
// MARK: - StatementBinding
public protocol StatementBinding {
/// Binds a statement argument.
///
/// - parameter sqliteStatement: An SQLite statement.
/// - parameter index: 1-based index to statement arguments
/// - returns: the code returned by the `sqlite3_bind_xxx` function.
func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
}
// MARK: - StatementArguments
/// StatementArguments provide values to argument placeholders in raw
/// SQL queries.
///
/// Placeholders can take several forms (see https://www.sqlite.org/lang_expr.html#varparam
/// Placeholders can take several forms (see <https://www.sqlite.org/lang_expr.html#varparam>
/// for more information):
///
/// - `?NNN` (e.g. `?2`): the NNN-th argument (starts at 1)
@@ -636,8 +528,8 @@ public final class UpdateStatement: Statement {
public struct StatementArguments: CustomStringConvertible, Equatable,
ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
{
private(set) var values: [DatabaseValue] = []
private(set) var namedValues: [String: DatabaseValue] = [:]
private(set) var values: [DatabaseValue]
private(set) var namedValues: [String: DatabaseValue]
public var isEmpty: Bool {
values.isEmpty && namedValues.isEmpty
@@ -648,6 +540,8 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
/// Creates empty StatementArguments.
public init() {
values = .init()
namedValues = .init()
}
// MARK: Positional Arguments
@@ -661,6 +555,7 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
/// - returns: A StatementArguments.
public init<Sequence: Swift.Sequence>(_ sequence: Sequence) where Sequence.Element == DatabaseValueConvertible? {
values = sequence.map { $0?.databaseValue ?? .null }
namedValues = .init()
}
/// Creates statement arguments from a sequence of optional values.
@@ -672,6 +567,7 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
/// - returns: A StatementArguments.
public init<Sequence: Swift.Sequence>(_ sequence: Sequence) where Sequence.Element: DatabaseValueConvertible {
values = sequence.map(\.databaseValue)
namedValues = .init()
}
/// Creates statement arguments from any array. The result is nil unless all
@@ -690,6 +586,10 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
self.init(values)
}
private mutating func set(databaseValues: [DatabaseValue]) {
self.values = databaseValues
namedValues.removeAll(keepingCapacity: true)
}
// MARK: Named Arguments
@@ -703,6 +603,7 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
/// - returns: A StatementArguments.
public init(_ dictionary: [String: DatabaseValueConvertible?]) {
namedValues = dictionary.mapValues { $0?.databaseValue ?? .null }
values = .init()
}
/// Creates statement arguments from a sequence of (key, value) pairs, such
@@ -716,7 +617,11 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
public init<Sequence>(_ sequence: Sequence)
where Sequence: Swift.Sequence, Sequence.Element == (String, DatabaseValueConvertible?)
{
namedValues = Dictionary(uniqueKeysWithValues: sequence.map { ($0.0, $0.1?.databaseValue ?? .null) })
namedValues = .init(minimumCapacity: sequence.underestimatedCount)
for (key, value) in sequence {
namedValues[key] = value?.databaseValue ?? .null
}
values = .init()
}
/// Creates statement arguments from [AnyHashable: Any].
+3 -2
View File
@@ -3,6 +3,7 @@ import Glibc
#endif
/// A protocol around sqlite3_set_authorizer
@usableFromInline
protocol StatementAuthorizer: AnyObject {
func authorize(
_ actionCode: Int32,
@@ -28,7 +29,7 @@ final class StatementCompilationAuthorizer: StatementAuthorizer {
/// Not nil if a statement is a BEGIN/COMMIT/ROLLBACK/RELEASE transaction or
/// savepoint statement.
var transactionEffect: UpdateStatement.TransactionEffect?
var transactionEffect: Statement.TransactionEffect?
private var isDropStatement = false
@@ -55,7 +56,7 @@ final class StatementCompilationAuthorizer: StatementAuthorizer {
invalidatesDatabaseSchemaCache = true
return SQLITE_OK
case SQLITE_ALTER_TABLE, SQLITE_DETACH,
case SQLITE_ATTACH, SQLITE_DETACH, SQLITE_ALTER_TABLE,
SQLITE_CREATE_INDEX, SQLITE_CREATE_TABLE,
SQLITE_CREATE_TEMP_INDEX, SQLITE_CREATE_TEMP_TABLE,
SQLITE_CREATE_TEMP_TRIGGER, SQLITE_CREATE_TEMP_VIEW,
+193 -55
View File
@@ -1,6 +1,6 @@
/// The `StatementColumnConvertible` protocol grants access to the low-level C
/// interface that extracts values from query results:
/// https://www.sqlite.org/c3ref/column_blob.html. It can bring performance
/// <https://www.sqlite.org/c3ref/column_blob.html>. It can bring performance
/// improvements.
///
/// To use it, have a value type adopt both `StatementColumnConvertible` and
@@ -18,32 +18,117 @@
/// score = row["score"] // there
/// }
/// }
///
/// `StatementColumnConvertible` is already adopted by all Swift integer types,
/// `Float`, `Double`, `String`, and `Bool`.
public protocol StatementColumnConvertible {
/// Initializes a value from a raw SQLite statement pointer.
/// Initializes a value from a raw SQLite statement pointer, if possible.
///
/// For example, here is the how Int64 adopts StatementColumnConvertible:
///
/// extension Int64: StatementColumnConvertible {
/// init(sqliteStatement: SQLiteStatement, index: Int32) {
/// init?(sqliteStatement: SQLiteStatement, index: Int32) {
/// self = sqlite3_column_int64(sqliteStatement, index)
/// }
/// }
///
/// This initializer is never called for NULL database values: don't perform
/// any extra check.
/// This initializer is never called for NULL database values. Just return
/// `nil` for failed conversions: GRDB will interpret a nil result as a
/// decoding failure.
///
/// See https://www.sqlite.org/c3ref/column_blob.html for more information.
/// See <https://www.sqlite.org/c3ref/column_blob.html> for more information.
///
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
init(sqliteStatement: SQLiteStatement, index: Int32)
init?(sqliteStatement: SQLiteStatement, index: Int32)
}
// MARK: - Conversions
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
@usableFromInline
/* private */ static func _valueMismatch(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Never
{
throw RowDecodingError.valueMismatch(
Self.self,
sqliteStatement: sqliteStatement,
index: index,
context: context())
}
@inline(__always)
@inlinable
static func fastDecode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
guard sqlite3_column_type(sqliteStatement, index) != SQLITE_NULL,
let value = self.init(sqliteStatement: sqliteStatement, index: index)
else {
try _valueMismatch(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
return value
}
@inline(__always)
@inlinable
static func fastDecode(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Self
{
if let sqliteStatement = row.sqliteStatement {
return try fastDecode(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
// Support for fast decoding from adapted rows
return try row.fastDecode(Self.self, atUncheckedIndex: index)
}
@inline(__always)
@inlinable
static func fastDecodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Self?
{
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
return nil
}
guard let value = self.init(sqliteStatement: sqliteStatement, index: index) else {
try _valueMismatch(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
return value
}
@inline(__always)
@inlinable
static func fastDecodeIfPresent(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Self?
{
if let sqliteStatement = row.sqliteStatement {
return try fastDecodeIfPresent(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
// Support for fast decoding from adapted rows
return try row.fastDecodeIfPresent(Self.self, atUncheckedIndex: index)
}
}
// MARK: - Cursors
/// A cursor of database values extracted from a single column.
/// For example:
///
@@ -54,12 +139,17 @@ public protocol StatementColumnConvertible {
/// }
/// }
public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & StatementColumnConvertible> : Cursor {
@usableFromInline let _statement: SelectStatement
@usableFromInline
enum _State {
case idle, busy, done, failed
}
@usableFromInline let _statement: Statement
@usableFromInline let _columnIndex: Int32
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline var _done = false
@usableFromInline var _state = _State.idle
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
_sqliteStatement = statement.sqliteStatement
if let adapter = adapter {
@@ -68,13 +158,16 @@ public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & Sta
} else {
_columnIndex = 0
}
_statement.reset(withArguments: arguments)
// Assume cursor is created for iteration
try statement.database.selectStatementWillExecute(statement)
// Assume cursor is created for immediate iteration: reset and set arguments
statement.reset(withArguments: arguments)
}
deinit {
if _state == .busy {
try? _statement.database.statementDidExecute(_statement)
}
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? _statement.reset()
@@ -82,19 +175,38 @@ public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & Sta
@inlinable
public func next() throws -> Value? {
if _done {
switch _state {
case .done:
// make sure this instance never yields a value again, even if the
// statement is reset by another cursor.
return nil
case .idle:
guard try _statement.database.statementWillExecute(_statement) == nil else {
throw DatabaseError(
resultCode: SQLITE_MISUSE,
message: "Can't run statement that requires a customized authorizer from a cursor",
sql: _statement.sql,
arguments: _statement.arguments)
}
_state = .busy
default:
break
}
switch sqlite3_step(_sqliteStatement) {
case SQLITE_DONE:
_done = true
_state = .done
try _statement.database.statementDidExecute(_statement)
return nil
case SQLITE_ROW:
return Value.fastDecode(from: _sqliteStatement, atUncheckedIndex: _columnIndex)
// TODO GRDB6: don't crash on decoding errors
return try! Value.fastDecode(
fromStatement: _sqliteStatement,
atUncheckedIndex: _columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(_columnIndex)))
case let code:
try _statement.didFail(withResultCode: code)
_state = .failed
try _statement.database.statementDidFail(_statement, withResultCode: code)
}
}
}
@@ -112,12 +224,17 @@ public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & Sta
public final class FastNullableDatabaseValueCursor<Value>: Cursor
where Value: DatabaseValueConvertible & StatementColumnConvertible
{
@usableFromInline let _statement: SelectStatement
@usableFromInline
enum _State {
case idle, busy, done, failed
}
@usableFromInline let _statement: Statement
@usableFromInline let _columnIndex: Int32
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline var _done = false
@usableFromInline var _state = _State.idle
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
_sqliteStatement = statement.sqliteStatement
if let adapter = adapter {
@@ -126,13 +243,16 @@ where Value: DatabaseValueConvertible & StatementColumnConvertible
} else {
_columnIndex = 0
}
_statement.reset(withArguments: arguments)
// Assume cursor is created for iteration
try statement.database.selectStatementWillExecute(statement)
// Assume cursor is created for immediate iteration: reset and set arguments
statement.reset(withArguments: arguments)
}
deinit {
if _state == .busy {
try? _statement.database.statementDidExecute(_statement)
}
// Statement reset fails when sqlite3_step has previously failed.
// Just ignore reset error.
try? _statement.reset()
@@ -140,19 +260,38 @@ where Value: DatabaseValueConvertible & StatementColumnConvertible
@inlinable
public func next() throws -> Value?? {
if _done {
switch _state {
case .done:
// make sure this instance never yields a value again, even if the
// statement is reset by another cursor.
return nil
case .idle:
guard try _statement.database.statementWillExecute(_statement) == nil else {
throw DatabaseError(
resultCode: SQLITE_MISUSE,
message: "Can't run statement that requires a customized authorizer from a cursor",
sql: _statement.sql,
arguments: _statement.arguments)
}
_state = .busy
default:
break
}
switch sqlite3_step(_sqliteStatement) {
case SQLITE_DONE:
_done = true
_state = .done
try _statement.database.statementDidExecute(_statement)
return nil
case SQLITE_ROW:
return Value.fastDecodeIfPresent(from: _sqliteStatement, atUncheckedIndex: _columnIndex)
// TODO GRDB6: don't crash on decoding errors
return try! Value.fastDecodeIfPresent(
fromStatement: _sqliteStatement,
atUncheckedIndex: _columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(_columnIndex)))
case let code:
try _statement.didFail(withResultCode: code)
_state = .failed
try _statement.database.statementDidFail(_statement, withResultCode: code)
}
}
}
@@ -164,12 +303,11 @@ where Value: DatabaseValueConvertible & StatementColumnConvertible
/// See DatabaseValueConvertible for more information.
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
// MARK: Fetching From SelectStatement
// MARK: Fetching From Prepared Statement
/// Returns a cursor over values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchCursor(statement) // Cursor of String
/// while let name = try names.next() { // String
/// ...
@@ -187,7 +325,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> FastDatabaseValueCursor<Self>
@@ -197,7 +335,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// Returns an array of values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchAll(statement) // [String]
///
/// - parameters:
@@ -207,7 +345,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// - returns: An array of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> [Self]
@@ -217,7 +355,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// Returns a single value fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let name = try String.fetchOne(statement) // String?
///
/// - parameters:
@@ -227,7 +365,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// - returns: An optional value.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Self?
@@ -244,7 +382,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
extension DatabaseValueConvertible where Self: StatementColumnConvertible & Hashable {
/// Returns a set of values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try String.fetchSet(statement) // Set<String>
///
/// - parameters:
@@ -254,7 +392,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible & Hash
/// - returns: A set of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchSet(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Set<Self>
@@ -293,7 +431,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> FastDatabaseValueCursor<Self>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
@@ -314,7 +452,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> [Self]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
@@ -335,7 +473,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> Self?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -358,7 +496,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible & Hash
adapter: RowAdapter? = nil)
throws -> Set<Self>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -511,18 +649,18 @@ extension FetchRequest where RowDecoder: DatabaseValueConvertible & StatementCol
/// try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...", arguments:...) // [String?]
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// try Optional<String>.fetchCursor(statement, arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(statement, arguments:...) // [String?]
///
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible {
// MARK: Fetching From SelectStatement
// MARK: Fetching From Prepared Statement
/// Returns a cursor over optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
@@ -540,7 +678,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> FastNullableDatabaseValueCursor<Wrapped>
@@ -550,7 +688,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// Returns an array of optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchAll(statement) // [String?]
///
/// - parameters:
@@ -560,7 +698,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// - returns: An array of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
@@ -572,7 +710,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable {
/// Returns a set of optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
/// let statement = try db.makeStatement(sql: "SELECT name FROM ...")
/// let names = try Optional<String>.fetchSet(statement) // Set<String?>
///
/// - parameters:
@@ -582,7 +720,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// - returns: A set of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchSet(
_ statement: SelectStatement,
_ statement: Statement,
arguments: StatementArguments? = nil,
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
@@ -621,7 +759,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> FastNullableDatabaseValueCursor<Wrapped>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
@@ -642,7 +780,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -665,7 +803,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
+77 -2
View File
@@ -2,7 +2,6 @@ import Foundation
/// Data is convertible to and from DatabaseValue.
extension Data: DatabaseValueConvertible, StatementColumnConvertible {
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
if let bytes = sqlite3_column_blob(sqliteStatement, index) {
let count = Int(sqlite3_column_bytes(sqliteStatement, index))
@@ -25,10 +24,86 @@ extension Data: DatabaseValueConvertible, StatementColumnConvertible {
return data
case .string(let string):
// Implicit conversion from string to blob, just as SQLite does
// See https://www.sqlite.org/c3ref/column_blob.html
// See <https://www.sqlite.org/c3ref/column_blob.html>
return string.data(using: .utf8)
default:
return nil
}
}
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
withUnsafeBytes {
sqlite3_bind_blob(sqliteStatement, index, $0.baseAddress, Int32($0.count), SQLITE_TRANSIENT)
}
}
}
// MARK: - Conversions
extension Data {
static func fastDecodeNoCopy(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
throws -> Data
{
guard sqlite3_column_type(sqliteStatement, Int32(index)) != SQLITE_NULL else {
throw RowDecodingError.valueMismatch(
Data.self,
sqliteStatement: sqliteStatement,
index: index,
context: context())
}
guard let bytes = sqlite3_column_blob(sqliteStatement, Int32(index)) else {
return Data()
}
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
return Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
}
static func fastDecodeNoCopy(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Data
{
if let sqliteStatement = row.sqliteStatement {
return try fastDecodeNoCopy(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
// Support for fast decoding from adapted rows
return try row.fastDecodeDataNoCopy(atUncheckedIndex: index)
}
static func fastDecodeNoCopyIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
context: @autoclosure () -> RowDecodingContext)
-> Data?
{
guard sqlite3_column_type(sqliteStatement, Int32(index)) != SQLITE_NULL else {
return nil
}
guard let bytes = sqlite3_column_blob(sqliteStatement, Int32(index)) else {
return Data()
}
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
return Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
}
static func fastDecodeNoCopyIfPresent(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Data?
{
if let sqliteStatement = row.sqliteStatement {
return fastDecodeNoCopyIfPresent(
fromStatement: sqliteStatement,
atUncheckedIndex: Int32(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
// Support for fast decoding from adapted rows
return try row.fastDecodeDataNoCopyIfPresent(atUncheckedIndex: index)
}
}
@@ -69,9 +69,11 @@ public struct DatabaseDateComponents: DatabaseValueConvertible, StatementColumnC
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
public init(sqliteStatement: SQLiteStatement, index: Int32) {
@inline(__always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
guard let cString = sqlite3_column_text(sqliteStatement, index) else {
fatalConversionError(to: DatabaseDateComponents.self, sqliteStatement: sqliteStatement, index: index)
return nil
}
let length = Int(sqlite3_column_bytes(sqliteStatement, index)) // avoid an strlen
let optionalComponents = cString.withMemoryRebound(
@@ -80,10 +82,9 @@ public struct DatabaseDateComponents: DatabaseValueConvertible, StatementColumnC
SQLiteDateParser().components(cString: cString, length: length)
}
guard let components = optionalComponents else {
fatalConversionError(to: DatabaseDateComponents.self, sqliteStatement: sqliteStatement, index: index)
return nil
}
self.dateComponents = components.dateComponents
self.format = components.format
self.init(components.dateComponents, format: components.format)
}
// MARK: - DatabaseValueConvertible adoption
+7 -5
View File
@@ -118,19 +118,21 @@ extension Date: StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inline(__always)
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, index) {
case SQLITE_INTEGER, SQLITE_FLOAT:
self.init(timeIntervalSince1970: sqlite3_column_double(sqliteStatement, index))
case SQLITE_TEXT:
let databaseDateComponents = DatabaseDateComponents(sqliteStatement: sqliteStatement, index: index)
guard let date = Date(databaseDateComponents: databaseDateComponents) else {
fatalConversionError(to: Date.self, sqliteStatement: sqliteStatement, index: index)
guard let components = DatabaseDateComponents(sqliteStatement: sqliteStatement, index: index),
let date = Date(databaseDateComponents: components)
else {
return nil
}
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate)
default:
fatalConversionError(to: Date.self, sqliteStatement: sqliteStatement, index: index)
return nil
}
}
}
Loaded 100 of 352 files, more files were not shown because too many files have changed in this diff. Show more