Compare commits

...
2752 Commits
Author SHA1 Message Date
Gwendal Roué 786ab176c9 v2.0 2017-09-16 18:37:27 +02:00
Gwendal Roué 973af107da More performance tests, upgrade SQLite.swift submodule 2017-09-16 18:25:24 +02:00
Gwendal Roué 1911ef0172 Merge branch 'master' of github.com:groue/GRDB.swift into Swift4
Conflicts:
	README.md
2017-09-16 14:49:39 +02:00
Gwendal Roué d2e9b340c9 Adapt FT5 support for the non optional Database.primaryKey(_:) 2017-09-15 19:05:39 +02:00
Gwendal Roué 5b487d1722 Fix compiler warning 2017-09-15 19:01:49 +02:00
Gwendal Roué a91da59448 Database.primaryKey(_:) no longer returns an Optional. PrimaryKeyInfo.isRowID tells whether the primary key is the rowed. 2017-09-15 09:00:56 +02:00
Gwendal Roué 2846254304 Improve make distclean, with submodules 2017-09-14 21:51:11 +02:00
Gwendal Roué 5fe765dd29 Improve make distclean 2017-09-14 21:49:06 +02:00
Gwendal Roué 9815f44134 Remove sqlite3.h from the distribution 2017-09-14 20:34:22 +02:00
Gwendal Roué 3f8969b88f PerformanceComparisonTests: update Realm to 2.10.0, SQLite.swift to latest swift-4 branch 2017-09-13 08:11:31 +02:00
Gwendal Roué 4fc7a44a9d Tweak JSONSynchronization playground 2017-09-12 08:30:05 +02:00
Gwendal Roué e132688e00 Simplify JSONSynchronization playground 2017-09-12 08:25:09 +02:00
Gwendal Roué 588df57840 Fix typo 2017-09-12 08:13:23 +02:00
Gwendal Roué 4a8ca6fdc1 TODO 2017-09-11 09:04:05 +02:00
Gwendal Roué 2bb2493731 Turn MutablePersistable.databaseDictionary into a property 2017-09-11 08:53:56 +02:00
Gwendal Roué c61949ceaf DatabaseError.description contains primary result code, not extended result code. 2017-09-11 08:12:43 +02:00
Gwendal Roué 3fce1e00c9 Introduce AnyDatabaseReader and AnyDatabaseWriter 2017-09-10 13:37:48 +02:00
Gwendal Roué 2f2add1c49 Update podspec 2017-09-09 13:29:24 +02:00
Gwendal Roué 697acb103f Cleanup 2017-09-08 21:45:35 +02:00
Gwendal Roué c830e43e8f Update JSONSynchronization playground with Record.updateChanges(_:) 2017-09-08 21:41:39 +02:00
Gwendal Roué 834ef45ca6 Document how to convert a Row to Dictionary 2017-09-08 20:38:03 +02:00
Gwendal Roué 279faa13e9 Less TODO 2017-09-08 13:23:20 +02:00
Gwendal Roué 0309abca6f Tests for Statement.SelectionInfo.description 2017-09-08 13:18:45 +02:00
Gwendal Roué fedee67bda Enhance documentation of fatal errors that happen during value conversion 2017-09-08 08:19:09 +02:00
Gwendal Roué a6c3566aa5 Record.updateChanges(_:) documentation 2017-09-08 08:08:07 +02:00
Gwendal Roué 52fa24e1c4 QueryInterfaceRequest.deleteAll() now honors the order and limit clauses when SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT option 2017-09-08 07:07:43 +02:00
Gwendal Roué a7ecf41e3b QueryInterfaceRequest.deleteAll() now honors the order and limit clauses. New Set(cursor) initialiser. 2017-09-07 19:22:21 +02:00
Gwendal Roué e68e5f6265 Tests for Record.updateChangedColumns(_:) 2017-09-06 09:12:38 +02:00
Gwendal Roué aad5a9b060 Less TODO 2017-09-06 08:59:02 +02:00
Gwendal Roué aa064029ec More typed cursor tests 2017-09-06 08:58:27 +02:00
Gwendal Roué e84060e01c More value tests 2017-09-06 08:50:30 +02:00
Gwendal Roué f4f72ebb43 Record.updateChanges(_:) 2017-09-06 08:36:13 +02:00
Gwendal Roué da51e81e38 Fix typo 2017-09-05 09:01:57 +02:00
Gwendal Roué 247cbdd0d0 Date and NSDate interpret database numbers as unix timestamps. 2017-09-05 08:58:17 +02:00
Gwendal Roué c528740154 Documentation 2017-09-05 07:57:00 +02:00
Gwendal Roué 37b357b050 TODO 2017-09-05 05:50:11 +02:00
Gwendal Roué 18c376979d Reformat links to other Swift versions 2017-09-03 11:39:25 +02:00
Gwendal Roué 9cc4357a70 Merge branch 'master' of github.com:groue/GRDB.swift into Swift4 2017-09-03 11:03:36 +02:00
Gwendal Roué f2d35a052f Cleanup 2017-09-03 10:54:13 +02:00
Gwendal Roué 221f378d10 Tests for zero-length blobs as function arguments 2017-09-03 10:31:02 +02:00
Gwendal Roué 06a8c8b940 GRDB is now able to store and load zero-length blobs. 2017-09-03 10:09:00 +02:00
Gwendal Roué eee80b421a Hide StatementCursor from public interface 2017-09-03 08:48:31 +02:00
Gwendal Roué f6e22c3636 Fix Typo 2017-09-02 16:34:07 +02:00
Gwendal Roué 20d77fbba5 README.md 2017-09-02 16:32:52 +02:00
Gwendal Roué 0393ebe012 Try to force SWIFT_VERSION to 4.0 with pod_target_xcconfig 2017-09-02 12:42:50 +02:00
Gwendal Roué 2beddcf77b Cleanup 2017-09-02 12:42:07 +02:00
Gwendal Roué e784ebbcdd Remove public StatementArguments() 2017-08-31 19:35:11 +02:00
Gwendal Roué 30ee538dbd StatementArguments(), tests, changeling 2017-08-30 20:07:34 +02:00
Gwendal Roué 7939ba6e05 Expose RowCursor.statement, StatementCursor.statement, Statement.index(ofColumn:) 2017-08-30 14:06:50 +02:00
Gwendal Roué 2785e69fc1 Data adopts StatementColumnConvertible 2017-08-29 19:27:47 +02:00
Gwendal Roué d472c1696d Workaround SR-5707 2017-08-28 13:49:08 +02:00
Gwendal Roué d9cfa71fc7 MutablePersistable.databaseDictionary() return [String: DatabaseValue] 2017-08-28 08:13:20 +02:00
Gwendal Roué 715e12912b New MutablePersistable.databaseDictionary() convenience method 2017-08-25 18:20:35 +02:00
Gwendal Roué b182fe27f6 Merge branch 'Swift4' of github.com:groue/GRDB.swift into Swift4 2017-08-25 17:43:19 +02:00
Gwendal Roué 5594b33933 Performance tests: distinguish fetching records with change tracking from simple record structs 2017-08-25 17:43:15 +02:00
Gwendal Roué 059b8800f6 TODO 2017-08-25 14:00:12 +02:00
Gwendal Roué 9f687b1848 Documentation 2017-08-25 06:06:59 +02:00
Gwendal Roué a4a05b1f0a Introduce DatabaseValueCursor, NullableDatabaseValueCursor 2017-08-25 05:54:37 +02:00
Gwendal Roué 1a7b0b0626 Introduce RecordCursor 2017-08-24 09:08:29 +02:00
Gwendal Roué 4c467e46cf CHANGELOG 2017-08-24 08:17:09 +02:00
Gwendal Roué fa71edeb07 Consistently use GRDB as the library name 2017-08-23 13:59:51 +02:00
Gwendal Roué 4ff436371d README 2017-08-23 13:57:25 +02:00
Gwendal Roué 9d8fa0bc5a Documentation 2017-08-23 10:03:03 +02:00
Gwendal Roué 1a8ecd7889 Documentation 2017-08-23 10:01:43 +02:00
Gwendal Roué f6614fdfda Documentation 2017-08-23 10:00:02 +02:00
Gwendal Roué a6055df756 New "Documentation diff" section in CHANGELOG 2017-08-23 08:43:35 +02:00
Gwendal Roué 5af91c5eab Documentation 2017-08-23 08:24:08 +02:00
Gwendal Roué 41974c4a46 Documentation 2017-08-23 08:21:28 +02:00
Gwendal Roué f001b5bd76 Documentation 2017-08-23 08:19:29 +02:00
Gwendal Roué 28cf457853 Add a performance test target that doesn't depend on Core Data, FMDB, Realm, and SQLite.swift. 2017-08-23 08:17:47 +02:00
Gwendal Roué 8ccc23333d Replace DatabaseCursor with new concrete cursors RowCursor, StatementColumnCursor, NullableStatementColumnCursor, and StatementCursor. 2017-08-23 08:16:30 +02:00
Gwendal Roué d95954d980 TODO: learn about Decoder.dateEncodingStrategy 2017-08-22 09:04:00 +02:00
Gwendal Roué 3506881c2a Documentation 2017-08-21 19:23:10 +02:00
Gwendal Roué 51d127c378 TODO.md 2017-08-21 08:48:03 +02:00
Gwendal Roué 2d5dd7ef63 Update GRDBProfiling project 2017-08-21 08:47:53 +02:00
Gwendal Roué ef23ba55a1 sqlite3.h is a private header when the SQLite3 module is used 2017-08-21 08:47:31 +02:00
Gwendal Roué ffdbf2f3f1 TODO.md 2017-08-20 05:33:27 +02:00
Gwendal Roué 56cad83f55 CHANGELOG.md 2017-08-19 16:34:28 +02:00
Gwendal Roué 719f33f7a7 GRDBDemoiOS: use default IPHONEOS_DEPLOYMENT_TARGET 2017-08-19 16:09:30 +02:00
Gwendal Roué 700ffacdb1 Minor 2017-08-19 15:55:36 +02:00
Gwendal Roué a6ef4ed55c Minor 2017-08-19 15:53:50 +02:00
Gwendal Roué c5da564fb3 Use built-in SQLite3 module when available 2017-08-19 15:21:44 +02:00
Gwendal Roué a6b04ebb64 FTS5 Cleanup 2017-08-19 12:35:45 +02:00
Gwendal Roué 99ba6db257 Documentation 2017-08-19 11:42:45 +02:00
Gwendal Roué a3cddb72b9 Documentation: rename "person" to "player" (and avoid both "persons" and "people") 2017-08-19 10:36:28 +02:00
Gwendal Roué 2a9e896095 Remove documentation for PrimaryKeyInfo (reference is enough) 2017-08-19 10:25:20 +02:00
Gwendal Roué 89d522d325 Rename "point of interest" to "place" (addresses #246) 2017-08-19 10:21:57 +02:00
Gwendal Roué 3c4ff587ca Documentation 2017-08-19 10:13:40 +02:00
Gwendal Roué e111529035 Documentation 2017-08-19 10:09:41 +02:00
Gwendal Roué cae1f97032 Update documentation now that TableMapping deletion methods have moved to MutablePersistable 2017-08-18 18:40:57 +02:00
Gwendal Roué 20419834a6 Sequence.Iterator.Element -> Sequence.Element 2017-08-18 18:10:56 +02:00
Gwendal Roué 5dabc2a20b CHANGELOG.md 2017-08-18 18:09:28 +02:00
Gwendal Roué c700f5fc68 Move TableMapping deletion methods to MutablePersistable (prevent TableMapping from being able to modify the database) 2017-08-18 17:15:10 +02:00
Gwendal Roué 0b71cf86f2 Less GRDB 2.0 TODO 2017-08-18 16:49:12 +02:00
Gwendal Roué 96159bd09c RowConvertible.fetchCursor(_:keys:) returns a non-optional cursor. 2017-08-18 16:48:06 +02:00
Gwendal Roué bcff802ccb CHANGELOG.md 2017-08-18 16:29:18 +02:00
Gwendal Roué 376d295853 Replace TableMapping.selectsRowID with TableMapping.databaseSelection 2017-08-18 16:27:24 +02:00
Gwendal Roué 0030ad1804 CHANGELOG.md 2017-08-18 14:57:55 +02:00
Gwendal Roué 4ec3e0f7d8 Drop deprecated TableMapping.primaryKeyRowComparator(_:) 2017-08-18 14:30:28 +02:00
Gwendal Roué e36219e408 Thanks @bfad 2017-08-18 14:22:15 +02:00
Gwendal Roué 8f8f53a697 Fix CocoaPods tests by bumping .swift-version 2017-08-18 14:22:15 +02:00
Gwendal Roué 567292c72f Fix SPM test target
Thanks to @aciidb0mb3r: https://bugs.swift.org/browse/SR-5697?focusedCommentId=27793&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-27793
2017-08-18 14:22:15 +02:00
Gwendal Roué b744f73a76 Restore test target in Package.swift, for swift test 2017-08-18 14:22:15 +02:00
Gwendal Roué da440a5e16 Swift 4 + SPM
- Upgrade Tests/SPM package layout and format to version 4, and have `make test_install_SPM` succeed
- Update .gitignore in order to ignore Package.resolved instead of Package.pins
2017-08-18 14:22:15 +02:00
Brad Lindsay 017af1d5c3 Update Package.swift for version 4 tooling 2017-08-18 14:22:14 +02:00
Gwendal Roué 1f5d75d8e9 Fix a compiler error in Xcode 9 beta 5 (and improve tests for DatabaseValue conformance to Equatable) 2017-08-18 14:22:14 +02:00
Gwendal Roué 8b80abc701 TODO.md 2017-08-18 14:22:14 +02:00
Gwendal Roué dc75ca4caf SE-0166 2017-08-18 14:22:14 +02:00
Gwendal Roué d7d4c0a54d Formatting 2017-08-18 14:22:14 +02:00
Gwendal Roué 823b094b60 SE-0168 2017-08-18 14:22:14 +02:00
Gwendal Roué 06a6c982aa SE-0148 2017-08-18 14:22:14 +02:00
Gwendal Roué 1d15ef01f9 Update Travis CI to use Xcode 9 2017-08-18 14:20:35 +02:00
Gwendal Roué f72ffcbb43 SE-0165 2017-08-18 14:20:35 +02:00
Gwendal Roué e0f2305cd9 SE-0104 2017-08-18 14:20:35 +02:00
Gwendal Roué 210939d2c1 SE-0169 2017-08-18 14:20:35 +02:00
Gwendal Roué 2fd071d90e NSLocalizedDescriptionKey 2017-08-18 14:20:35 +02:00
Gwendal Roué badec62cdd SE-0110 2017-08-18 14:20:35 +02:00
Gwendal Roué 895cda4de7 Xcode 9 beta 3 project updates 2017-08-18 14:20:35 +02:00
Gwendal Roué 21fdc9f350 v1.3.0 2017-08-18 13:13:24 +02:00
Gwendal Roué 398c0ef687 Documentation 2017-08-18 12:25:22 +02:00
Gwendal Roué 3b0a9aef3c No more SQLite 3.20.0 TODO 2017-08-18 08:52:48 +02:00
Gwendal Roué 48ec0916bf Use SQLITE_PREPARE_PERSISTENT flag for cached statements 2017-08-18 08:52:23 +02:00
Gwendal Roué 10af87a7d0 SQLite 3.20.0 2017-08-18 08:35:02 +02:00
Gwendal Roué 96e7996f37 SQLite 3.20.0 TODO 2017-08-03 10:19:52 +02:00
Gwendal Roué 0f7af931a9 SQLite 3.20.0 TODO 2017-08-03 10:16:17 +02:00
Gwendal Roué cfd2d80b78 Fix typo 2017-07-30 15:22:13 +02:00
Gwendal Roué 0386c01aa9 CHANGELOG 2017-07-29 14:36:02 +02:00
Gwendal Roué 2c39c91ac6 CHANGELOG 2017-07-29 13:01:49 +02:00
Gwendal Roué 0eb51e3e8b Int8, Int16, UInt, UInt8, UInt16, UInt32, UInt64 adopt DatabaseValueConvertible and StatementColumnConvertible 2017-07-29 12:58:35 +02:00
Gwendal Roué bb931e9da7 FTS5.api(_:) can now throw an error 2017-07-21 18:34:19 +02:00
Gwendal Roué 7b2e672496 Cleanup 2017-07-21 17:59:04 +02:00
Gwendal Roué cdc6370ee5 Restore column ordering in filter(db, keys: [["a": ..., "b": ...], ...]) removed in 2b2e92c810 2017-07-21 13:45:24 +02:00
Gwendal Roué cc762e4e1d TODO 2017-07-21 12:20:32 +02:00
Gwendal Roué ed525bd1d8 Cleanup 2017-07-21 12:15:35 +02:00
Gwendal Roué 2b2e92c810 Cleanup 2017-07-21 12:13:03 +02:00
Gwendal Roué 44d31ead76 Implement deleteAll(_:keys:), deleteOne(_🔑) on top of the Query Interface 2017-07-21 11:19:24 +02:00
Gwendal Roué ec163e94eb Implement fetchCursor(_:keys:), fetchAll(_:keys:), and fetchOne(_🔑) on top of the Query Interface 2017-07-21 09:13:20 +02:00
Gwendal Roué ec2ac33fec TODO.md 2017-07-21 07:58:25 +02:00
Gwendal Roué 20bda2af26 v1.2.2 2017-07-20 19:30:39 +02:00
Gwendal Roué 7a49f6293d CHANGELOG.md 2017-07-20 17:50:14 +02:00
Gwendal Roué 81b21010f1 Fix memory leak with Configuration.trace 2017-07-20 17:47:11 +02:00
Gwendal Roué 2526e0a2f7 Fix links to reference documentation 2017-07-19 19:40:19 +02:00
Gwendal Roué af1e8470c9 v1.2.1 2017-07-19 09:38:25 +02:00
Gwendal Roué dfd9da68a7 CHANGELOG 2017-07-19 08:32:21 +02:00
Gwendal Roué 5e702234f4 Upgrade SQLite to v3.19.3 2017-07-19 08:31:32 +02:00
Gwendal Roué 9020dcca9a CHANGELOG 2017-07-19 08:28:02 +02:00
Gwendal Roué 930a4e4c1d Improve implementation comments in DatabasePool.readFromCurrentState 2017-07-19 08:22:23 +02:00
Gwendal Roué 4db77f96b7 Improve implementation comments in DatabasePool.readFromCurrentState 2017-07-18 16:34:50 +02:00
Gwendal Roué cc12c046b9 func === (lhs: SQLExpressible?, rhs: SQLCollatedExpression) bugfix 2017-07-18 09:00:49 +02:00
Gwendal Roué f5c63e0997 Remove unused method 2017-07-18 07:48:43 +02:00
Gwendal Roué 29a26800b7 Cleanup 2017-07-17 20:20:20 +02:00
Gwendal Roué bc5eeb3b3a expr == DatabaseValue.null is converted to expr IS NULL. 2017-07-17 20:19:19 +02:00
Gwendal Roué 40d02518b0 Cleanup 2017-07-17 15:33:09 +02:00
Gwendal Roué a2556edc69 Use sqlite3_get_autocommit
This function knows whether the database is currently inside a
transaction or not, and provides robust rollback error handling.
2017-07-17 15:33:01 +02:00
Gwendal Roué 111970fda9 Tests for public protocols and open classes
The goal of those tests is to prevent breaking changes as the one that happened in v1.2, where the DatabaseReader protocol was added a new method without any default implementation.
2017-07-13 16:53:01 +02:00
Gwendal Roué ebeb7bc969 v1.2 2017-07-13 13:17:58 +02:00
Gwendal Roué 6ccac5f69c CHANGELOG.md 2017-07-13 13:00:19 +02:00
Gwendal Roué cc41b8b259 Fix Pool bug introduced in 2add1c68ea
I think this is the bug behind this failed test suite: https://travis-ci.org/groue/GRDB.swift/jobs/253093331

In 2add1c68ea Pool has started relying on *indexes* inside its inner array of items. Those indexes weren't reliable enough: this commit brings back independence from indexes by making the Item type a class again.
2017-07-13 12:17:03 +02:00
Gwendal Roué db1a3456b7 Cleanup 2017-07-13 12:12:56 +02:00
Gwendal Roué 1b9305c073 Less TODO 2017-07-13 11:24:41 +02:00
Gwendal Roué a33814ef40 Documentation for unsafe concurrency APIs 2017-07-13 11:10:02 +02:00
Gwendal Roué 581bc9f27c Support for partial records whose encode(to:) method does not provide values for all table columns 2017-07-13 11:03:23 +02:00
Gwendal Roué 40cff0053f TODO.md 2017-07-13 09:58:42 +02:00
Gwendal Roué cc33b12b0d DatabaseReader.unsafeReentrantRead 2017-07-13 09:11:21 +02:00
Gwendal Roué 2add1c68ea Raise a fatal error when DatabasePool is used in a reentrant way 2017-07-12 20:07:05 +02:00
Gwendal Roué 380b6676a6 Statement.sql trims white space and semicolon 2017-07-12 08:45:56 +02:00
Gwendal Roué f133a36477 TODO.md 2017-07-07 17:13:25 +02:00
Gwendal Roué 5f2d6f8e2f Table creation API enhancements 2017-07-01 16:44:33 +02:00
Gwendal Roué a72c207ec5 v1.1 2017-07-01 12:04:27 +02:00
Gwendal Roué ae3c28dee1 Add missing CSQLite import 2017-07-01 11:39:52 +02:00
Gwendal Roué bd919e5209 DatabaseAggregate (fixes #236) 2017-07-01 11:39:52 +02:00
Gwendal Roué d1697756e9 Remove compiler warning 2017-06-30 07:47:14 +02:00
Gwendal Roué 83c3745165 Documentation 2017-06-30 07:47:14 +02:00
Gwendal Roué 56a4a964b7 QueryInterfaceRequest.order() clears the isReversed flag 2017-06-30 07:47:13 +02:00
Gwendal Roué c9a02faf08 Refactor AdaptedTypedRequest around AdaptedRequest 2017-06-30 07:47:13 +02:00
Gwendal Roué e59388738e FetchedRecordsController: don't assume constant row layout when comparing records 2017-06-30 07:47:13 +02:00
Gwendal Roué c8368d98eb Refactor FetchedRecordsController so that it stops using deprecated TableMapping.primaryKeyRowComparator 2017-06-30 07:47:13 +02:00
Gwendal Roué d12dad2e34 Deprecate TableMapping.primaryKeyRowComparator 2017-06-30 07:47:13 +02:00
Gwendal Roué 1ee8c73562 Fix typo 2017-06-30 03:57:36 +02:00
Gwendal Roué ad8de84257 Update Makefile for Xcode 9 beta 2 2017-06-22 19:34:11 +02:00
Gwendal Roué 48398b4913 v1.0 2017-06-20 07:54:19 +02:00
Gwendal Roué d719fe4612 Bump requirements to Xcode8.3+ / Swift 3.1 2017-06-20 07:54:19 +02:00
Gwendal Roué 034a30b444 CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 9609e2ac4c Database.foreignKeys(on:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 66c2b72a28 Database.afterNextTransactionCommit(_:): document that the closure runs in a protected dispatch queue 2017-06-20 07:54:19 +02:00
Gwendal Roué da48b0880e CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 4134b1549a CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 7265b2535b CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué bb638377ac CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 466113fc4a 🎉 2017-06-20 07:54:19 +02:00
Gwendal Roué 31aea350cb Rename Database.afterCommit(_:) to Database.afterNextTransactionCommit(_:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 56869577d4 Documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué ed3c597a92 Documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué cbb607b6b0 SQLSpecificExpressible.collating(_:) inline documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 7f64abe820 Identify experimental features in the inline documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué b43dc1ba37 Less TODO 2017-06-20 07:54:19 +02:00
Gwendal Roué 59962e5e88 Identify experimental features in the inline documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 8eabcecb69 Fix TransactionObservationExtent.nextTransaction 2017-06-20 07:54:19 +02:00
Gwendal Roué a3ad726111 Cleanup 2017-06-20 07:54:19 +02:00
Gwendal Roué a46b4edb0a Replace experimental badge image with searchable text 2017-06-20 07:54:19 +02:00
Gwendal Roué 7059fe3815 TODO.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 780f1afe91 Replace CLLocationCoordinate2DMake(_:_:) with CLLocationCoordinate2D(latitude:longitude:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 2459b4e56f Foster columns gathered in an enum 2017-06-20 07:54:19 +02:00
Gwendal Roué f750cee594 Documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 1c3824f4b9 Don't retain weak transaction observers 2017-06-20 07:54:19 +02:00
Gwendal Roué 5ba1fa856d Documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué f40a685ac9 Update performance tests for FMDB 2.7.2 2017-06-20 07:54:19 +02:00
Gwendal Roué bf3b6577d5 Deployment target of performance tests is macOS 10.12 2017-06-20 07:54:19 +02:00
Gwendal Roué 7b0659332b Realm 2.8.2 2017-06-20 07:54:19 +02:00
Gwendal Roué 19812cb015 SQLite.swift 0.11.3, FMDB 2.7.2 2017-06-20 07:54:19 +02:00
Gwendal Roué b283c80776 Documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 49838c67ee Typo 2017-06-20 07:54:19 +02:00
Gwendal Roué 4a40bddd82 Better Database.afterCommit(_:) documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 208b7860aa Better Database.afterCommit(_:) documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 05e7c9470b Better Database.afterCommit(_:) documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 2f79d5f805 Database.afterCommit(_:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 1f120a04f9 CHANGELOG.md 2017-06-20 07:54:19 +02:00
Gwendal Roué 90a46f6556 Introduce TransactionObservationExtent 2017-06-20 07:54:19 +02:00
Gwendal Roué 4dff14a02a README: note about "Pure Transaction Observers", and warning about "Recursive Commits" 2017-06-20 07:54:19 +02:00
Gwendal Roué d9a9acb616 README: Introduction to Database Changes Observation 2017-06-20 07:54:19 +02:00
Gwendal Roué 8ea215931e Refactor Request
Rename TypedRequest's associated type from `Fetched` to `RowConverter`, because if TypedRequest needs a type that can decode rows, the type of the decoded rows does not need to be identical to the decoder type.

Introduce AdaptedRequest and AdaptedTypedRequest as results of Request.adapted(_:) and TypedRequest.adapted(_:), instead of the generic AnyRequest and AnyTypedRequest.
2017-06-20 07:54:19 +02:00
Gwendal Roué 6caed6aacc DatabaseMigrator documentation 2017-06-20 07:54:19 +02:00
Gwendal Roué 0c192fcb57 DatabaseMigrator.migrate(_:upTo:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 3e819a5051 TODO.md 2017-06-20 07:54:19 +02:00
Gwendal Roué b31983cc3a TODO: write regression tests for #156 and #157 2017-06-20 07:54:19 +02:00
Gwendal Roué e24cb1783c Change default transaction kind to deferred (the SQLite default). 2017-06-20 07:54:19 +02:00
Gwendal Roué a913aba018 Replace persistentDictionary with encode(to:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 35d34ab524 Remove obsolete documentation of QueryInterfaceRequest.contains(_:) 2017-06-20 07:54:19 +02:00
Gwendal Roué 604cf6b522 Remove QueryInterfaceRequest.contains(_:) 2017-06-20 07:54:19 +02:00
Gwendal Roué e987695732 Remove obsolete documentation of QueryInterfaceRequest.exists() 2017-06-20 07:54:19 +02:00
Gwendal Roué 09f37a86ad Fix link of experimental badges 2017-06-20 07:54:19 +02:00
Gwendal Roué ff32f99610 Better experimental description 2017-06-20 07:54:19 +02:00
Gwendal Roué 4cd099ef30 Fix link of experimental badges 2017-06-20 07:54:19 +02:00
Gwendal Roué 54d3b0eabc Flag Request.adapted(_:) as experimental 2017-06-20 07:54:19 +02:00
Gwendal Roué b3d731b040 Remove QueryInterfaceRequest.exists() 2017-06-20 07:54:19 +02:00
Gwendal Roué 6629ec48a3 Flag SQLExpressionFunction, SQLFunctionName, SQLExpressionUnary, SQLExpressionBinary, SQLExpressionFunction, QueryInterfaceRequest.exists() as experimental 2017-06-20 07:54:19 +02:00
Gwendal Roué 19c273771d Flag row adapters as experimental 2017-06-20 07:54:19 +02:00
Gwendal Roué e7b6919bc1 Experimental badge and FAQ (with workaround https://github.com/isaacs/github/issues/316) 2017-06-20 07:54:19 +02:00
Gwendal Roué 60e6c7d250 Remove DatabaseCoder 2017-06-20 07:54:19 +02:00
Gwendal Roué 4feeb0e608 Help Xcode 9 beta 1 users in the README (completes #230) 2017-06-09 06:53:20 +02:00
Gwendal Roué b3243efdf5 Update Makefile for Xcode 8.3.3 2017-06-09 06:44:26 +02:00
Gwendal Roué 60a23bb280 More Xcode-9 fixes 2017-06-09 06:44:26 +02:00
Gwendal Roué 973f38727d More Xcode-9 fixes 2017-06-09 06:44:26 +02:00
David Hart deaac5808d Make the bug-fix conditional to continue building on 3.1 2017-06-09 06:44:26 +02:00
David Hart 22dc01610e Fix compilation with Xcode 9 in compatibilty mode 2017-06-09 06:44:26 +02:00
Gwendal Roué fe702d8fea The magic command that helps finding unwanted git tags 2017-06-01 10:02:59 +02:00
Gwendal Roué 10e669423f Use the dbValue identifier for variables of type DatabaseValue 2017-06-01 08:35:14 +02:00
Gwendal Roué fbf146657e CHANGELOG for SQLite 3.19.2 2017-05-28 15:48:46 +02:00
Gwendal Roué 8667fab206 v0.110.0 2017-05-28 14:29:41 +02:00
Gwendal Roué e974cd4b33 Fix make test_SPM by backporting 7adfb3c233fc3fdeacbb3933d7d13b4c2a3a2eed and using the default Swift compiler unless TOOLCHAIN is defined 2017-05-28 14:02:13 +02:00
Gwendal Roué 43c96803be CHANGELOG: announce removal of deprecation warning for sqlite3_trace 2017-05-28 13:32:17 +02:00
Gwendal Roué 70b42a5633 CHANGELOG: announce Travis-CI integration 2017-05-28 13:24:21 +02:00
Gwendal Roué 9f989f7706 CHANGELOG: announce SQLCipher v3.4.1 2017-05-28 13:20:27 +02:00
swiftlyfalling 4d976ef803 Add Travis-CI build status badge to README.md 2017-05-28 13:16:47 +02:00
Gwendal Roué 02257fd78f Update SQLite version in documentation 2017-05-28 13:15:41 +02:00
Gwendal Roué 929c8f49a6 Upgrade SQLite to v3.19.2 2017-05-28 13:15:41 +02:00
Gwendal Roué a6ec38c805 Upgrade SQLite to v3.19.1 2017-05-28 13:15:41 +02:00
Gwendal Roué e5ec8ea3b2 Update SQLite version in documentation 2017-05-28 13:15:41 +02:00
Gwendal Roué 36ac5a2802 CHANGELOG for SQLite 3.19.0 2017-05-28 13:15:41 +02:00
Gwendal Roué b5beff5030 Fix SelectStatementTests.testSelectionInfo SPM test 2017-05-28 13:15:41 +02:00
Gwendal Roué d1d1a5da77 Improve SelectionInfo for SQLite 3.19.0 2017-05-28 13:15:41 +02:00
Gwendal Roué 713d58612e SQLite 3.19.0 wants authorizer callbacks to be prepared from NULL inputs 2017-05-28 13:15:41 +02:00
Gwendal Roué bd0990deb4 Upgrade SQLite to v3.19.0 2017-05-28 13:15:41 +02:00
Gwendal Roué 35e8d9c12b Update SQLCipher version in documentation 2017-05-28 11:40:26 +02:00
Gwendal Roué 1fb7f9ff5b Disable query tracing inside EncryptionTests.testExportPlainTextDatabaseToEncryptedDatabase (workaround https://github.com/sqlcipher/sqlcipher/issues/216) 2017-05-28 11:40:26 +02:00
Gwendal Roué 7eecb059e6 Disable EncryptionTests.testExportPlainTextDatabaseToEncryptedDatabase until https://github.com/sqlcipher/sqlcipher/issues/216 is fixed 2017-05-28 11:40:26 +02:00
Gwendal Roué ba8375adb1 Upgrade SQLCipher to v3.4.1 2017-05-28 11:40:26 +02:00
Gwendal Roué 2ef547c461 Fix flaky busy handler tests 2017-05-27 15:04:27 +02:00
Gwendal Roué a34784ca73 TODO: Fix flaky ConcurrencyTests.testReaderInDeferredTransactionDuringDefaultTransaction 2017-05-25 23:02:31 +02:00
Gwendal Roué 5594d46c2d Makefile cleanup 2017-05-25 19:57:51 +02:00
Gwendal Roué dc7a1e3f41 Delete Package.pins files in clean and distclean Makefile targets 2017-05-25 19:57:46 +02:00
Gwendal Roué 68732487f9 Ignore Package.pins files 2017-05-25 19:57:41 +02:00
Gwendal Roué 5ea1d4376d Remove quotes around "GRDB [SPM] (Xcode 8.3, macOS 10.12)" TID in .travis.yml 2017-05-25 19:57:36 +02:00
Gwendal Roué 9cb8b205c5 Rewrite tests that check that closing a connection does not break unclosed statements (this should fix #216, for good this time!) 2017-05-25 19:25:47 +02:00
Gwendal Roué a35c453423 Fix flaky test ConcurrencyTests.testBusyCallback 2017-05-25 18:54:02 +02:00
Gwendal Roué e7f91d7c25 TODO: fix flaky test ConcurrencyTests.testBusyCallback 2017-05-25 18:43:21 +02:00
Gwendal Roué 4886f43463 Rewrite tests that check that closing a connection does not break unclosed statements (this should fix #216) 2017-05-25 18:39:38 +02:00
Gwendal Roué 929c8ac2b5 GRDB has no longer iterators, but cursors 2017-05-25 18:23:14 +02:00
Gwendal Roué 1438934aa6 Extract deployment targets in dedicated xcconfig files. 2017-05-25 17:13:45 +02:00
Gwendal Roué ec65335fcd Use sqlite3_trace_v2 when available (addresses #100) 2017-05-25 17:13:04 +02:00
Gwendal Roué 39d31dbd11 Merge pull request #218 from swiftlyfalling/travis_add_spm_test
Add `make test_SPM` to .travis.yml
2017-05-25 13:53:26 +02:00
swiftlyfalling 6c5be7a169 Minor tweaks 2017-05-24 11:15:59 -04:00
swiftlyfalling b45894fd51 Add test_SPM to travis.yml 2017-05-24 11:13:32 -04:00
swiftlyfalling a660b4e5c4 Merge remote-tracking branch 'groue/master' 2017-05-24 11:04:43 -04:00
Gwendal Roué e11c88cf05 Merge pull request #215 from swiftlyfalling/travis-ci-xcode-82-fix
Makefile Fix: Xcode 8.2 max-iOS builds
2017-05-24 07:53:25 +02:00
swiftlyfalling 40f930f08a Fix Xcode 8.2 max-iOS builds
- Fixes errant “fancy quotes”
2017-05-23 16:57:15 -04:00
swiftlyfalling 0c55e7819d Merge remote-tracking branch 'groue/master' 2017-05-23 16:54:04 -04:00
Gwendal Roué 3c17ee941f Documentation 2017-05-23 11:44:43 +02:00
Gwendal Roué 5a67ca0411 Foster asRequest(of:) 2017-05-23 11:38:17 +02:00
Gwendal Roué 63d04a6707 TODO: upgrade SQLCipher 2017-05-23 08:17:31 +02:00
Gwendal Roué 676a116cda Merge pull request #213 from swiftlyfalling/travis-ci-integration
Continuous Integration (w/ Travis CI)
2017-05-23 07:45:43 +02:00
Gwendal Roué 55435fd324 v0.109.0 2017-05-22 19:58:48 +02:00
Gwendal Roué 612f8059b8 Documentation 2017-05-22 19:58:01 +02:00
Gwendal Roué ffd16f7639 Backport some Makefile improvements from @zmeyc's pr_linux branch 2017-05-22 19:56:57 +02:00
swiftlyfalling 528860161e Add Travis-CI support 2017-05-22 13:24:22 -04:00
swiftlyfalling 1fe6094da5 Remove + ignore .ruby-version to avoid conflicts with Travis-CI
If the .ruby-version file is present and contains a version of Ruby
greater than Travis-CI supports, it will break the Travis-CI builds.
2017-05-22 13:23:07 -04:00
swiftlyfalling 399c51b1ee Merge remote-tracking branch 'groue/master' 2017-05-22 13:18:05 -04:00
Gwendal Roué 55e4abd534 Rename USING_SQLCIPHER to GRDBCIPHER and USING_CUSTOMSQLITE to GRDBCUSTOMSQLITE 2017-05-22 19:15:10 +02:00
Gwendal Roué e9d02f441b More links to RxGRDB 2017-05-22 19:00:24 +02:00
Gwendal Roué f858bcbe5b Rename Request.fetching(_:) to Request.asRequest(of:) 2017-05-22 18:55:51 +02:00
Gwendal Roué cd107711a9 Rename Request.bound(to:) to Request.fetching(_:) 2017-05-22 18:37:46 +02:00
Gwendal Roué ce4c20b112 Replace DatabaseWriter.availableDatabaseConnection with unsafeReentrantWrite() 2017-05-22 18:10:19 +02:00
Gwendal Roué 0b8ba1ccfa Merge branch 'master' of github.com:groue/GRDB.swift 2017-05-22 14:21:29 +02:00
Gwendal Roué c72c97fd53 TODO.md 2017-05-22 13:54:33 +02:00
Gwendal Roué 1e12068e64 DatabaseEventKind.impacts(_ selectionInfo:SelectStatement.SelectionInfo) now returns an non-optional boolean. 2017-05-22 13:53:59 +02:00
Gwendal Roué 1799fe1ff9 Consistently crash for all failed conversions from DatabaseValue 2017-05-22 13:51:39 +02:00
Gwendal Roué ae5175c5b4 CHANGELOG.md 2017-05-17 20:01:28 +02:00
Gwendal Roué 86d5b0b23d Update ReleaseProcess.md 2017-05-17 14:41:43 +02:00
Gwendal Roué 341044356f v0.108.0 2017-05-17 14:27:53 +02:00
Gwendal Roué 5eb7a62062 Add @sroddy to the thanks section 2017-05-17 14:25:09 +02:00
Gwendal Roué 74f96c0766 CHANGELOG.md 2017-05-17 14:24:03 +02:00
Gwendal Roué 49b62cb27a Merge pull request #212 from BendingSpoons/feature/CocoaPods-SQLCipher
SQLCipher support with Cocoapods
2017-05-17 14:20:05 +02:00
Gwendal Roué 798588c54b Documentation for GRDBCipher installation via CocoaPods 2017-05-17 14:19:31 +02:00
Gwendal Roué f1a9cdaa8e Restore GRDB.swift.podspec, introduce GRDBCipher.podspec 2017-05-17 13:27:03 +02:00
Stefano Rodriguez c66c0a11b6 Add Cocoapods checks for SQLCipher subspec 2017-05-17 01:29:28 +02:00
Stefano Rodriguez b1cdd1360b Update README.md 2017-05-17 01:17:10 +02:00
Stefano Rodriguez 7c8b48e08a Fix Podspec 2017-05-15 01:08:33 +02:00
Stefano Rodriguez 64df5c6b41 Update README.md 2017-05-13 22:54:56 +02:00
Stefano Rodriguez a5c1361dc9 Add Support for SQLCipher in CocoaPods 2017-05-13 22:49:14 +02:00
Gwendal Roué 798b1a7d2e Tests for DatabaseEventKind.impacts(_ selectionInfo: SelectStatement.SelectionInfo) and triggers. 2017-05-10 13:35:55 +02:00
Gwendal Roué e484e4c6de Tests for DatabaseEventKind.impacts(_ selectionInfo: SelectStatement.SelectionInfo) and foreign keys. 2017-05-10 13:26:57 +02:00
Gwendal Roué 31299a529a TODO.md 2017-05-10 10:27:53 +02:00
Gwendal Roué 53ac681d49 TODO.md 2017-05-09 10:16:18 +02:00
Gwendal Roué 828ef48441 Database.setupErrorLog() rewrite 2017-05-08 13:27:51 +02:00
Gwendal Roué 63e8742fb1 TODO.md 2017-05-05 13:27:46 +02:00
Gwendal Roué 192a958fdc Fix manual installation git checkout command 2017-05-05 13:26:58 +02:00
Gwendal Roué f606e633da Drop RowConvertible.awakeFromFetch 2017-05-05 13:20:37 +02:00
Gwendal Roué e2d2b031a5 Bump Ruby version for jazzy 2017-05-05 10:16:30 +02:00
Gwendal Roué c203a972ff v0.107.0 2017-05-05 08:23:17 +02:00
Gwendal Roué 44df1aa0bd Update GRDBOSXPerformanceTests for Swift 3.1 2017-05-05 08:16:06 +02:00
Gwendal Roué d010587f44 README.md: more direct links to DemoApps/GRDBDemoiOS 2017-05-05 08:05:49 +02:00
Gwendal Roué 840525c11a Improve DemoApps/GRDBDemoiOS/Database.swift 2017-05-05 08:05:28 +02:00
Gwendal Roué a0881d851c Drop attempt to have Carthage build SQLCipher (undo changes for #41) 2017-05-04 22:50:03 +02:00
Gwendal Roué ac00e05a72 CHANGELOG.md 2017-05-04 20:21:45 +02:00
Gwendal Roué 4938568ea7 Refactor statement cache, allow SQLRequest to use cached statements 2017-05-04 20:11:45 +02:00
Gwendal Roué cb4c07a5fb TODO.md 2017-05-04 18:05:49 +02:00
Gwendal Roué 4edd76341e There are two statement caches: one for statements generated by the user, and one for the statements generated by GRDB. Those are separated so that GRDB has no opportunity to inadvertently modify the arguments of user statements. 2017-05-04 18:05:36 +02:00
Gwendal Roué bb8aee8965 TODO.md 2017-05-04 17:17:36 +02:00
Gwendal Roué 5d97d2d680 TODO.md 2017-05-02 10:16:50 +02:00
Gwendal Roué 3eb2646cad More SPM tests 2017-04-23 19:04:28 +02:00
Gwendal Roué 96c3dadb7b Tests/README.md 2017-04-23 18:38:17 +02:00
Gwendal Roué 4d9a238c27 Merge pull request #208 from groue/SPMTests
Support for Swift Package Manager tests
2017-04-23 16:40:53 +02:00
Gwendal Roué a475cfa340 Tests organization 2017-04-23 16:37:59 +02:00
Gwendal Roué e54cec9123 Move tests to Swift Package Manager test target 2017-04-23 15:47:16 +02:00
Gwendal Roué 3edad29501 Documentation: Database.logError is now available through SPM (#207) 2017-04-22 19:27:20 +02:00
Gwendal Roué 392a004bd1 Add @zmeyc to the thanks section 2017-04-22 19:20:53 +02:00
Gwendal Roué 7f8ec17511 Merge pull request #207 from zmeyc/pr_spm_logging
Enable logging when using SPM
2017-04-22 19:17:53 +02:00
Gwendal Roué d9e6fd3b89 Bump CSQLite dependency to 0.2 2017-04-22 19:17:33 +02:00
Andrey Fidrya 6cf59838a6 Enable logging when using SPM 2017-04-22 20:04:09 +03:00
Gwendal Roué 3efa60ce8a Merge pull request #206 from groue/ErrorLoggingCallback
Error logging callback
2017-04-22 18:27:37 +02:00
Gwendal Roué 7a90cd2562 Database.logError documentation 2017-04-22 17:58:19 +02:00
Gwendal Roué 4cdbe4f0f4 Use Database.logError in GRDBDemoiOS 2017-04-22 17:57:56 +02:00
Gwendal Roué 595408b351 Rename logErrorFunction into logError 2017-04-22 17:57:33 +02:00
Gwendal Roué 4ee1fd9f65 Database.logErrorFunction for GRDBCipher and GRDBCustomSQLite 2017-04-22 17:26:16 +02:00
Gwendal Roué f16f4d557a Database.logErrorFunction for CocoaPods 2017-04-22 16:51:22 +02:00
Gwendal Roué 27314d1af3 No Database.logErrorFunction for SPM 2017-04-22 16:35:12 +02:00
Gwendal Roué 4f14fb0ccd Support for SQLITE_CONFIG_LOG via Database.logErrorFunction 2017-04-22 15:11:01 +02:00
Gwendal Roué 9b2a8f847f Remove some useless availability checks in tests 2017-04-22 15:04:47 +02:00
Gwendal Roué dae4ae1c6b Reduce internal coupling 2017-04-22 11:12:43 +02:00
Gwendal Roué c8023adff1 Cleanup 2017-04-20 14:49:08 +02:00
Gwendal Roué c34ac0f17b Cleanup 2017-04-20 14:37:06 +02:00
Gwendal Roué 2222a1bfe2 doc: Fix links to Github in jazzy-generated doc 2017-04-14 15:59:06 +02:00
Gwendal Roué 3134809c22 minor 2017-04-13 13:51:46 +02:00
Gwendal Roué 203e8c41ce Better test_install_SPM 2017-04-12 14:39:53 +02:00
Gwendal Roué 5804c044d5 make test_install_SPM 2017-04-12 14:24:11 +02:00
Gwendal Roué 80c378df21 v0.106.1 2017-04-12 13:16:39 +02:00
Gwendal Roué 0f3bc5922d Documentation about Swift Package Manager 2017-04-12 12:54:23 +02:00
Gwendal Roué 1810edfa6e Sample SPM executable 2017-04-11 13:58:41 +02:00
Gwendal Roué 362b8d3243 0.106.0 2017-04-11 13:50:28 +02:00
Gwendal Roué b06f76512d Merge pull request #202 from zmeyc/pr_spm1
SPM support
2017-04-11 13:37:23 +02:00
Gwendal Roué 6c2b421b57 Add test_framework_SPM target to Makefile 2017-04-11 13:33:36 +02:00
Gwendal Roué 63b3b4225a Rename package to GRDB, and rename SQLite module to CSQLite 2017-04-11 13:22:26 +02:00
Gwendal Roué 5b7ad40163 [whitespace] 2017-04-11 11:05:49 +02:00
Andrey Fidrya 1751fb38e5 SPM support 2017-04-08 21:32:58 +03:00
Gwendal Roué 184a2bcf18 Typo 2017-04-06 14:19:40 +02:00
Gwendal Roué 57fce9d20f Link to http://github.com/RxSwiftCommunity/RxGRDB 2017-04-06 14:18:54 +02:00
Gwendal Roué d354157c0e v0.105.0 2017-04-06 13:07:03 +02:00
Gwendal Roué de78e065cb CHANGELOG.md 2017-04-06 11:40:01 +02:00
Gwendal Roué 17a49b5d8c New public property: DatabaseWriter.availableDatabaseConnection. This new API opens the door to reentrant uses of the database, a much needed tool for RxGRDB. 2017-04-06 11:02:49 +02:00
Gwendal Roué 6c6bbf6294 Fix failing test for SELECT COUNT(*) FROM table observation 2017-04-06 10:35:41 +02:00
Gwendal Roué 72f04367d9 TODO.md 2017-04-05 11:41:19 +02:00
Gwendal Roué 7395305f87 Failing test for SELECT COUNT(*) FROM table observation 2017-04-05 10:45:37 +02:00
Gwendal Roué 1c62a665c7 TODO.md 2017-04-03 14:21:54 +02:00
Gwendal Roué 518919aeee Merge pull request #194 from groue/modulemapRefactor
Xcode 8.3 support
2017-04-03 14:19:39 +02:00
Gwendal Roué da798b3748 v0.104.0 2017-04-03 14:14:00 +02:00
Gwendal Roué 441e936d88 ReleaseProcess.md 2017-04-03 14:12:24 +02:00
Gwendal Roué 23def44101 Stop requiring that Xcode is located at /Applications/Xcode.app. Add a word about Carthage, and leave the door open. 2017-04-03 14:02:39 +02:00
Gwendal Roué 35fafdb476 CHANGELOG.md 2017-04-03 13:47:12 +02:00
Gwendal Roué 0e20e6a0bb Update manual installation instructions for WatchOS 2017-04-03 13:40:38 +02:00
Gwendal Roué 04654a5c85 Functional GRDBDemoWatchOS 2017-04-03 13:37:36 +02:00
Gwendal Roué e17c4e5271 GRDBDemoWatchOS 2017-04-03 13:10:24 +02:00
Gwendal Roué 4d79b35c47 Share GRDBOSXPerformanceTests scheme 2017-04-03 13:10:08 +02:00
Gwendal Roué 26aeb7dcbd New public function: TableMapping.primaryKeyRowComparator. This new API exposes record comparison abilities that were reserved to FetchedRecordsController, and open a better support for GRDB reactive extensions. 2017-04-02 17:27:25 +02:00
Gwendal Roué 7bc3582525 SelectStatement.SelectionInfo.description 2017-04-02 14:18:48 +02:00
Gwendal Roué 1ad00e1102 Custom SQLite 3.18.0 2017-04-01 19:54:38 +02:00
Gwendal Roué 311ad6b940 New public APIs: SelectStatement.selectionInfo, DatabaseEventKind.impacts(_:). Those new APIs expose database observation abilities that were reserved to FetchedRecordsController, and open a better support for GRDB reactive extensions. 2017-04-01 16:01:55 +02:00
Gwendal Roué c65f3289a3 TODO.md 2017-04-01 15:06:48 +02:00
Gwendal Roué cfeaf2f376 TODO.md 2017-04-01 15:04:59 +02:00
Gwendal Roué 8434e856f4 Update documentation about access to the raw SQLite C API since it is now embedded right into the GRDB module. 2017-04-01 14:59:25 +02:00
Gwendal Roué 35a700027c TODO.md 2017-04-01 14:40:14 +02:00
Gwendal Roué 2196158f58 Run GRDBDemoiOS in Release configuration 2017-04-01 14:13:38 +02:00
Gwendal Roué 56d5ca180a Update ReleaseProcess.md 2017-04-01 14:02:07 +02:00
Gwendal Roué 60326b8f65 Update ReleaseProcess.md 2017-04-01 14:01:46 +02:00
Gwendal Roué 363943583d Update ReleaseProcess.md 2017-04-01 14:01:19 +02:00
Gwendal Roué 4348889865 Drop mention of Carthage support from documentation 2017-04-01 14:00:05 +02:00
Gwendal Roué 50e50e82e1 Makefile cleanup and documentation 2017-04-01 13:38:00 +02:00
Gwendal Roué fd30f16364 Stop testing Carthage (see https://github.com/Carthage/Carthage/issues/1867) 2017-04-01 08:49:05 +02:00
Gwendal Roué 21879db549 Bootstrap GRDBCustom / GRDBCipher tests 2017-03-31 18:18:38 +02:00
Gwendal Roué 313b9d64f6 Bootstrap GRDBCustom / GRDBCipher tests 2017-03-31 13:44:37 +02:00
Gwendal Roué 87be97a38d Some tests require submodules 2017-03-31 13:27:56 +02:00
Gwendal Roué 4f5054d792 Share more tested schemes 2017-03-31 13:27:35 +02:00
Gwendal Roué 51545c4db0 Share tested schemes + test GRCBCipheriOS installation (addresses #193) 2017-03-31 13:23:08 +02:00
Gwendal Roué 98fb48eb1d Makefile adaptation for Xcode 8.1 (test up to iOS 10.1) 2017-03-31 09:22:05 +02:00
Gwendal Roué fa2817ab52 GRDBCipher test app 2017-03-31 08:53:37 +02:00
Gwendal Roué 2a35601ff4 make test checks iOS 8.1 2017-03-31 08:32:03 +02:00
Gwendal Roué ed70058a1f ReleaseProcess.md 2017-03-31 08:14:42 +02:00
Gwendal Roué 79a1b65547 ReleaseProcess.md 2017-03-31 08:01:18 +02:00
Gwendal Roué cccddd8455 make test checks manual install, pod lint, and carthage build 2017-03-31 07:54:49 +02:00
Gwendal Roué 9a4d9f7f1f make test 2017-03-31 06:19:34 +02:00
Gwendal Roué c532f40b7d CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE, CLANG_WARN_DOCUMENTATION_COMMENTS = YES 2017-03-31 06:07:29 +02:00
Gwendal Roué d7e68c340c Disable fragile test DatabasePoolBackupTests.testConcurrentWriteDuringBackup 2017-03-31 05:59:40 +02:00
Gwendal Roué 42a985112a Drop watchOS demo app 2017-03-30 22:47:53 +02:00
Gwendal Roué 16a653ed9d Fix product name of test targets (and restore GRDBCipheriOS tests) 2017-03-30 21:59:33 +02:00
Gwendal Roué 91f18323be Merge branch 'master' of github.com:groue/GRDB.swift into modulemapRefactor
Conflicts:
	.gitignore
2017-03-30 20:12:55 +02:00
Gwendal Roué 09bbb50e1f README.md 2017-03-28 08:36:52 +02:00
Gwendal Roué a4eebfeeb2 Documentation: more explicit dbQueue.inDatabase wrapping in key chapters (addresses #189 from @pumplerod) 2017-03-28 08:33:52 +02:00
Gwendal Roué 62d19c9d11 Xcode8.3 WIP 2017-03-28 08:02:08 +02:00
Gwendal Roué 07142b3052 TODO.md 2017-03-27 09:45:58 +02:00
Gwendal Roué a304bc0eed README.md 2017-03-27 09:42:22 +02:00
Gwendal Roué 857b7e53d9 v0.103.0 2017-03-26 18:39:16 +02:00
Gwendal Roué 2987bb129c CocoaPods test application 2017-03-26 18:32:50 +02:00
Gwendal Roué 8da9ad696b Fix signing of GRDBDemoWatchOS 2017-03-26 18:00:33 +02:00
Gwendal Roué 8720d6937a Remove inaccurate documentation for int64EqualDouble(_:_:): Swift standard library does not aim at providing this function. 2017-03-26 17:55:30 +02:00
Gwendal Roué 9262834ffb Fix the test project for Carthage installation of GRDB on iOS 2017-03-26 17:55:24 +02:00
Gwendal Roué a41b1a5a2d Remove the test project for the no longer supported installation of GRDBCipher via Carthage 2017-03-26 17:55:18 +02:00
Gwendal Roué 1e362fdd53 Prefer write { $0... } over write { db in db... } for one liners 2017-03-26 17:55:06 +02:00
Gwendal Roué 8dfe166944 CocoaPods test 2017-03-26 16:32:35 +02:00
Gwendal Roué 8d0feea2c2 Cocoapods support 2017-03-26 16:28:44 +02:00
Gwendal Roué 47d9f5920f Cocoapods support 2017-03-26 16:24:18 +02:00
Gwendal Roué 25eca4146c Cocoapods support 2017-03-26 16:15:24 +02:00
Gwendal Roué 61938601fd SDK-relative sqlite3.h 2017-03-26 16:04:41 +02:00
Gwendal Roué 61d114f297 Remove inaccurate documentation for int64EqualDouble(_:_:): Swift standard library does not aim at providing this function. 2017-03-26 15:38:37 +02:00
Gwendal Roué eddebfbba5 Prefer write { $0... } over write { db in db... } for one liners 2017-03-26 15:38:03 +02:00
Gwendal Roué 323d828eb7 Fix the test project for Carthage installation of GRDB on iOS 2017-03-26 15:37:46 +02:00
Gwendal Roué bb763f7315 Remove the test project for the no longer supported installation of GRDBCipher via Carthage 2017-03-26 15:37:39 +02:00
Gwendal Roué b1d93112da Embed a copy of sqlite3.h in order to work around my inability at importing <sqlite3.h> from all targeted SDKs (addresses #166, #170) 2017-03-26 15:37:31 +02:00
Gwendal Roué 56bd3513a3 Fix FTS3 pattern test so that it compiles when support for FTS5 is available 2017-03-26 15:14:18 +02:00
Gwendal Roué ddcf26058b CHANGELOG.md 2017-03-26 15:10:47 +02:00
Gwendal Roué ba4ee3f1fc Bugfix 2017-03-26 15:09:05 +02:00
Gwendal Roué dedfd5cd33 Document that extended result codes are not always available (#171, #180) 2017-03-26 15:07:04 +02:00
Gwendal Roué b5296f4206 Remove warning from documentation now that availability checks for FTS3Pattern(matchingAnyTokenIn:), FTS3Pattern(matchingAllTokensIn:), FTS3Pattern(matchingPhrase:) have been added 2017-03-26 14:52:22 +02:00
Gwendal Roué e2e2c58d9f Add availability checks for FTS3Pattern(matchingAnyTokenIn:), FTS3Pattern(matchingAllTokensIn:), FTS3Pattern(matchingPhrase:) 2017-03-26 14:51:11 +02:00
Gwendal Roué 7a90b9ce23 Add availability checks for FTS3 unicode61 tokenizer, FTS4 unindexed columns, and partial indexes. 2017-03-26 14:41:15 +02:00
Gwendal Roué ae0928e686 TODO.md 2017-03-26 13:58:26 +02:00
Gwendal Roué b815ad7a8c Apply SQLCipher advice from https://discuss.zetetic.net/t/important-advisory-sqlcipher-with-xcode-8-and-new-sdks/1688 2017-03-26 13:53:39 +02:00
Gwendal Roué 06cca9033a TODO.md 2017-03-26 13:33:46 +02:00
Gwendal Roué 5302364139 [format] 2017-03-26 13:33:39 +02:00
Gwendal Roué 78b7fc6169 Workaround PRAGMA table_info bug: check against SQLite version instead of build options 2017-03-26 13:32:01 +02:00
Gwendal Roué b159c30cf1 SQLITE_CONSTRAINT_FOREIGNKEY was added in SQLite 3.7.16 (iOS 8.2+ and OS X 10.10+) 2017-03-26 13:17:59 +02:00
Gwendal Roué 5c7712bf6c PRAGMA query_only was added in SQLite 3.8.0 (iOS 8.2+ and OS X 10.10+) 2017-03-26 13:17:25 +02:00
Gwendal Roué e64b766599 Expose withoutRowID table creation option for custom SQLite builds and SQLCipher. 2017-03-26 12:48:21 +02:00
Gwendal Roué 89a852286c Reading list 2017-03-26 11:48:13 +02:00
Gwendal Roué 1e312cfbb1 TODO.md 2017-03-25 16:56:11 +01:00
Gwendal Roué 8d4522227c Replace all assertNoError and try! with throwing tests 2017-03-25 16:31:54 +01:00
Gwendal Roué eee39a7c0b Improve unexpected error reporting 2017-03-25 14:15:04 +01:00
Gwendal Roué bd58c18bb0 Simplify cursor step failure steps 2017-03-25 14:14:42 +01:00
Gwendal Roué 685b3a4f21 SQLite 3.17.0 has a big FTS5 bug: don't ship it. 2017-03-25 14:13:36 +01:00
Gwendal Roué 4e82a482d1 DatabaseCursor: test preservation of custom error codes 2017-03-25 14:12:47 +01:00
Gwendal Roué 1214e28563 Remove the "DatabaseReader.read does not prevent a queue from writing." sentence from the documentation: it is no longer true 2017-03-24 20:18:54 +01:00
Gwendal Roué 9170ed6e3a CHANGELOG.md 2017-03-24 20:12:21 +01:00
Gwendal Roué f2bb8bb8af Remove DatabaseValue.value() 2017-03-24 20:05:02 +01:00
Gwendal Roué 24d74698ef TODO.md 2017-03-24 18:39:49 +01:00
Gwendal Roué ba615c15cb Documentation, and remove DatabaseQueue.writeInTransaction 2017-03-24 18:39:14 +01:00
Gwendal Roué 88f206e7f5 New DatabaseReader.read() guarantee: database modifications are prevented 2017-03-24 09:18:24 +01:00
Gwendal Roué 511740ccd7 Warn against slow compilation in the documentation of Persistable.persistentDictionary, and strip down the documentation of the Record class hoping readers will check detailed protocol documentations (addresses #188) 2017-03-23 08:00:46 +01:00
Gwendal Roué 7a2fab1126 Stop relying on CocoaDocs since http://blog.cocoapods.org/CocoaDocs-Documentation-Sunsetting/ 2017-03-19 15:56:38 +01:00
Gwendal Roué fd435f0941 make doc with Jazzy 2017-03-19 15:49:53 +01:00
Gwendal Roué ffd5a8b321 gh-pages consistency 2017-03-19 15:49:39 +01:00
Gwendal Roué 5454e43bc4 Use Int(exactly:) and Int32(exactly:) initializers 2017-03-18 17:00:06 +01:00
Gwendal Roué a94fd2d127 TODO.md 2017-03-18 13:52:45 +01:00
Gwendal Roué 14c53c5e3e Have DatabasePool implementation better expose the write method and its readerPool as its fundamentals. 2017-03-17 09:06:13 +01:00
Gwendal Roué b25648eea1 Have DatabaseQueue implementation better expose inDatabase as its fundamental method. 2017-03-17 09:05:42 +01:00
Gwendal Roué 10d0d162b5 Performance tests against Realm 2.4.3, SQLite.swift 0.11.2 2017-03-09 17:25:35 +01:00
Gwendal Roué e5b2be4346 README.md 2017-03-07 11:14:29 +01:00
Gwendal Roué 4cea442b59 README.md 2017-03-07 11:11:02 +01:00
Gwendal Roué 532f682fc7 Typo 2017-03-07 11:10:14 +01:00
Gwendal Roué c2cd689c32 README.md 2017-03-07 11:09:00 +01:00
Gwendal Roué c3e986eb56 Document that database pools require mastery of database transactions 2017-03-04 18:19:02 +01:00
Gwendal Roué d91f4c244f Documentation 2017-03-04 18:11:25 +01:00
Gwendal Roué 22b768963f Typo 2017-03-04 18:05:54 +01:00
Gwendal Roué 57354cd1ef README.md 2017-03-04 18:00:14 +01:00
Gwendal Roué c74cc40d5c CHANGELOG.md 2017-03-04 07:22:33 +01:00
Gwendal Roué b867a74b6b CHANGELOG.md 2017-03-03 08:15:31 +01:00
Gwendal Roué 7a10486492 DatabaseError conversion to NSError preserves extended result code 2017-03-03 08:14:36 +01:00
Gwendal Roué f36b833654 CHANGELOG.md 2017-03-02 13:47:53 +01:00
Gwendal Roué ef9206088e v0.102.0 2017-03-02 13:39:09 +01:00
Gwendal Roué e141b26411 Remove done TODOs 2017-03-02 13:38:41 +01:00
Gwendal Roué 1f4da13060 Add ReleaseProcess.md to project, for quick access 2017-03-02 13:38:29 +01:00
Gwendal Roué 4ec85e2f25 Merge pull request #181 from groue/RequestFetchCount
Let all requests count, introduce Request.fetchCount()
2017-03-02 13:01:23 +01:00
Gwendal Roué 842831d729 Merge branch 'master' into RequestFetchCount 2017-03-02 13:01:13 +01:00
Gwendal Roué 39a0b5672b Merge pull request #180 from groue/Issue171
Activate extended result codes, and expose result codes as Swift constants
2017-03-02 12:59:27 +01:00
Gwendal Roué 2729892676 Merge branch 'master' into Issue171 2017-03-02 12:58:42 +01:00
Gwendal Roué 50318354a6 Merge branch 'master' into RequestFetchCount 2017-03-02 12:56:57 +01:00
Gwendal Roué 77593c8031 Fix RequestTests.swift so that it tests the Request protocol, not the concrete type that adopts it. 2017-03-02 10:54:27 +01:00
Gwendal Roué 3bfb9adb99 Document how to query external content tables (addresses #178) 2017-03-02 08:42:19 +01:00
Gwendal Roué deebf289de Rename DatabaseMigrator.registerMigrationWithDisabledForeignKeyChecks to registerMigrationWithDeferredForeignKeyCheck 2017-03-02 08:29:45 +01:00
Gwendal Roué d4e777900c #171: less TODO 2017-03-02 08:24:21 +01:00
Gwendal Roué 1b44683cfe #171: cleanup 2017-03-02 08:21:29 +01:00
Gwendal Roué 0ff53f0bd7 #171: CHANGELOG 2017-03-02 08:03:01 +01:00
Gwendal Roué a5cbf08a76 Documentation 2017-03-02 08:01:43 +01:00
Gwendal Roué 023fa8afc9 #171: Missing upgrades to the new ResultCode APIs 2017-03-02 07:57:02 +01:00
Gwendal Roué a721748de1 #171: fix-it for DatabaseError.code 2017-03-02 07:56:48 +01:00
Gwendal Roué ad112285e6 Wording 2017-03-01 14:41:34 +01:00
Gwendal Roué fe05ac9753 #171: Missing upgrades to the new ResultCode APIs 2017-03-01 14:21:14 +01:00
Gwendal Roué b873162a6f #171: Preserve some extended result code that were lost 2017-03-01 14:19:48 +01:00
Gwendal Roué 846604cce5 Merge branch 'master' into Issue171 2017-03-01 14:12:31 +01:00
Gwendal Roué b1ea970f62 #171: ResultCode tests 2017-03-01 13:57:51 +01:00
Gwendal Roué 5bcfb7f488 #171: ~= ResultCode operator 2017-03-01 13:27:19 +01:00
Gwendal Roué 1908f1b4f6 #171: Documentation 2017-03-01 13:03:54 +01:00
Gwendal Roué b0bf8e81aa Better CHANGELOG 2017-03-01 10:10:18 +01:00
Gwendal Roué 4866ba0c84 Typo 2017-03-01 09:14:45 +01:00
Gwendal Roué 8dadf42504 #171: CHANGELOG 2017-03-01 09:13:57 +01:00
Gwendal Roué fc18b15106 #171: Apply @hartbit's suggestion of having two DatabaseError properties: resultCode and extendedResultCode 2017-03-01 09:05:06 +01:00
Gwendal Roué 9b4e55be28 Documentation for Request.fetchCount() (https://github.com/groue/GRDB.swift/issues/176#issuecomment-282783884) 2017-03-01 08:24:43 +01:00
Gwendal Roué 8a4686984a Tests for Request.fetchCount() (https://github.com/groue/GRDB.swift/issues/176#issuecomment-282783884) 2017-03-01 08:06:54 +01:00
Gwendal Roué 42ebffc4fc Keep Request.fetchCount() simple (https://github.com/groue/GRDB.swift/issues/176#issuecomment-282783884) 2017-03-01 07:56:17 +01:00
Gwendal Roué 2d2c596f75 Add Request.fetchCount(). Implements https://github.com/groue/GRDB.swift/issues/176#issuecomment-282783884 2017-03-01 05:32:52 +01:00
Gwendal Roué fa464b489d TODO 2017-02-28 04:35:18 +01:00
Gwendal Roué b531504912 TODOs for #171, #172, #176, #178 2017-02-28 03:19:23 +01:00
Gwendal Roué e4a346995b #171: rename ResultCode.code into ResultCode.resultCode (@hartbit's suggestion) 2017-02-26 17:24:44 +01:00
Gwendal Roué f0d1f2387d #171: always use extended result codes 2017-02-26 15:49:14 +01:00
Gwendal Roué 7eb592df79 #171: introduce ResultCode 2017-02-26 15:36:21 +01:00
Gwendal Roué a704c0ad35 Add @hartbit to the thanks section 2017-02-25 17:07:11 +01:00
Gwendal Roué acf4077878 Merge pull request #174 from hartbit/fix-record-persistenceconflictpolicy
Fix Record's persistenceConflictPolicy
2017-02-25 15:43:56 +01:00
David Hart ba50771007 add tests 2017-02-22 23:02:44 +01:00
David Hart 898db8b7d4 fix Record getting the default implementation of persistenceConflictPolicy 2017-02-22 19:33:22 +01:00
Gwendal Roué d452a00592 Warning against FTS3Pattern initializers before iOS8.2 and macOS 10.10 2017-02-01 14:13:39 +01:00
Gwendal Roué 4ab8fb359b Restore some tests that were avoided because of linker errors (all we needed was to set deployment targets on test targets) 2017-02-01 13:48:34 +01:00
Gwendal Roué 29e6082663 Fix registerMigrationWithDisabledForeignKeyChecks for legacy sqlite 2017-02-01 13:36:20 +01:00
Gwendal Roué 7c6197b1fc TODO: don't use fts3tokenize before SQLite 3.7.17 2017-02-01 13:31:36 +01:00
Gwendal Roué 1e0e40912b GRDBiOS tests on iOS8.1 2017-02-01 13:28:08 +01:00
Gwendal Roué ff84638df8 Documentation 2017-01-31 09:06:45 +01:00
Gwendal Roué 90dee9c171 Documentation 2017-01-30 09:08:27 +01:00
Gwendal Roué 53873c7864 Rewrite the "How do I close a database connection?" FAQ 2017-01-26 06:20:48 +01:00
Gwendal Roué f60a9708b2 Link to the Xcode8.3beta branch 2017-01-25 18:20:34 +01:00
Gwendal Roué 84497bfba7 TODO.md 2017-01-24 08:53:14 +01:00
Gwendal Roué 4dfd672c04 Compound unique keys: preserve index ordering in generated SQL queries 2017-01-22 16:51:02 +01:00
Gwendal Roué d8b64aa2f4 Use sqlite3_close_v2 in GRDBCipher and GRDBCustomSQLite 2017-01-22 16:04:10 +01:00
Gwendal Roué 4968100420 Expose DatabaseMigrator.registerMigrationWithDisabledForeignKeyChecks to GRDBCipher and GRDBCustomSQLite 2017-01-22 14:37:14 +01:00
Gwendal Roué b52687f356 Documentation 2017-01-21 07:51:42 +01:00
Gwendal Roué 71d4565aa5 Typo 2017-01-20 18:12:19 +01:00
Gwendal Roué 42ff295092 v0.101.1 2017-01-20 14:03:26 +01:00
Gwendal Roué f0758e2a6c Darn 2017-01-20 14:02:27 +01:00
Gwendal Roué 33e93ea156 v0.101.0 2017-01-20 13:53:54 +01:00
Gwendal Roué 9f212184fd FetchedRecordsController.allowBackgroundChangesTracking(in:) 2017-01-20 12:16:14 +01:00
Gwendal Roué 1c16d4bd3f Merge branch 'BackgroundFetchedRecordsController' of github.com:groue/GRDB.swift 2017-01-20 12:07:19 +01:00
Gwendal Roué 0008ffc735 TransactionObserver: update documentation about database event filtering 2017-01-20 11:13:57 +01:00
Gwendal Roué e5dce929bb Data Protection documentation 2017-01-20 09:12:22 +01:00
Gwendal Roué 40bcf96c2b Data Protection documentation 2017-01-20 08:54:23 +01:00
Gwendal Roué 519d4470e3 Drop Configuration.fileAttributes 2017-01-20 08:22:46 +01:00
Gwendal Roué cdf18b5480 README 2017-01-19 17:12:00 +01:00
Gwendal Roué dbe4965438 DatabaseEventKind.tableName 2017-01-19 10:12:30 +01:00
Gwendal Roué 899b9b07dd Merge branch 'master' of github.com:groue/GRDB.swift into BackgroundFetchedRecordsController 2017-01-19 10:10:38 +01:00
Gwendal Roué 54d8a03e87 README 2017-01-19 08:56:34 +01:00
Gwendal Roué 052ad87da0 README 2017-01-19 07:56:02 +01:00
Gwendal Roué 2a515b1d8d README 2017-01-19 07:55:20 +01:00
Gwendal Roué dad48df039 TODO 2017-01-18 16:05:49 +01:00
Gwendal Roué ee798df57d Documentation 2017-01-18 15:54:13 +01:00
Gwendal Roué eed21b8f8f Typo 2017-01-18 15:48:24 +01:00
Gwendal Roué 29938f5703 Documentation 2017-01-18 15:47:45 +01:00
Gwendal Roué 52bcf97d73 TODO.md 2017-01-18 15:02:06 +01:00
Gwendal Roué 9934184f5f README 2017-01-18 08:51:48 +01:00
Gwendal Roué fdf33cbf81 Experimental: FetchedRecordsController.allowBackgroundTracking 2017-01-17 15:01:14 +01:00
Gwendal Roué 34458bc86e README 2017-01-17 09:08:52 +01:00
Gwendal Roué 9b061b3aa7 README 2017-01-17 09:06:34 +01:00
Gwendal Roué 2fa6acef1c README 2017-01-17 09:01:48 +01:00
Gwendal Roué 3afb1f145a README 2017-01-17 08:54:01 +01:00
Gwendal Roué b03b75d125 README 2017-01-17 08:53:17 +01:00
Gwendal Roué b9756f0bdc README 2017-01-17 08:39:52 +01:00
Gwendal Roué c3234cb79f README 2017-01-17 08:33:51 +01:00
Gwendal Roué 828ab97837 README 2017-01-17 08:32:26 +01:00
Gwendal Roué ac66510f32 README organization 2017-01-17 08:31:27 +01:00
Gwendal Roué 599397b6f7 Typo 2017-01-17 08:30:42 +01:00
Gwendal Roué e230f5d358 Introduction 2017-01-17 08:29:36 +01:00
Gwendal Roué 91486f1b70 TODO.md 2017-01-12 08:04:01 +01:00
Gwendal Roué 95e6de8654 Time to jump into 2017 2017-01-10 14:19:41 +01:00
Gwendal Roué 784baaec46 v0.100.0 2017-01-10 13:58:27 +01:00
Gwendal Roué 6adaca568f Copyright (C) 2017 Gwendal Roué 2017-01-10 13:53:13 +01:00
Gwendal Roué bcdcceb809 Cleanup 2017-01-10 13:38:51 +01:00
Gwendal Roué de3d075ff2 Updated documentation for #160 2017-01-10 13:33:37 +01:00
Gwendal Roué c5f3aa21b3 FetchedRecordsController documentation 2017-01-10 13:05:17 +01:00
Gwendal Roué 9831b0e3d4 FetchedRecordsController.setRequest() uses TypedRequest 2017-01-10 08:23:09 +01:00
Gwendal Roué 24a8df801f Upgrade SQLite to v3.16.2 2017-01-10 08:16:00 +01:00
Gwendal Roué e0cfd404a1 Update GRDBDemoiOS 2017-01-10 08:03:21 +01:00
Gwendal Roué 0e62c3455b GRDBiOS tests: enable code coverage 2017-01-10 07:59:56 +01:00
Gwendal Roué 9cd5a7926a TODO: upgrade SQLite to v3.16.2 2017-01-06 18:54:00 +01:00
Gwendal Roué 8e4995c8d9 Upgrade SQLite to v3.16.1 2017-01-06 08:51:25 +01:00
Gwendal Roué ca5fc1e8fc Documentation 2017-01-06 08:43:16 +01:00
Gwendal Roué 14dca4667a Simplify FetchedRecordsController callbacks API 2017-01-06 08:40:09 +01:00
Gwendal Roué ebff14adac Cleanup 2017-01-06 08:24:50 +01:00
Gwendal Roué 51f02ed46e Move TableMapping.primaryKeyFunction and primaryKeyRowComparator into TableMapping.swift 2017-01-06 08:19:07 +01:00
Gwendal Roué 03740d0918 Remove FetchedRecordsController compareRecordsByPrimaryKey initializer option 2017-01-06 08:16:57 +01:00
Gwendal Roué c83a16e22e FetchedRecordsController initialisers use TypedRequest 2017-01-06 08:12:14 +01:00
Gwendal Roué e1bf662884 TODO post #160 2017-01-04 06:53:57 +01:00
Gwendal Roué d866bc9044 Row adopts Hashable 2017-01-04 06:52:57 +01:00
Gwendal Roué fd0e4c20ee CHANGELOG.md 2017-01-04 06:47:53 +01:00
Gwendal Roué 55ca0a80b6 Restore test that one can change the set of columns tracked by a fetched records controller 2017-01-04 06:43:17 +01:00
Gwendal Roué eeaf3dc2cf Merge branch 'fetched_records_events_platforms' of https://github.com/reTXT/GRDB.swift 2017-01-04 06:32:18 +01:00
Gwendal Roué 467b948349 Another diff algorithm to look at 2017-01-03 16:40:47 +01:00
Kevin Wooten f368af3d02 Support “TableViewEvent” on all all platforms
* TableViewEvent features of FetchedRecordsController supported on all platforms
* Renamed TableViewEvent to FetchedRecordsChangeEvent
* Renamed TableViewChange to FetchedRecordsChange
2016-12-30 00:30:23 -07:00
Gwendal Roué 0f34ee7d16 Revert "DatabaseError.code is now Database.ResultCode"
This reverts commit 968942f128.
2016-12-29 13:32:29 +01:00
Gwendal Roué 2fe89fc41b Documentation 2016-12-28 13:05:29 +01:00
Gwendal Roué 968942f128 DatabaseError.code is now Database.ResultCode 2016-12-28 11:55:47 +01:00
Gwendal Roué b5fae096a9 Typo 2016-12-23 07:28:48 +01:00
Gwendal Roué 5cad9a1071 Documentation 2016-12-23 07:28:22 +01:00
Gwendal Roué f4a350c3d0 Typo 2016-12-23 07:22:11 +01:00
Gwendal Roué 89885ed4d9 Document the scope of DatabaseWriter DatabaseReader (#159) 2016-12-23 07:18:39 +01:00
Gwendal Roué 612878d3b1 v0.99.2 2016-12-22 08:30:45 +01:00
Gwendal Roué 65d0bb6a90 TODO.md 2016-12-22 08:29:07 +01:00
Gwendal Roué 484b440816 Database.cachedSelectStatement() no longer returns a statement that can not be reused because it has already failed. 2016-12-21 18:59:23 +01:00
Gwendal Roué 92d78515c4 Failing test for cached select statements that have failed 2016-12-21 18:53:55 +01:00
Gwendal Roué 341bedd7ca Failing test for cached select statements that have failed 2016-12-21 18:46:01 +01:00
Gwendal Roué e9f54f1841 TODO.md 2016-12-21 17:52:58 +01:00
Gwendal Roué 4c4af5f1fc TODO.md 2016-12-21 09:11:23 +01:00
Gwendal Roué 2558cd9356 v0.99.1 2016-12-21 06:06:18 +01:00
Gwendal Roué 4670026c92 Fix #157 for virtual tables 2016-12-21 06:06:12 +01:00
Gwendal Roué 302b9c2ac5 Fix #156 and #157 2016-12-21 05:44:19 +01:00
Gwendal Roué 000f1d02c3 Fix #156? 2016-12-20 19:17:12 +01:00
Gwendal Roué 63ce8429f2 TODO.md 2016-12-20 17:45:59 +01:00
Gwendal Roué 61993c4a50 CHANGELOG.md 2016-12-20 06:19:20 +01:00
Gwendal Roué c248efc9fe v0.99.0 2016-12-20 06:17:43 +01:00
Gwendal Roué ec64ca2865 Documentation & Changelog 2016-12-20 06:15:03 +01:00
Gwendal Roué d4fe7467b6 truncate optimization TODO 2016-12-20 06:14:41 +01:00
Gwendal Roué e8a229103a Fix #156 2016-12-20 06:01:28 +01:00
Gwendal Roué e6cdab37b0 TODO.md 2016-12-19 10:12:56 +01:00
Gwendal Roué 26c88ffaec TODO.md 2016-12-18 14:48:20 +01:00
Gwendal Roué abf1c144c5 TODO.md 2016-12-16 19:58:13 +01:00
Gwendal Roué c4e04d6e07 Tests for FetchedRecordsController error handling 2016-12-16 19:46:46 +01:00
Gwendal Roué ed4826a67f FetchedRecordsController error handling 2016-12-16 19:46:12 +01:00
Gwendal Roué dee2df9e45 TODO.md 2016-12-16 18:45:40 +01:00
Gwendal Roué acabd11d40 CHANGELOG.md 2016-12-16 14:21:47 +01:00
Gwendal Roué 8adea6ba1e TODO.md 2016-12-16 14:20:50 +01:00
Gwendal Roué c36be55c2f FetchedRecordsController error handling WIP 2016-12-16 09:09:50 +01:00
Gwendal Roué 5355555568 Typo 2016-12-16 07:42:34 +01:00
Gwendal Roué 176735d4cf v0.98.0 2016-12-16 05:35:39 +01:00
Gwendal Roué 3e01bca690 Documentation 2016-12-16 05:25:18 +01:00
Gwendal Roué dd99d96c24 Documentation: links to StatementArgument reference 2016-12-16 05:12:34 +01:00
Gwendal Roué 22e8c59031 TODO.md 2016-12-16 05:02:37 +01:00
Gwendal Roué 44cefc89e4 Documentation for StatementArguments.append(contentsOf:) and operators +, &+, += 2016-12-16 05:02:27 +01:00
Gwendal Roué df15249f23 Tests for StatementArguments.append(contentsOf:) and operators +, &+, += 2016-12-16 05:02:01 +01:00
Gwendal Roué b737321cbd Rows expressed as dictionary literals now preserve column ordering, and allow duplicated column names 2016-12-16 05:01:07 +01:00
Gwendal Roué 319380ec6c CHANGELOG.md 2016-12-15 21:45:20 +01:00
Gwendal Roué cae7cad5d4 TODO.md 2016-12-15 21:45:11 +01:00
Gwendal Roué d4c7b41897 StatementArguments.append(contentsOf:) returns the updated values; operators +, &+, += 2016-12-15 21:39:28 +01:00
Gwendal Roué 0ecf6b5aa1 Drop StatementArguments + StatementArguments (because it allows [1, 2] + ["foo": 1] to compile) 2016-12-15 17:50:56 +01:00
Gwendal Roué cb51c03992 StatementArguments + StatementArguments 2016-12-15 17:47:01 +01:00
Gwendal Roué 5dca5fe3cb StatementArguments.append(contentsOf:) refuses to update named arguments 2016-12-15 17:38:33 +01:00
Gwendal Roué a7acd50159 StatementArguments.append(contentsOf:) 2016-12-15 17:26:23 +01:00
Gwendal Roué e732ec9fe4 v0.97.0 2016-12-15 08:56:46 +01:00
Gwendal Roué e4070c8b5e Clarify scope of mismatched Swift/SQLite transaction state 2016-12-15 08:49:38 +01:00
Gwendal Roué b171b5904b CHANGELOG.md 2016-12-15 08:48:34 +01:00
Gwendal Roué cc89c994c8 Remove useless self. 2016-12-15 08:13:33 +01:00
Gwendal Roué fc2689e207 Fix Pool.get when an error prevents a pool item from being created (counting semaphore wasn't signaled). This fixes DatabasePool.read when read connection can not be established. Tests. 2016-12-15 08:09:17 +01:00
Gwendal Roué a5979b2e47 Documentation 2016-12-15 05:16:36 +01:00
Gwendal Roué 2eb8e32705 Documentation 2016-12-15 05:12:31 +01:00
Gwendal Roué b32984b1d6 Document improved error handling of DatabasePool.readFromCurrentState() and support for raw BEGIN/COMMIT/ROLLBACK transaction statements 2016-12-15 05:11:25 +01:00
Gwendal Roué 7e2fd9e690 DatabasePool.readFromCurrentState throws if it can't acquire an isolated database access 2016-12-15 04:57:31 +01:00
Gwendal Roué a96dac8205 Now that we support free BEGIN/COMMIT transaction statements, DatabaesPool.readFromCurrentState will be able to handle read errors 2016-12-15 04:00:00 +01:00
Gwendal Roué 6afc2fd75a Test that DatabasePool.read and readFromCurrentState open a transaction 2016-12-15 03:58:44 +01:00
Gwendal Roué e44bd4684b Fix SerializedDatabase crash when database is deallocated in its own queue 2016-12-15 03:57:46 +01:00
Gwendal Roué 115158a70e Cleanup 2016-12-14 20:19:10 +01:00
Gwendal Roué 63577feca4 Documentation 2016-12-14 18:49:11 +01:00
Gwendal Roué e8b91bf617 TODO.md 2016-12-14 18:47:42 +01:00
Gwendal Roué 567e6f1d82 TODO 2016-12-14 12:55:22 +01:00
Gwendal Roué 2b9b8ce536 Cleanup 2016-12-14 12:53:11 +01:00
Gwendal Roué a0f4cb9271 Fix failing tests for TransactionObserver 2016-12-14 12:49:33 +01:00
Gwendal Roué 46f24c582c Fix failing tests for Database.isInsideTransaction 2016-12-14 08:59:57 +01:00
Gwendal Roué 2068710a30 Failing test for Database.isInsideTransaction when transaction is implicitly rollbacked 2016-12-14 08:19:13 +01:00
Gwendal Roué 0568b5c6de Tests for free BEGIN/COMMIT/ROLLBACK statements 2016-12-14 08:11:20 +01:00
Gwendal Roué a0d9b9fbe8 Support for free BEGIN/COMMIT/ROLLBACK statements 2016-12-14 08:07:42 +01:00
Gwendal Roué 2190e449c1 Documentation fix 2016-12-13 09:13:46 +01:00
Gwendal Roué f665b56e2b Documentation 2016-12-12 08:46:50 +01:00
Gwendal Roué 041b6abd59 Documentation 2016-12-12 08:42:02 +01:00
Gwendal Roué fb7ace729c Documentation 2016-12-12 08:41:18 +01:00
Gwendal Roué a68ed01003 Documentation 2016-12-12 08:38:03 +01:00
Gwendal Roué 95af80acde Documentation 2016-12-12 08:21:27 +01:00
Gwendal Roué 18664b7e7e Documentation 2016-12-12 08:13:31 +01:00
Gwendal Roué 37f9634389 v0.96.0 2016-12-11 21:32:31 +01:00
Gwendal Roué a995b76f24 Request.adapted(_:) example 2016-12-11 21:13:18 +01:00
Gwendal Roué cb81e50f71 Request.adapted(_:) 2016-12-11 21:07:52 +01:00
Gwendal Roué f8ba151b76 Typo 2016-12-11 08:00:13 +01:00
Gwendal Roué a0af67fce8 Documentation 2016-12-11 07:58:49 +01:00
Gwendal Roué 1467936c89 Typo 2016-12-11 07:57:36 +01:00
Gwendal Roué 0d3008b839 TODO.md 2016-12-10 05:37:35 +01:00
Gwendal Roué 517821632a TODO.md 2016-12-10 05:29:37 +01:00
Gwendal Roué 0ed3e540c2 Typo 2016-12-10 05:20:27 +01:00
Gwendal Roué c96bb16db6 Typo 2016-12-09 15:34:24 +01:00
Gwendal Roué bd82441883 CHANGELOG.md 2016-12-09 15:32:41 +01:00
Gwendal Roué 18421cde49 v0.95.0 2016-12-09 13:39:21 +01:00
Gwendal Roué 6dea26932e Merge branch 'master' of github.com:groue/GRDB.swift into TypedFetchRequest 2016-12-09 13:38:21 +01:00
Gwendal Roué 258768505e Documentation 2016-12-09 13:32:00 +01:00
Gwendal Roué 8caa20b746 Refactor Row Adapters documentation 2016-12-09 13:26:02 +01:00
Gwendal Roué 5efc39af6a Documentation 2016-12-09 12:49:05 +01:00
Gwendal Roué 66daa2eb29 RangeRowAdapter(CountableClosedRange<Int>) 2016-12-09 09:54:25 +01:00
Gwendal Roué 02687991e0 #153: GRDB requires Xcode 8.1+ 2016-12-09 09:44:20 +01:00
Gwendal Roué 1e64592a39 Documentation 2016-12-09 09:02:49 +01:00
Gwendal Roué 9d2b074bec Restore MyPlayground content 2016-12-09 08:56:12 +01:00
Gwendal Roué 384a6f3d36 Documentation 2016-12-09 08:54:13 +01:00
Gwendal Roué 754d972253 Documentation 2016-12-09 08:50:31 +01:00
Gwendal Roué 9a29a6de5a Documentation 2016-12-09 08:49:23 +01:00
Gwendal Roué f6513932b0 Documentation 2016-12-09 08:48:26 +01:00
Gwendal Roué 368f91c4c5 Documentation 2016-12-08 21:02:03 +01:00
Gwendal Roué f1f40f0289 CHANGELOG.md 2016-12-08 19:14:08 +01:00
Gwendal Roué 1d6671c11a Introduce RangeRowAdapter 2016-12-08 19:07:11 +01:00
Gwendal Roué 9a0fa2f8b3 Documentation 2016-12-08 18:41:16 +01:00
Gwendal Roué 9b6ec9ffd3 Documentation 2016-12-08 18:28:23 +01:00
Gwendal Roué e9b8fe5018 Documentation 2016-12-08 18:09:31 +01:00
Gwendal Roué 4a5cec8ed5 Documentation 2016-12-08 18:07:29 +01:00
Gwendal Roué fa6f0ba77c Documentation 2016-12-08 18:05:04 +01:00
Gwendal Roué a8fc58e143 Documentation 2016-12-08 18:04:36 +01:00
Gwendal Roué 57961e04b3 Documentation 2016-12-08 18:00:36 +01:00
Gwendal Roué 6628aa7eaf Documentation 2016-12-08 17:56:27 +01:00
Gwendal Roué b7e492e03d Documentation 2016-12-08 17:24:15 +01:00
Gwendal Roué 2f2dc86c9d Documentation 2016-12-08 17:20:32 +01:00
Gwendal Roué bfb2ff9390 Documentation 2016-12-08 16:02:35 +01:00
Gwendal Roué cbd14c4b8c Documentation 2016-12-08 14:03:22 +01:00
Gwendal Roué cb08660a78 Rename FetchRequest -> Request 2016-12-08 13:56:05 +01:00
Gwendal Roué 87e1b075e0 Remove public qualifiers from README.md 2016-12-08 09:08:33 +01:00
Gwendal Roué 26a3682c6e Documentation 2016-12-08 09:07:05 +01:00
Gwendal Roué be30a2463a Documentation 2016-12-08 08:50:29 +01:00
Gwendal Roué cc1df37725 Documentation 2016-12-08 08:50:00 +01:00
Gwendal Roué 3510032050 Documentation 2016-12-08 08:48:20 +01:00
Gwendal Roué 07aecd3a95 Fix failing tests of TypedFetchRequest 2016-12-08 08:43:58 +01:00
Gwendal Roué 0e2a96b402 Failing tests from TypedFetchRequest 2016-12-08 08:39:06 +01:00
Gwendal Roué 603c121874 Documentation 2016-12-08 08:09:49 +01:00
Gwendal Roué 9e634196bf Public SQLFetchRequest initializer 2016-12-08 07:48:28 +01:00
Gwendal Roué 4f20ea4570 Documentation 2016-12-08 07:14:58 +01:00
Gwendal Roué c851708b3d Documentation 2016-12-08 06:53:58 +01:00
Gwendal Roué fd6a693bc8 Documentation 2016-12-08 06:48:53 +01:00
Gwendal Roué bab56b4c9d Documentation 2016-12-08 06:46:39 +01:00
Gwendal Roué 970da50910 Expose SQLFetchRequest, and cleanup 2016-12-07 23:20:58 +01:00
Gwendal Roué 0008e4b645 FetchedRecordsController's ObservedRequest adopts TypedFetchRequest 2016-12-07 22:39:53 +01:00
Gwendal Roué 89e7a62d99 Introduce AnyFetchRequest, TypedFetchRequest, AnyTypedFetchRequest 2016-12-07 22:21:19 +01:00
Gwendal Roué 74e89c542a Cleanup 2016-12-07 18:45:14 +01:00
Gwendal Roué d441483201 TODO.md 2016-12-07 11:07:57 +01:00
Gwendal Roué f11d4fa613 v0.94.0 2016-12-07 10:48:25 +01:00
Gwendal Roué 11f9880ccf Documentation 2016-12-07 10:12:31 +01:00
Gwendal Roué 8c440961c5 Database.columnCount(in:) 2016-12-07 10:10:59 +01:00
Gwendal Roué 8f5d7da934 Documentation 2016-12-07 09:03:15 +01:00
Gwendal Roué 807347da80 v0.93.1 2016-12-07 08:55:52 +01:00
Gwendal Roué 9364491316 CHANGELOG.md 2016-12-07 08:54:34 +01:00
Gwendal Roué 255e12849e Fix failing test for change tracking of wrapped Record 2016-12-07 08:46:02 +01:00
Gwendal Roué 5c0fe81dcf Failing test for change tracking of wrapped Record 2016-12-07 08:31:47 +01:00
Gwendal Roué e34dee8852 Documentation 2016-12-05 19:40:25 +01:00
Gwendal Roué a803420576 Documentation 2016-12-05 19:32:50 +01:00
Gwendal Roué a1939bc295 Documentation 2016-12-05 19:31:02 +01:00
Gwendal Roué 8c7bbd937f Documentation 2016-12-05 19:19:59 +01:00
Gwendal Roué c87b2eaf7b Documentation 2016-12-05 13:44:57 +01:00
Gwendal Roué f156718d86 Documentation 2016-12-05 13:44:10 +01:00
Gwendal Roué 9cabfacb99 Documentation 2016-12-05 13:42:32 +01:00
Gwendal Roué 377237d7c0 Documentation 2016-12-05 13:35:36 +01:00
Gwendal Roué 13f2611b25 Documentation 2016-12-05 13:32:23 +01:00
Gwendal Roué 519dfd3be7 Update "fetching methods don't fail" guarantee 2016-12-05 13:27:31 +01:00
Gwendal Roué c9c8d23ed5 Add a 3rd guarantee 2016-12-05 13:17:22 +01:00
Gwendal Roué ed4ceb41b5 Documentation 2016-12-05 10:06:58 +01:00
Gwendal Roué fb4643630b Documentation 2016-12-05 09:23:09 +01:00
Gwendal Roué 999c3be21a Documentation 2016-12-05 09:20:29 +01:00
Gwendal Roué 0793a0638e Documentation 2016-12-05 09:13:45 +01:00
Gwendal Roué 8ad1d93cc6 Documentation 2016-12-05 08:23:49 +01:00
Gwendal Roué afb4c9a00d Documentation 2016-12-05 08:15:48 +01:00
Gwendal Roué 93d9516a07 Minor 2016-12-04 15:42:31 +01:00
Gwendal Roué 7950f23b6d Typo 2016-12-04 09:34:58 +01:00
Gwendal Roué 178e206d19 v0.93.0 2016-12-04 07:42:13 +01:00
Gwendal Roué d157308306 Upgrade SQLite to v3.15.2 2016-12-04 07:35:54 +01:00
Gwendal Roué 261eb19fea Documentation 2016-12-04 06:51:14 +01:00
Gwendal Roué 6a973421e3 Fix typo 2016-12-03 08:48:14 +01:00
Gwendal Roué 325110c0cd Documentation 2016-12-03 08:12:19 +01:00
Gwendal Roué 184360925d Documentation 2016-12-02 21:20:08 +01:00
Gwendal Roué 58710196ca CHANGELOG.md 2016-12-02 21:18:48 +01:00
Gwendal Roué a3c57a01d6 Documentation 2016-12-02 20:05:00 +01:00
Gwendal Roué 63d26c2a51 Documentation 2016-12-02 19:44:02 +01:00
Gwendal Roué 8cd824f66f Documentation 2016-12-02 19:43:30 +01:00
Gwendal Roué 1652990324 Rewrite readFromCurrentState documentation 2016-12-02 19:40:33 +01:00
Gwendal Roué 28221e398e Documentation 2016-12-02 14:23:17 +01:00
Gwendal Roué 49fde8158f Documentation 2016-12-02 14:02:17 +01:00
Gwendal Roué 59d1526a88 Documentation 2016-12-02 13:58:17 +01:00
Gwendal Roué 36fdf1f67b Documentation 2016-12-02 13:57:19 +01:00
Gwendal Roué a2771c262b Documentation 2016-12-02 13:56:34 +01:00
Gwendal Roué de4e753429 Documentation 2016-12-02 13:13:44 +01:00
Gwendal Roué cac9104769 Documentation 2016-12-02 13:09:39 +01:00
Gwendal Roué f56cb03a09 Documentation 2016-12-02 12:59:43 +01:00
Gwendal Roué 911d3ad722 Documentation: add a 3rd concurrency rule 2016-12-02 12:52:55 +01:00
Gwendal Roué 72a1984331 v0.92.1 2016-12-02 08:40:06 +01:00
Gwendal Roué 67035b8422 Database.execute(_:) iterates all rows of statements 2016-12-02 08:28:24 +01:00
Gwendal Roué 1c9416fbed Cleanup 2016-12-02 06:38:13 +01:00
Gwendal Roué cf25ced2e6 Documentation 2016-12-02 06:04:47 +01:00
Gwendal Roué 4003697850 TODO 2016-12-02 05:29:08 +01:00
Gwendal Roué 7f48c7abbe v0.92.0 2016-12-01 19:35:30 +01:00
Gwendal Roué b8d924ab6f Restore DatabasePool in a stable state 2016-12-01 19:17:19 +01:00
Gwendal Roué b58a4e90da WIP DatabaseWriter/DatabaseReader improvements 2016-12-01 18:13:00 +01:00
Gwendal Roué f781da41a4 WIP: the recent failing tests of DatabasePool.readFromCurrentState, a paramount brick of FetchedRecordsController, have led to a refactoring of the DatabaseWriter protocol, and DatabasePool.write { ... } always executing a transaction. 2016-12-01 14:12:20 +01:00
Gwendal Roué c0695e80a8 Fix failing DatabasePool tests 2016-12-01 10:44:28 +01:00
Gwendal Roué 019363e56b Failing tests for DatabasePool.read 2016-12-01 10:44:18 +01:00
Gwendal Roué bf76567fdf Remove useless code 2016-12-01 10:43:10 +01:00
Gwendal Roué e64250c519 Documentation 2016-12-01 09:27:16 +01:00
Gwendal Roué 4d190cd055 Documentation 2016-12-01 09:24:56 +01:00
Gwendal Roué fe02fd7284 Documentation 2016-12-01 09:23:56 +01:00
Gwendal Roué d73ced98ad Documentation 2016-12-01 09:22:22 +01:00
Gwendal Roué ee5f915cca Documentation 2016-12-01 09:20:34 +01:00
Gwendal Roué d801f1f5fb Failing test for DatabasePool.readFromCurrentState 2016-12-01 08:56:04 +01:00
Gwendal Roué bd32afbed2 Rename DatabaseWriter.readFromWrite to readFromCurrentState 2016-12-01 08:55:47 +01:00
Gwendal Roué 226d98cf6b CHANGELOG.md 2016-12-01 06:35:34 +01:00
Gwendal Roué dc3b4d3770 CHANGELOG.md 2016-12-01 06:31:39 +01:00
Gwendal Roué 409169061e CHANGELOG.md 2016-12-01 06:30:27 +01:00
Gwendal Roué c539166747 Cleanup 2016-12-01 06:08:30 +01:00
Gwendal Roué 2bb199bc25 CHANGELOG.md 2016-12-01 05:20:27 +01:00
Gwendal Roué 6da9c50b9d CHANGELOG.md 2016-12-01 05:19:00 +01:00
Gwendal Roué 8118f781d9 v0.91.0 2016-11-30 20:26:19 +01:00
Gwendal Roué 2e2f28d1bb Documentation 2016-11-30 20:24:17 +01:00
Gwendal Roué 316bb91625 Documentation 2016-11-30 20:23:22 +01:00
Gwendal Roué 263adb157c Update tests for SQLCipher 2016-11-30 19:34:09 +01:00
Gwendal Roué 18937bdcc4 Fixit files belong to GRDB 2016-11-30 18:49:17 +01:00
Gwendal Roué 948d7498bd Expose fixit files into CocoaPods 2016-11-30 18:35:38 +01:00
Gwendal Roué 59ff18b508 Thanks @kdubb in the README 2016-11-30 14:07:19 +01:00
Gwendal Roué baa9501c65 Fix-its for removed APIs. Update GRDBDemoiOS for FetchedRecordsController changes 2016-11-30 13:57:46 +01:00
Gwendal Roué 5c44f55ef6 FetchedRecordsController: remove some crash opportunities by compiling the fetch request statement right from the initializer and the setRequest() method. 2016-11-30 13:27:51 +01:00
Gwendal Roué 095778cf0f Documentation 2016-11-30 10:53:57 +01:00
Gwendal Roué 2cec3f29d1 Statement.fetchCursor() no longer throws. TODO: Type.fetchCursor(statement) should not throw 2016-11-30 09:18:22 +01:00
Gwendal Roué 9523b88d77 CHANGELOG.md 2016-11-30 09:13:02 +01:00
Gwendal Roué 6bcab179d1 Classify all try! and fatalError into TODO, Programmer Error, or GRDB bug that needs to be fixed. 2016-11-30 08:56:45 +01:00
Gwendal Roué fc1fdab51a Documentation 2016-11-29 22:35:05 +01:00
Gwendal Roué f9bb3defde Documentation 2016-11-29 22:34:12 +01:00
Gwendal Roué 6075a92905 Documentation 2016-11-29 22:14:45 +01:00
Gwendal Roué f495edfb3a Improve Cursor test coverage 2016-11-29 21:11:12 +01:00
Gwendal Roué 6af47fa6ee CHANGELOG.md 2016-11-29 19:03:15 +01:00
Gwendal Roué 972789dba3 Replace Array(Type.fetchCursor()) with Type.fetchAll() 2016-11-29 19:02:58 +01:00
Gwendal Roué cec1ed8d3d IteratorCursor has public initializers. Add joined() method for cursors of sequences. 2016-11-29 19:02:10 +01:00
Gwendal Roué 374963167a Documentation 2016-11-29 17:29:25 +01:00
Gwendal Roué ccb5826a25 Documentation 2016-11-29 14:27:15 +01:00
Gwendal Roué 527aed0ea3 Documentation 2016-11-29 14:17:41 +01:00
Gwendal Roué a8e266377c Documentation 2016-11-29 12:02:29 +01:00
Gwendal Roué de57dc9410 TODO: think about supporting Cursor's underestimatedCount 2016-11-29 08:49:58 +01:00
Gwendal Roué 617f0c8c17 TODO: more Cursor methods so that it looks more like a sequence 2016-11-29 08:47:34 +01:00
Gwendal Roué 2e73199153 Cleanup FlattenCursor 2016-11-29 08:41:13 +01:00
Gwendal Roué 5b0b674988 DatabaseStore: *really* expose initialization error (addresses https://github.com/groue/GRDB.swift/pull/148#issuecomment-263376526) 2016-11-29 08:21:43 +01:00
Gwendal Roué d85a74570d DatabaseStore: expose initialization error (addresses https://github.com/groue/GRDB.swift/pull/148#issuecomment-263376526) 2016-11-29 08:20:36 +01:00
Gwendal Roué bb1f8aab24 Drop Cursor.lazy 2016-11-29 06:35:09 +01:00
Gwendal Roué 0c4fb36827 Add RowFetchTests 2016-11-28 20:48:38 +01:00
Gwendal Roué ec2017ff72 Cursor.enumerated, filter, flatMap, map now return cursors. Cursor.lazy returns a lazy sequence. Introduce AnyCursor. Force Cursor types to be classes. 2016-11-28 20:34:53 +01:00
Gwendal Roué f3cc0a07bc Update sample playgrounds 2016-11-28 16:33:14 +01:00
Gwendal Roué 5e2dc95331 DatabaseValueConvertible.fetchOne(): avoid double DatabaseValue conversion 2016-11-28 08:46:57 +01:00
Gwendal Roué ee99abc266 Replace fetchCursor().next() with fetchOne() 2016-11-28 08:41:59 +01:00
Gwendal Roué cbf4ab797d TODO.md 2016-11-28 08:35:24 +01:00
Gwendal Roué bbe0bfadd9 #147: fetchCursor, fetchAll & fetchOne all throw sqlite3_prepare_v2 errors, sqlite3_step errors, and conversion errors (for DatabaseValueConvertible) 2016-11-27 20:13:58 +01:00
Gwendal Roué 35414e0afd Update GRDBProfiling app 2016-11-27 19:29:50 +01:00
Gwendal Roué 90e99aac3b TODO.md 2016-11-27 19:09:49 +01:00
Gwendal Roué 59506a97d6 Cleanup 2016-11-27 19:08:25 +01:00
Gwendal Roué ebf9b0e4f1 Simplify tests for RowConvertible fetch requests 2016-11-27 18:44:54 +01:00
Gwendal Roué b85a8b8b0b #147: DatabaseValueConvertible.fetchOne() can throw conversion errors 2016-11-27 18:21:04 +01:00
Gwendal Roué f8029a6dc9 Remove a couple try! 2016-11-27 15:38:36 +01:00
Gwendal Roué 95eb9afeef Cleanup 2016-11-27 15:37:03 +01:00
Gwendal Roué 87024f0426 QueryInterfaceSelectQueryDefinition.makeDeleteStatement() throws 2016-11-27 15:26:23 +01:00
Gwendal Roué 09697f2593 DAO.init() throws DatabaseError instead of crashing whenever table does not exist, or database can't be accessed 2016-11-27 15:23:00 +01:00
Gwendal Roué e99e9f3e40 Migration.runWithDisabledForeignKeys(): throw error from PRAGMA foreign_keys = ON 2016-11-27 15:18:25 +01:00
Gwendal Roué b8c05e551d Cleanup 2016-11-27 15:14:38 +01:00
Gwendal Roué 829eb7d3a2 SelectStatement.SelectionInfo cleanup 2016-11-27 15:12:08 +01:00
Gwendal Roué 268080cbc5 #147: FetchedRecordsController.performFetch() can now throw database errors; remove work around for SR-2623 2016-11-27 08:19:43 +01:00
Gwendal Roué 8d9d0dd826 DatabasePool.nonIsolatedRead(_:) can now throw on macOS, too 2016-11-27 06:26:50 +01:00
Gwendal Roué 195c201f87 #147: DatabasePool.read(_:) and DatabasePool.nonIsolatedRead(_:) can now throw database errors. 2016-11-26 23:44:14 +01:00
Gwendal Roué ceb0fc4db9 TODO.md 2016-11-26 23:42:36 +01:00
Gwendal Roué 6121a9b48c Remove dead code 2016-11-26 23:22:34 +01:00
Gwendal Roué e3138154f1 Update performance tests 2016-11-26 23:18:53 +01:00
Gwendal Roué ac6c7f6a35 #147: fetchAll() and fetchOne() can now throw database errors. 2016-11-26 22:38:40 +01:00
Gwendal Roué af6e31dcdf #147: The fetch method have been removed, along with DatabaseSequence and DatabaseIterator. 2016-11-26 21:14:10 +01:00
Gwendal Roué 6f158e3382 TODO.md 2016-11-26 18:52:25 +01:00
Gwendal Roué 81504bba1e #147: DatabaseCursor.flatMap() 2016-11-26 16:10:39 +01:00
Gwendal Roué 66bedf46a1 #147: DatabaseCursor.enumerated() 2016-11-26 15:19:40 +01:00
Gwendal Roué a196ac03b1 #147: tests for DatabaseCursor.filter, forEach, map, reduce; dropped DatabaseCursor.enumerated since it can't be implemented yet 2016-11-26 14:39:09 +01:00
Gwendal Roué ae1010166a #147: record.exists(_:) can now throw a database error 2016-11-26 11:36:07 +01:00
Gwendal Roué a548212f27 #147: tests for QueryInterfaceRequest.fetchCursor(_:) and (RowConvertible & TableMapping).fetchCursor(_:) 2016-11-26 11:20:35 +01:00
Gwendal Roué 1aeb6d0d9e bugfix 2016-11-26 11:13:36 +01:00
Gwendal Roué 612c963105 TODO 2016-11-26 10:23:41 +01:00
Gwendal Roué 173a60eac6 bugfix 2016-11-26 10:23:36 +01:00
Gwendal Roué 8411efc8ef #147: tests for RowConvertible.fetchCursor(_:keys:) methods 2016-11-26 10:19:56 +01:00
Gwendal Roué af8fe35222 #147: tests for RowConvertible.fetchCursor() methods 2016-11-26 09:52:54 +01:00
Gwendal Roué a0e5f64ddf #147: tests for StatementColumnConvertible.fetchCursor() methods 2016-11-26 09:37:50 +01:00
Gwendal Roué c80f0d317a #147: Array(cursor) initialiser; base all fetchAll and fetchOne methods on fetchCursor. 2016-11-26 09:13:39 +01:00
Gwendal Roué e5a9159282 #147: tests for DatabaseValueConvertible.fetchCursor() methods 2016-11-26 08:46:57 +01:00
Gwendal Roué 8215791051 cleanup 2016-11-26 08:37:53 +01:00
Gwendal Roué ab62abed79 #147: use cursor 2016-11-26 08:29:51 +01:00
Gwendal Roué b31356aada #147: Database.tableExists(_:) and Database.indexes(on:) can now throw database errors 2016-11-26 08:28:32 +01:00
Gwendal Roué b0db219aeb #147: Rename DatabaseCursor.step() into next 2016-11-26 08:20:26 +01:00
Gwendal Roué 20a7c550fe DatabaseCursor.enumerated, filter, forEach, map, reduce are public. Once DatabaseCursor.step() has returned nil, all subsequent calls return nil. (addresses #147) 2016-11-26 07:37:34 +01:00
Gwendal Roué 2eb190dbbb Base DatabaseSequence on DatabaseCursor (addresses #147) 2016-11-26 00:56:37 +01:00
Gwendal Roué d97360ef52 DatabaseCursor.enumerated, filter, forEach, map, reduce (addresses #147) 2016-11-25 19:12:36 +01:00
Gwendal Roué fab64c61c4 Add DatabaseCursor to CHANGELOG, fix FTS5, and some TODO (addresses #147) 2016-11-25 18:43:41 +01:00
Gwendal Roué b9fea2ea12 Introduce DatabaseCursor (addresses #147)
let cursor = try Row.fetchCursor(db, "SELECT * FROM persons)
while let row = try cursor.step() { ... }
2016-11-25 18:34:16 +01:00
Gwendal Roué adc4ae48d6 Test DatabaseSequence<Row>.map 2016-11-25 08:11:26 +01:00
Gwendal Roué e7549a2887 Documentation 2016-11-25 05:47:12 +01:00
Gwendal Roué f28507a366 Merge branch 'master' of github.com:groue/GRDB.swift 2016-11-24 20:02:17 +01:00
Gwendal Roué a1b2c011f5 Performance tests against Realm v2.1.0 and Swift 3.0.1 2016-11-24 19:00:33 +01:00
Gwendal Roué b8ee051f8f TODO.md 2016-11-24 10:18:34 +01:00
Gwendal Roué 06e34c88b5 TODO.md 2016-11-24 10:14:33 +01:00
Gwendal Roué 9866b92405 Documentation 2016-11-23 20:42:33 +01:00
Gwendal Roué d1846217fd Documentation 2016-11-23 20:41:16 +01:00
Gwendal Roué aa82f3637b Documentation 2016-11-23 18:15:55 +01:00
Gwendal Roué 731684f22f Documentation 2016-11-23 18:07:05 +01:00
Gwendal Roué 48b84270c4 Documentation 2016-11-23 18:06:18 +01:00
Gwendal Roué acc4bbf628 Documentation 2016-11-23 17:21:37 +01:00
Gwendal Roué 1718c3bc16 New FAQ entry: Compilation takes a long time 2016-11-23 17:20:18 +01:00
Gwendal Roué 235fa57423 FetchedRecordsController cleanup 2016-11-23 12:48:28 +01:00
Gwendal Roué 90f0ebde1d FetchedRecordsController cleanup 2016-11-23 09:26:09 +01:00
Gwendal Roué e016725814 FetchedRecordsController cleanup 2016-11-23 08:54:02 +01:00
Gwendal Roué 3f449a40ad FetchedRecordsController cleanup 2016-11-23 08:12:58 +01:00
Gwendal Roué e92726bdb3 Documentation 2016-11-23 05:23:44 +01:00
Gwendal Roué 45fe70d8ed Documentation 2016-11-23 04:56:28 +01:00
Gwendal Roué e833e5d86d Documentation 2016-11-23 04:51:53 +01:00
Gwendal Roué 3dff5cb99f Documentation 2016-11-23 04:41:32 +01:00
Gwendal Roué 666d09e296 Documentation 2016-11-23 04:41:03 +01:00
Gwendal Roué 6e1e49a185 Documentation 2016-11-23 04:39:34 +01:00
Gwendal Roué 15c13ece27 Documentation 2016-11-22 19:46:16 +01:00
Gwendal Roué 754efefd32 Documentation 2016-11-22 19:44:26 +01:00
Gwendal Roué f81e69f73c TODO: check https://github.com/wokalski/Diff.swift 2016-11-22 16:05:37 +01:00
Gwendal Roué dd8e73e8f2 Documentation 2016-11-22 08:47:43 +01:00
Gwendal Roué 660520b939 Documentation 2016-11-21 20:35:05 +01:00
Gwendal Roué a1c3096556 Documentation 2016-11-21 09:15:10 +01:00
Gwendal Roué 8cd9dea821 Documentation 2016-11-21 09:13:36 +01:00
Gwendal Roué 0cf64a7dde Documentation 2016-11-21 09:04:28 +01:00
Gwendal Roué 53aff4fbbb Documentation 2016-11-21 09:01:13 +01:00
Gwendal Roué 78789fad1c Documentation 2016-11-21 08:54:07 +01:00
Gwendal Roué 3c54d844b2 Documentation 2016-11-21 08:51:56 +01:00
Gwendal Roué d8e27abff9 Documentation 2016-11-20 19:14:00 +01:00
Gwendal Roué b7b8f9caa6 TODO.md 2016-11-20 17:05:37 +01:00
Gwendal Roué 7e1cd47a4e TODO.md 2016-11-20 17:04:00 +01:00
Gwendal Roué badbd846c2 Documentation 2016-11-20 07:19:00 +01:00
Gwendal Roué e08089ba3e Documentation 2016-11-19 21:22:35 +01:00
Gwendal Roué 27f57ce0b3 Documentation 2016-11-19 17:50:12 +01:00
Gwendal Roué 8aa773df9a Documentation 2016-11-19 17:40:27 +01:00
Gwendal Roué 8fb19d24e8 Documentation 2016-11-19 17:38:20 +01:00
Gwendal Roué fd1376be53 Documentation 2016-11-19 17:35:49 +01:00
Gwendal Roué 051f0fd377 Documentation 2016-11-19 17:03:57 +01:00
Gwendal Roué 954644a001 v0.90.1 2016-11-18 17:36:17 +01:00
Gwendal Roué 19fcbf8f25 Fix availabilities for watchOS 2016-11-18 17:30:14 +01:00
Gwendal Roué c1e2c20ace Documentation 2016-11-18 08:40:39 +01:00
Gwendal Roué 09dbbc17e4 Documentation 2016-11-18 08:38:42 +01:00
Gwendal Roué 4d9db3665f Documentation 2016-11-18 08:34:18 +01:00
Gwendal Roué 625f19ae00 Documentation 2016-11-17 09:14:12 +01:00
Gwendal Roué dcc715d75d Documentation 2016-11-17 08:47:40 +01:00
Gwendal Roué e8717498b5 Documentation 2016-11-17 08:39:07 +01:00
Gwendal Roué ecfbbb39bd Documentation 2016-11-17 08:34:32 +01:00
Gwendal Roué 2cd8f56842 Documentation 2016-11-17 08:28:21 +01:00
Gwendal Roué 588b9737bf Revert "Use sqlite3_trace_v2 when available (but the warning on sqlite3_trace remains)"
This reverts commit 049e9f1a55.
2016-11-15 18:38:46 +01:00
Gwendal Roué 22d540caaa TODO.md 2016-11-15 08:15:19 +01:00
Gwendal Roué 2dead0306a TODO.md 2016-11-11 09:21:32 +01:00
Gwendal Roué b77fa9f627 TODO.md 2016-11-11 09:09:15 +01:00
Gwendal Roué 6a29eecf8d TODO.md 2016-11-11 09:04:17 +01:00
Gwendal Roué 049e9f1a55 Use sqlite3_trace_v2 when available (but the warning on sqlite3_trace remains) 2016-11-10 09:11:02 +01:00
Gwendal Roué dcb995c626 Fix compiler warning 2016-11-10 08:32:23 +01:00
Gwendal Roué 6200f5fb62 Fix Xcode 8.1 warning 2016-11-10 06:55:24 +01:00
Gwendal Roué cc27c19c66 FIXME: sqlite3_rekey is discouraged. 2016-11-08 19:37:28 +01:00
Gwendal Roué 23dc818eac Documentation 2016-11-06 12:48:05 +01:00
Gwendal Roué 311d40a9f1 Test that FetchedRecordsController.sections.count is 1 when there are no fetched records 2016-11-06 12:39:42 +01:00
Gwendal Roué ad4d2831c9 Improve FetchedRecordsController misuse feedback 2016-11-06 12:37:28 +01:00
Gwendal Roué ee9c959262 TODO.md 2016-11-06 11:24:25 +01:00
Gwendal Roué b739603a3c v0.90.0 2016-11-05 15:41:42 +01:00
Gwendal Roué 153701133d Documentation 2016-11-05 15:27:11 +01:00
Gwendal Roué d8704edc7f TODO.md 2016-11-05 15:01:20 +01:00
Gwendal Roué 57f6b2d122 availability cleanup 2016-11-05 14:40:14 +01:00
Gwendal Roué 21c41fb145 availability cleanup 2016-11-05 14:37:36 +01:00
Gwendal Roué 12d35a39c7 TODO.md 2016-11-05 14:13:25 +01:00
Gwendal Roué 11aa9f7b79 Upgrade SQLite to v3.15.1 2016-11-05 14:05:23 +01:00
Gwendal Roué 23ae3ad8ad CHANGELOG.md 2016-11-05 13:56:08 +01:00
Gwendal Roué 84d468ad2f TODO.md 2016-11-05 13:55:58 +01:00
Gwendal Roué 0459612632 Documentation 2016-11-03 06:38:32 +01:00
Gwendal Roué 7dfa4bcdb5 FetchedRecordsController: restore default record comparator 2016-10-29 10:49:32 +02:00
Gwendal Roué a3e73508f4 CHANGELOG.md 2016-10-29 07:34:10 +02:00
Gwendal Roué df120ec4a3 FetchedRecordsController: default record comparator now compares rows 2016-10-29 07:25:56 +02:00
Gwendal Roué 6dfa6a3710 FetchedRecordsController.isSameRecord is an iOS-only tool 2016-10-28 19:42:02 +02:00
Gwendal Roué 7ae39a00cb Naming things is hard 2016-10-28 19:22:52 +02:00
Gwendal Roué 0cbcbe3e69 Documentation 2016-10-28 08:11:28 +02:00
Gwendal Roué 47debc0223 Documentation 2016-10-27 09:05:38 +02:00
Gwendal Roué 5953f08495 v0.89.2 2016-10-26 08:35:58 +02:00
Gwendal Roué 43276582ed Typo 2016-10-21 19:58:42 +02:00
Gwendal Roué 2c3d7871ff Merge branch 'master' of github.com:groue/GRDB.swift 2016-10-21 09:56:07 +02:00
Gwendal Roué 112f10a16d Performance tests: Record initializer from FMDB resultsDictionary does not have to use NSNumber 2016-10-21 09:56:03 +02:00
Gwendal Roué 28beefcbb8 Documentation 2016-10-21 09:22:47 +02:00
Gwendal Roué edcff1068b CHANGELOG.md 2016-10-21 09:20:15 +02:00
Gwendal Roué 266f23d1e6 Update tests for CountableRange.contains(), add tests for 0.negated 2016-10-21 09:14:54 +02:00
Gwendal Roué c4dfd24782 CountableRange.contains(): turn 0..<10.contains(x) to "x >= 0 AND x < 10" instead of "x BETWEEN 0 AND 9" (and avoid Int ranges to mess with double values) 2016-10-21 09:14:19 +02:00
Gwendal Roué 9ae2de6dc1 DatabaseValue.negated: prefer 1 to NOT 0 2016-10-21 09:13:03 +02:00
Gwendal Roué 45fd6f89c0 Performance tests: fix warnings 2016-10-21 08:47:06 +02:00
Gwendal Roué b1ba4b505a Documentation 2016-10-20 19:17:47 +02:00
Gwendal Roué 99e6cf4796 Documentation 2016-10-20 19:14:00 +02:00
Gwendal Roué 4df5752df7 Documentation 2016-10-20 18:08:53 +02:00
Gwendal Roué 7a2837b6c9 Performance tests: Swift 3 2016-10-20 18:08:43 +02:00
Gwendal Roué dc08805307 Performance tests: SQLite.swift 0.11.0 2016-10-20 18:07:39 +02:00
Gwendal Roué 2ffebb9c0b Performance tests: Realm v2.0.2 2016-10-20 18:01:13 +02:00
Gwendal Roué 2553a51408 Documentation 2016-10-20 09:44:27 +02:00
Gwendal Roué e2a338c3c9 Documentation 2016-10-20 09:40:25 +02:00
Gwendal Roué 795f4cd7a7 Documentation 2016-10-20 09:11:42 +02:00
Gwendal Roué 932fa22701 Documentation 2016-10-20 09:11:16 +02:00
Gwendal Roué 5c746ad3d4 Documentation 2016-10-20 09:09:36 +02:00
Gwendal Roué d0c8a80e5e Documentation 2016-10-20 09:07:16 +02:00
Gwendal Roué da40f7ab07 CocoaPods is no longer beta 2016-10-20 08:53:01 +02:00
Gwendal Roué f4c42a5d39 Fix links to cocoadocs.org 2016-10-20 08:23:35 +02:00
Gwendal Roué 7b3a752ad9 Documentation 2016-10-19 19:54:59 +02:00
Gwendal Roué ad861e7da1 Documentation 2016-10-19 19:51:48 +02:00
Gwendal Roué 17e8cf8aaa Documentation 2016-10-19 19:45:18 +02:00
Gwendal Roué 6773f1e152 v0.89.1 2016-10-19 19:37:36 +02:00
Gwendal Roué 928b95861d Explicit SQLCipher version 2016-10-19 19:36:34 +02:00
Gwendal Roué f274abcc8d Bold 2016-10-19 19:31:21 +02:00
Gwendal Roué 5a725af1bb Link to https://www.sqlite.org/changes.html 2016-10-19 19:30:42 +02:00
Gwendal Roué b0d5c8870a Documentation/CustomSQLiteBuilds.md replaces SQLiteCustom/README.md 2016-10-19 19:29:41 +02:00
Gwendal Roué fb14a49dd5 Link to custom FTS5 tokenizers from GRDB Extension Guide 2016-10-19 08:03:38 +02:00
Gwendal Roué b6d2ec3bea TODO.md 2016-10-18 09:05:32 +02:00
Gwendal Roué 3fd5b77de8 README.md 2016-10-18 08:59:17 +02:00
Gwendal Roué b060039a28 README.md 2016-10-18 08:55:45 +02:00
Gwendal Roué ba84e8bc33 TODO.md 2016-10-18 08:13:39 +02:00
Gwendal Roué cba111c055 TODO.md 2016-10-18 08:05:01 +02:00
Gwendal Roué a1f4c3506d Typo 2016-10-18 06:25:40 +02:00
Gwendal Roué a4e0abf7bc Typo 2016-10-18 06:14:19 +02:00
Gwendal Roué 7058bb5e12 Have DatabaseError adopt CustomNSError 2016-10-18 05:49:12 +02:00
Gwendal Roué 43d4d3cddc CHANGELOG.md 2016-10-17 20:44:16 +02:00
Gwendal Roué c4804f427f CHANGELOG.md 2016-10-17 20:40:31 +02:00
Gwendal Roué 430ef5d1a6 Hide FetchedRecordsControlleriOSTests behind #if os(iOS) 2016-10-17 20:27:24 +02:00
Gwendal Roué d8fb4304b7 CHANGELOG.md 2016-10-17 20:23:03 +02:00
Gwendal Roué caf5ee7412 Fix the compareRecordsByPrimaryKey option of FetchedRecordsController when record has no primary key but has selectsRowID set to true 2016-10-17 20:17:37 +02:00
Gwendal Roué 2acfbcdce6 Failing test for compareRecordsByPrimaryKey option of FetchedRecordsController when record has no primary key 2016-10-17 20:16:31 +02:00
Gwendal Roué c687c5df24 CHANGELOG.md 2016-10-17 19:27:05 +02:00
Gwendal Roué f63db81268 Merge branch 'master' of github.com:groue/GRDB.swift
Conflicts:
	TODO.md
2016-10-17 19:23:54 +02:00
Gwendal Roué 00de9bbbc5 Database.create(virtualTable:using:) wraps the table creation and virtual module post actions in a save point. Fix failing test for virtual module that throws in its database(_:didCreate:using:) method. 2016-10-17 19:23:11 +02:00
Gwendal Roué 825db1158c Add failing test for virtual table module that throws in its database(_:didCreate:using:) 2016-10-17 19:21:57 +02:00
Gwendal Roué b5bff64cf0 TODO.md 2016-10-17 16:55:45 +02:00
Gwendal Roué c5255872ca Documentation 2016-10-17 15:59:11 +02:00
Gwendal Roué 9920f44a90 TODO.md 2016-10-17 14:04:32 +02:00
Gwendal Roué f5bbc43c87 Add a test for FetchedRecordsController request modification with uppercase table and column names 2016-10-17 14:00:32 +02:00
Gwendal Roué 7076809b71 v0.89.0 2016-10-17 13:41:57 +02:00
Gwendal Roué 34b7cda2ec Fix failing test for FetchedRecordsController: when the request changes, we now do update the tracked tables and columns 2016-10-17 13:34:46 +02:00
Gwendal Roué f2cd90a999 Failing test for FetchedRecordsController: when the request changes, we do not update the tracked tables and columns 2016-10-17 13:16:15 +02:00
Gwendal Roué 2c35c63a09 Typo 2016-10-17 12:00:06 +02:00
Gwendal Roué 7832a6eb6f Documentation 2016-10-17 11:59:46 +02:00
Gwendal Roué e1c3dda6e0 Documentation 2016-10-17 11:52:44 +02:00
Gwendal Roué f11c015522 Documentation 2016-10-17 10:24:13 +02:00
Gwendal Roué 9cd23bc02b Documentation 2016-10-17 10:22:00 +02:00
Gwendal Roué 8c0ab4285b Documentation 2016-10-17 10:17:48 +02:00
Gwendal Roué 3cbc5aaf2d Documentation 2016-10-17 09:13:24 +02:00
Gwendal Roué c43aae15ff Typo 2016-10-17 09:11:00 +02:00
Gwendal Roué 2fd3ded6e2 TableMapping.none() 2016-10-17 09:09:17 +02:00
Gwendal Roué cb6d727664 Column.rank 2016-10-17 08:12:30 +02:00
Gwendal Roué 3be2047c9c Documentation 2016-10-16 16:48:39 +02:00
Gwendal Roué b3ec9a0900 Documentation 2016-10-16 16:16:31 +02:00
Gwendal Roué 50cf830404 Documentation 2016-10-16 16:09:24 +02:00
Gwendal Roué 72e58a7f0d Documentation 2016-10-16 16:02:20 +02:00
Gwendal Roué 36781c0bc6 Documentation 2016-10-16 15:58:18 +02:00
Gwendal Roué 12ca7d0fe2 Documentation 2016-10-16 15:57:45 +02:00
Gwendal Roué b85066eb06 Documentation 2016-10-16 15:56:37 +02:00
Gwendal Roué 456705de54 Documentation 2016-10-16 15:55:37 +02:00
Gwendal Roué 31b500cc7f Documentation 2016-10-16 15:50:37 +02:00
Gwendal Roué 03d0011c2f Documentation 2016-10-16 15:39:34 +02:00
Gwendal Roué 101088cadc Link to https://github.com/groue/WWDCCompanion 2016-10-16 11:27:57 +02:00
Gwendal Roué 638702728c CHANGELOG.md 2016-10-16 11:05:29 +02:00
Gwendal Roué 015a0888d4 v0.88.0 2016-10-16 11:00:18 +02:00
Gwendal Roué 361eaeca07 Upgrade SQLiteCustom to v3.15.0 2016-10-16 10:59:28 +02:00
Gwendal Roué 6850c2a9ee External Content Full-Text Tables documentation 2016-10-16 10:21:17 +02:00
Gwendal Roué 12af387e50 FTS4: support for external content table synchronization 2016-10-16 09:52:58 +02:00
Gwendal Roué 55216be46b FTS5: support for external content table synchronization 2016-10-16 09:32:41 +02:00
Gwendal Roué 7630642c56 matching() and match() methods accept nil FTS patterns 2016-10-16 07:47:25 +02:00
Gwendal Roué ad8fe7923a TODO.md 2016-10-15 18:15:51 +02:00
Gwendal Roué f06b4f70f9 CHANGELOG.md: fix link 2016-10-14 09:09:50 +02:00
Gwendal Roué 408ecda944 Add contentRowID to FTS5TableDefinition 2016-10-14 08:58:58 +02:00
Gwendal Roué 95844cd6c0 Validate FTS patterns with db.execute() instead of a fetch sequence since it achieves error detection with less code 2016-10-14 05:05:01 +02:00
Gwendal Roué cf4824e588 Documentation 2016-10-13 08:08:17 +02:00
Gwendal Roué c99aaf763d Documentation 2016-10-13 08:07:03 +02:00
Gwendal Roué 1156027587 Documentation 2016-10-13 07:59:12 +02:00
Gwendal Roué 46c6d43556 Documentation 2016-10-12 17:23:14 +02:00
Gwendal Roué 07fccd0479 Documentation 2016-10-12 17:20:33 +02:00
Gwendal Roué 10e4fe7a71 Documentation 2016-10-12 17:16:53 +02:00
Gwendal Roué 5f37891eae Documentation 2016-10-12 17:15:16 +02:00
Gwendal Roué f09644be00 Documentation 2016-10-12 17:08:52 +02:00
Gwendal Roué 96e573b356 Documentation 2016-10-12 14:58:13 +02:00
Gwendal Roué bed63b55fe Documentation 2016-10-12 09:10:57 +02:00
Gwendal Roué 0a8ac5cb05 v0.87.0 2016-10-12 08:48:19 +02:00
Gwendal Roué 590d7cc79b Documentation 2016-10-12 08:41:26 +02:00
Gwendal Roué aeeaa18b28 Documentation 2016-10-12 08:38:42 +02:00
Gwendal Roué d6a6f1ed51 Documentation 2016-10-12 08:37:53 +02:00
Gwendal Roué 68bf5d5105 Documentation 2016-10-12 08:36:55 +02:00
Gwendal Roué 78d5f6f598 Documentation 2016-10-12 08:36:04 +02:00
Gwendal Roué fa8c6dfa6f Documentation 2016-10-12 08:34:49 +02:00
Gwendal Roué 15d3bc70d2 Documentation 2016-10-12 08:19:51 +02:00
Gwendal Roué c37b52645c Documentation 2016-10-12 08:17:39 +02:00
Gwendal Roué e6f61699d7 Documentation 2016-10-12 08:15:59 +02:00
Gwendal Roué 6cdf61d6cf Documentation 2016-10-12 08:15:10 +02:00
Gwendal Roué 60dee64fa0 Documentation 2016-10-12 08:12:56 +02:00
Gwendal Roué 21f4ba4f3a Documentation 2016-10-12 08:12:03 +02:00
Gwendal Roué df4777dca4 Documentation 2016-10-12 08:11:39 +02:00
Gwendal Roué 03b8e98cb2 Documentation 2016-10-12 08:07:57 +02:00
Gwendal Roué fafe2374b7 Documentation 2016-10-12 08:03:26 +02:00
Gwendal Roué 1840fac000 Documentation 2016-10-12 08:01:05 +02:00
Gwendal Roué ec460ff07a Documentation 2016-10-12 08:00:32 +02:00
Gwendal Roué b0e68366d4 Documentation 2016-10-12 07:58:19 +02:00
Gwendal Roué 99266e4ea9 Documentation 2016-10-12 07:55:52 +02:00
Gwendal Roué 34025599a0 Documentation 2016-10-12 07:46:33 +02:00
Gwendal Roué 21f34b8039 Documentation 2016-10-12 07:45:09 +02:00
Gwendal Roué 30b3a4c9c7 Documentation 2016-10-12 07:41:18 +02:00
Gwendal Roué 7ca2f7d6b1 Documentation 2016-10-12 07:37:37 +02:00
Gwendal Roué 7a6ac1f6d0 Documentation 2016-10-12 06:56:56 +02:00
Gwendal Roué e53f0a3191 Documentation 2016-10-12 06:55:47 +02:00
Gwendal Roué 54b28ae356 Documentation 2016-10-11 22:36:37 +02:00
Gwendal Roué 22b7181c40 Documentation 2016-10-11 22:01:45 +02:00
Gwendal Roué daf6a856c7 Documentation 2016-10-11 22:00:37 +02:00
Gwendal Roué 4e2baa0868 Documentation 2016-10-11 21:48:55 +02:00
Gwendal Roué 6b48084c9c Documentation 2016-10-11 21:27:46 +02:00
Gwendal Roué 1e48959c0a Documentation 2016-10-11 21:04:37 +02:00
Gwendal Roué 088c37d1ea Documentation 2016-10-11 20:51:32 +02:00
Gwendal Roué 18dcc21340 Documentation 2016-10-11 14:43:53 +02:00
Gwendal Roué e03c1d4c85 Documentation 2016-10-11 14:42:45 +02:00
Gwendal Roué 9fb85f252e Documentation 2016-10-11 14:41:15 +02:00
Gwendal Roué c7601c9921 Documentation 2016-10-11 14:41:04 +02:00
Gwendal Roué eab2bd3565 Documentation 2016-10-11 14:38:50 +02:00
Gwendal Roué 4454c6be73 FTS5Tokenizer.tokenize callback is not optional 2016-10-11 11:28:22 +02:00
Gwendal Roué 0adf8a0a05 Documentation 2016-10-11 10:47:33 +02:00
Gwendal Roué bdf59c1a5f Documentation 2016-10-11 10:27:50 +02:00
Gwendal Roué e317926fcb Documentation 2016-10-11 10:26:50 +02:00
Gwendal Roué 1487a0ecd2 Documentation 2016-10-11 09:23:57 +02:00
Gwendal Roué 950d2689c7 Documentation 2016-10-11 09:22:00 +02:00
Gwendal Roué 8687ed6697 Documentation 2016-10-11 09:19:15 +02:00
Gwendal Roué ab9c0dab04 Documentation 2016-10-11 09:05:39 +02:00
Gwendal Roué 45e2819694 Documentation 2016-10-11 09:04:53 +02:00
Gwendal Roué 0187a0cace Documentation 2016-10-11 09:04:11 +02:00
Gwendal Roué 9d714ba9e0 Documentation 2016-10-11 09:01:20 +02:00
Gwendal Roué a614434c04 Documentation 2016-10-11 09:00:33 +02:00
Gwendal Roué 0fbfee521f Documentation 2016-10-11 08:59:15 +02:00
Gwendal Roué d2233acc44 Documentation 2016-10-11 08:57:04 +02:00
Gwendal Roué 4b86741683 Documentation 2016-10-11 08:56:37 +02:00
Gwendal Roué 26bf91e1da Documentation 2016-10-11 08:52:03 +02:00
Gwendal Roué 37eab31b40 Documentation 2016-10-11 08:06:03 +02:00
Gwendal Roué 39aa548586 Documentation 2016-10-11 07:59:50 +02:00
Gwendal Roué a228b36e8e Documentation 2016-10-11 07:57:46 +02:00
Gwendal Roué 7d33a1572e Documentation 2016-10-11 07:54:40 +02:00
Gwendal Roué 5ccbf0042c Documentation 2016-10-11 07:54:13 +02:00
Gwendal Roué 0313ea636a Documentation 2016-10-11 07:53:30 +02:00
Gwendal Roué d7a5db3dbb Documentation 2016-10-11 07:52:52 +02:00
Gwendal Roué 82435bf6ff Documentation 2016-10-11 06:56:04 +02:00
Gwendal Roué e56a4ed9e2 Documentation 2016-10-11 06:55:31 +02:00
Gwendal Roué 52ef16dba5 Documentation 2016-10-11 06:21:46 +02:00
Gwendal Roué e4713edd75 Documentation 2016-10-11 05:19:37 +02:00
Gwendal Roué 5abe72f7e7 Documentation 2016-10-11 05:06:28 +02:00
Gwendal Roué fdeb07f82b Documentation 2016-10-11 05:05:25 +02:00
Gwendal Roué 44b59eea58 Documentation 2016-10-10 20:54:35 +02:00
Gwendal Roué f8bf2f38d3 Documentation 2016-10-10 20:41:40 +02:00
Gwendal Roué 091854a6d0 Documentation 2016-10-10 20:30:05 +02:00
Gwendal Roué fd55aa61cf Documentation 2016-10-10 20:28:04 +02:00
Gwendal Roué 7bd014f9de Documentation 2016-10-10 20:17:02 +02:00
Gwendal Roué 793ef35c95 Documentation 2016-10-10 20:16:15 +02:00
Gwendal Roué d8eb8499ef Documentation 2016-10-10 20:14:53 +02:00
Gwendal Roué ad98339de7 Documentation 2016-10-10 19:53:06 +02:00
Gwendal Roué d121326382 Documentation 2016-10-10 19:06:17 +02:00
Gwendal Roué bd9e689885 Documentation 2016-10-10 19:05:36 +02:00
Gwendal Roué 79dcf6d63b Code cleanup 2016-10-10 18:54:25 +02:00
Gwendal Roué 3390a26588 Rename FTSXTokenizerRequest to FTSXTokenizerDescriptor 2016-10-10 18:33:32 +02:00
Gwendal Roué 93d1cd3ee7 Remove the FTS3TokenizerRequest public initializer 2016-10-10 18:31:56 +02:00
Gwendal Roué 4b3cfc5de1 FTS3 is not ready for Database.tokenize(string:with:). Only FTS5 is. 2016-10-10 18:17:39 +02:00
Gwendal Roué f9d38fdd69 Database.tokenize(string:with:) 2016-10-10 18:15:14 +02:00
Gwendal Roué 628c375b8c Documentation 2016-10-10 15:31:05 +02:00
Gwendal Roué 714c884732 Code cleanup 2016-10-10 14:43:23 +02:00
Gwendal Roué f6dffe9845 Rename FTSXTokenizerDefinition to FTSXTokenizerRequest 2016-10-10 13:58:05 +02:00
Gwendal Roué a28b3cc268 FTS5.api robustness 2016-10-10 13:51:58 +02:00
Gwendal Roué 388dd99986 Custom FTS5 tokenizer cleanup 2016-10-10 13:46:04 +02:00
Gwendal Roué 1081b6a1c0 Custom FTS5 tokenizer cleanup 2016-10-10 13:11:11 +02:00
Gwendal Roué 80d93b1fc9 FTS5WrapperTokenizer 2016-10-10 11:36:03 +02:00
Gwendal Roué 3980fe5de1 CHANGELOG.md 2016-10-10 08:51:17 +02:00
Gwendal Roué b374b1ef7a Typo 2016-10-10 08:49:47 +02:00
Gwendal Roué 09a7865e7d Test the custom FTS5 tokenizer with a synonyms tokenizer 2016-10-10 08:46:56 +02:00
Gwendal Roué 2f9a399d18 Fix NFKC tokenizer so that it does not mangle token offsets inside pText (convert tokens to NFKC, not the base string) 2016-10-10 08:16:27 +02:00
Gwendal Roué bbda3955c3 Test the custom FTS5 tokenizer with a NFKC tokenizer 2016-10-09 23:41:25 +02:00
Gwendal Roué ba42932024 Test the custom FTS5 tokenizer with a "stop words" tokenizer 2016-10-09 23:09:22 +02:00
Gwendal Roué f7c8bd6d1c FTS5TokenizeFlags 2016-10-09 22:15:11 +02:00
Gwendal Roué 35479575ec Tests for custom FTS5 tokenizer with DatabaseQueue and DatabasePool 2016-10-09 21:52:22 +02:00
Gwendal Roué 23a4aab3c4 Custom FTS5 tokenizer experiments 2016-10-09 21:35:07 +02:00
Gwendal Roué ec5bd18b67 Custom FTS5 tokenizer experiments 2016-10-09 19:01:51 +02:00
Gwendal Roué d5750bf329 Documentation 2016-10-09 07:20:45 +02:00
Gwendal Roué ac55d35b13 Custom SQLite examples 2016-10-08 19:34:24 +02:00
Gwendal Roué a1c27049d6 CHANGELOG.md 2016-10-08 19:14:46 +02:00
Gwendal Roué 8b36b29126 v0.86.0 2016-10-08 19:09:46 +02:00
Gwendal Roué c0e75ac6b4 Update the GRDB Extension Guide so that it stops talking about the MATCH operator - use GLOB instead. 2016-10-08 19:09:40 +02:00
Gwendal Roué 897f3a86c5 More FTS tests 2016-10-08 17:31:59 +02:00
Gwendal Roué 58025d3b01 Remove unused code 2016-10-08 16:59:29 +02:00
Gwendal Roué 591197422d Prefer flatMap to guard when chaining values 2016-10-08 16:56:39 +02:00
Gwendal Roué 027b1f711c URL, UUID and Date now adopt DatabaseValueConvertible through NSURL, NSUUID and NSDate, thanks to the new support for Foundation's ReferenceConvertible. 2016-10-08 16:54:32 +02:00
Gwendal Roué 5f15a0f555 Improve test coverage 2016-10-08 16:30:08 +02:00
Gwendal Roué c46238301a Improve test coverage 2016-10-08 16:04:30 +02:00
Gwendal Roué 7c282d28df Improve test coverage 2016-10-08 15:44:11 +02:00
Gwendal Roué 587251e73c TODO 2016-10-08 15:44:00 +02:00
Gwendal Roué 12dbafd0c9 Improve test coverage 2016-10-08 14:56:17 +02:00
Gwendal Roué 3c822399b1 Restore DatabaseValue.description into its previous behavior, and test that \n or \t are described as "\\n" and "\\t" (avoid multi-line DatabaseValue description) 2016-10-08 14:38:30 +02:00
Gwendal Roué ae7252fbec Code cleanup 2016-10-08 14:37:14 +02:00
Gwendal Roué 13dfde1862 Upgrade SQLiteCustom to v3.14.2 2016-10-08 14:18:10 +02:00
Gwendal Roué 3a0aef3779 README.md 2016-10-08 14:03:29 +02:00
Gwendal Roué a82cc8cbd4 Update playgrounds 2016-10-08 14:03:08 +02:00
Gwendal Roué 6e6701a644 CHANGELOG.md 2016-10-08 13:46:21 +02:00
Gwendal Roué b6b74e292f Cleanup 2016-10-08 13:40:16 +02:00
Gwendal Roué db0dfdcd59 VirtualTableModule cleanup and documentation 2016-10-08 13:36:27 +02:00
Gwendal Roué fc49643860 Remove QueryInterfaceRequest public initializer 2016-10-08 13:06:46 +02:00
Gwendal Roué 7968c1dcd2 Fix warnings 2016-10-08 12:59:34 +02:00
Gwendal Roué b9180798ca Tests for delete(db) return value 2016-10-08 12:53:35 +02:00
Gwendal Roué 8ed0888ea8 Documentation 2016-10-08 12:46:15 +02:00
Gwendal Roué e5d941f98b Documentation 2016-10-08 12:43:38 +02:00
Gwendal Roué 62f434f0e0 Documentation 2016-10-08 12:22:03 +02:00
Gwendal Roué 829451486e Documentation 2016-10-08 12:18:48 +02:00
Gwendal Roué 0da1a293e6 Update tests for error descriptions that include argument literals, since DatabaseValue.description now returns the SQL literal representation of the value 2016-10-08 12:17:49 +02:00
Gwendal Roué a51ccad560 Code cleanup 2016-10-08 11:52:46 +02:00
Gwendal Roué b8ab30fc22 DatabaseValue.description now returns the SQL literal representation of the value 2016-10-08 11:51:10 +02:00
Gwendal Roué 915bc6c7cd Less TODO 2016-10-08 11:36:22 +02:00
Gwendal Roué 0bc55a5185 FTS5Pattern and FTS4Tokenizer require SQLITE_ENABLE_FTS5 2016-10-08 10:24:50 +02:00
Gwendal Roué 07c2973459 Full text and records 2016-10-08 10:03:19 +02:00
Gwendal Roué 2bc8722049 Document that fetchOne(_🔑), fetch(_:keys:), fetchAll(_:keys:), deleteOne(_🔑), and deleteAll(_:keys:) assume a rowID primary key when table has no explicit primary key. 2016-10-08 09:57:15 +02:00
Gwendal Roué 84259fd9d8 TableMapping.selectsRowID documentation 2016-10-08 09:49:42 +02:00
Gwendal Roué 31474b581b TableMapping.selectsRowID documentation 2016-10-08 09:33:35 +02:00
Gwendal Roué 2fc71c762a TODO.md 2016-10-08 08:39:42 +02:00
Gwendal Roué a541e6db1f deleteOne(_🔑) and deleteAll(_:keys:) with implicit rowID key 2016-10-08 08:36:56 +02:00
Gwendal Roué a4aab9f4c2 TableMapping.selectsRowID test 2016-10-08 08:33:19 +02:00
Gwendal Roué 2d6abc088f TableMapping.selectsRowID + passing tests for FTS3Record 2016-10-07 19:17:40 +02:00
Gwendal Roué a1f3d42fd0 Failing tests from FTS3Record 2016-10-07 17:47:56 +02:00
Gwendal Roué 915e72584c fetchOne(_🔑), fetch(_:keys:), fetchAll(_:keys:), deleteOne(_🔑), and deleteAll(_:keys:) now assumes a rowID primary key when table has no explicit primary key. 2016-10-07 17:47:29 +02:00
Gwendal Roué 22ef3c8b2a Persistable DAO assumes "rowid" as a default primary key, so that a record that exposes "rowid" in its persistentDictionary can be updated, and deleted. 2016-10-07 17:44:38 +02:00
Gwendal Roué 0936793b23 TODO 2016-10-07 17:35:07 +02:00
Gwendal Roué 8bbdf56cb0 Documentation 2016-10-07 15:16:04 +02:00
Gwendal Roué 25fd939bc6 FTS documentation 2016-10-07 15:10:25 +02:00
Gwendal Roué 5e4f31fe84 Unicode gotchas 2016-10-07 15:08:43 +02:00
Gwendal Roué 5638b4f889 Unicode gotchas 2016-10-07 15:06:02 +02:00
Gwendal Roué 2f28a7f3f2 FTS documentation 2016-10-07 14:52:34 +02:00
Gwendal Roué 9f3137e509 FTS cleanup 2016-10-07 14:48:34 +02:00
Gwendal Roué 32c91f56f3 FTS documentation 2016-10-07 14:42:56 +02:00
Gwendal Roué c81284754f FTS documentation 2016-10-07 14:34:12 +02:00
Gwendal Roué e300546a32 FTS4 and FTS5 options 2016-10-07 14:21:29 +02:00
Gwendal Roué ce0f62d598 FTS documentation 2016-10-07 11:03:21 +02:00
Gwendal Roué 18e1987a6a FTS documentation 2016-10-07 10:59:32 +02:00
Gwendal Roué 626c12c8a3 FTS documentation 2016-10-07 10:50:28 +02:00
Gwendal Roué 8e8fb9cfe8 FTS documentation 2016-10-07 10:48:25 +02:00
Gwendal Roué c0c3f2c9ba FTS documentation 2016-10-07 10:26:33 +02:00
Gwendal Roué 7e4846b83c FTS documentation 2016-10-07 10:13:00 +02:00
Gwendal Roué adcd0e2936 FTS documentation 2016-10-07 10:10:12 +02:00
Gwendal Roué 2a02a2e40b FTS documentation 2016-10-07 10:07:21 +02:00
Gwendal Roué 8b8953b98c FTS documentation 2016-10-07 09:22:10 +02:00
Gwendal Roué 05baa544bc Typo 2016-10-07 09:21:15 +02:00
Gwendal Roué 95aee6eb37 Typo 2016-10-07 09:15:47 +02:00
Gwendal Roué d348c0e794 FTS documentation 2016-10-07 09:15:22 +02:00
Gwendal Roué bdc25e4fb5 Query interface matching() method 2016-10-07 08:59:39 +02:00
Gwendal Roué f864fba78b FTS documentation 2016-10-07 08:36:29 +02:00
Gwendal Roué ec34261674 FTS documentation 2016-10-07 08:35:43 +02:00
Gwendal Roué 119965a7fb FTS documentation 2016-10-07 08:34:00 +02:00
Gwendal Roué 24c672ddc9 Validation of raw FTS5 patterns requires a database connection and a table name 2016-10-07 08:32:23 +02:00
Gwendal Roué 56578c7c0c CURRENT_TIMESTAMP, not NOW 2016-10-07 06:50:57 +02:00
Gwendal Roué fdc78b5c32 Typo 2016-10-07 06:37:22 +02:00
Gwendal Roué 3585223827 Typo 2016-10-07 06:35:21 +02:00
Gwendal Roué 13bdb881c7 FTS column queries 2016-10-07 06:17:54 +02:00
Gwendal Roué 12c46c794f Remove dead code 2016-10-07 06:17:26 +02:00
Gwendal Roué 3b839ebd1f FTS documentation 2016-10-06 19:19:39 +02:00
Gwendal Roué 04d5c98756 FTS documentation 2016-10-06 16:00:42 +02:00
Gwendal Roué 2cce4bf2a8 FTS documentation 2016-10-06 15:57:32 +02:00
Gwendal Roué 15560229ce FTS documentation 2016-10-06 15:55:18 +02:00
Gwendal Roué 20317e5830 FTS5 documentation 2016-10-06 15:44:50 +02:00
Gwendal Roué 2bf1de5a43 FTS5 documentation 2016-10-06 15:42:55 +02:00
Gwendal Roué 7306ce09b4 FTS5 documentation 2016-10-06 15:38:40 +02:00
Gwendal Roué 846bcf3ef5 FTS5 documentation 2016-10-06 15:26:01 +02:00
Gwendal Roué 69b69da52a FTS5 documentation 2016-10-06 14:09:10 +02:00
Gwendal Roué 7a7be6e454 FTS documentation 2016-10-06 14:07:54 +02:00
Gwendal Roué 3587e450a3 FTS5 documentation 2016-10-06 14:06:15 +02:00
Gwendal Roué 0b8001eac2 FTS5 documentation 2016-10-06 14:05:04 +02:00
Gwendal Roué 8235c6d4fc FTS5 documentation 2016-10-06 14:03:42 +02:00
Gwendal Roué aed88bd857 FTS documentation 2016-10-06 13:38:18 +02:00
Gwendal Roué 8fcca219b4 FTS documentation 2016-10-06 13:11:11 +02:00
Gwendal Roué 4b16ed6bdd FTS documentation 2016-10-06 12:56:43 +02:00
Gwendal Roué 3ad7901edb FTS documentation 2016-10-06 12:55:10 +02:00
Gwendal Roué a684823f25 FTS documentation 2016-10-06 12:52:50 +02:00
Gwendal Roué 90a03c5096 FTS documentation 2016-10-06 12:42:08 +02:00
Gwendal Roué 46f8f3c27e FTS documentation 2016-10-06 09:16:19 +02:00
Gwendal Roué 3569a85488 FTS TODO 2016-10-06 09:08:22 +02:00
Gwendal Roué 9a0942e9b2 Split FTS tokenizer tests from table builder tests 2016-10-06 08:52:51 +02:00
Gwendal Roué 26725bd878 FTS5 table builder tests 2016-10-06 08:35:35 +02:00
Gwendal Roué ae01148b76 FTS5 patterns tests 2016-10-06 08:35:15 +02:00
Gwendal Roué 1269959265 FTS3 tokenizer tests: stop testing NFC/NFD 2016-10-06 08:31:31 +02:00
Gwendal Roué a471d68d6c FTS3 tokenizer tests: stop testing NFC/NFD 2016-10-06 08:31:20 +02:00
Gwendal Roué 2eb8859080 FTS3PatternTests: stop testing NFC/NFD, and stop testing document prefix queries, which seem fragile according to SQLite version (some tests fail with custom SQLite 3.14.1) 2016-10-06 08:30:56 +02:00
Gwendal Roué 038fe07fd4 TS5Tokenizer.porter(wrapping:) 2016-10-06 08:28:40 +02:00
Gwendal Roué 578b899653 FTS5 virtual table require at least one column 2016-10-06 08:28:05 +02:00
Gwendal Roué 32e0151f7d Correct implementation for FTS5Pattern(rawPattern:) 2016-10-06 08:27:50 +02:00
Gwendal Roué 43cf02d5b8 FTS3Pattern(matchingAllTokensIn:) does not insert useless AND operator 2016-10-06 08:27:22 +02:00
Gwendal Roué d60a1193b2 Reminder about NFKC NFKD tests 2016-10-05 18:09:50 +02:00
Gwendal Roué 806e0b6d7f FTS Documentation 2016-10-05 18:09:35 +02:00
Gwendal Roué 74434e87c5 Introduce FTS5 2016-10-05 14:14:14 +02:00
Gwendal Roué 41935d8b48 Code cleanup 2016-10-05 14:13:57 +02:00
Gwendal Roué 8a93c7472f FTS3Tokenizer.tokenize(string) 2016-10-05 13:04:53 +02:00
Gwendal Roué 687737f71a FTS3Pattern: remove ability to specify tokenizer 2016-10-05 09:23:03 +02:00
Gwendal Roué c4296f0127 FTS documentation 2016-10-05 09:13:25 +02:00
Gwendal Roué 933e8d4409 FTS documentation 2016-10-05 08:53:24 +02:00
Gwendal Roué 28950473b2 FTS documentation 2016-10-05 08:48:31 +02:00
Gwendal Roué 6a478ca315 Introduce FTS tests 2016-10-05 06:17:42 +02:00
Gwendal Roué 03d4175bea More FTS4 2016-10-04 18:39:32 +02:00
Gwendal Roué 25abdef96a Introduce FTS4 2016-10-04 18:27:48 +02:00
Gwendal Roué a01d8548e3 FTS cleanup 2016-10-04 18:21:51 +02:00
Gwendal Roué c1946e57b7 FTS3Pattern initializers use a tokenizer when relevant 2016-10-04 18:15:57 +02:00
Gwendal Roué 811ed6efe5 FTS: TODO 2016-10-04 16:19:58 +02:00
Gwendal Roué 6855a0afbe #92: FTS3Tokenizer and tests 2016-10-04 14:17:34 +02:00
Gwendal Roué f9e68a0c9c #92: FTS3 module documentation 2016-10-04 11:43:15 +02:00
Gwendal Roué f1ecdfc9df #92: Refactor experimental API around virtual tables creation so that virtual modules can require initialization parameters 2016-10-04 09:37:01 +02:00
Gwendal Roué 01fc9f6130 #92: Experimental API around virtual tables creation 2016-10-04 09:08:23 +02:00
Gwendal Roué a2c3f74ab2 TODO.md 2016-10-03 22:35:41 +02:00
Gwendal Roué 11301d7b63 Remove obsolete code 2016-10-03 22:35:31 +02:00
Gwendal Roué 1d2e1d9950 #92, #129: Test interaction of RowConvertible and MutablePersistable with FTS virtual tables 2016-10-03 22:35:10 +02:00
Gwendal Roué 47938a2278 #92, #129: Test full-text search with NFD-normalized patterns 2016-10-03 20:00:32 +02:00
Gwendal Roué 6922ad04a9 #92, #129: Rename test file 2016-10-03 19:37:00 +02:00
Gwendal Roué cc24e73483 #92, #129: Test FTS3Pattern(matchingAnyTokenIn:), FTS3Pattern(matchingAllTokensIn:), FTS3Pattern(matchingPhrase:) 2016-10-03 19:34:56 +02:00
Gwendal Roué 59fed5c756 #92, #129: Test FTS3Pattern with invalid patterns 2016-10-03 19:10:16 +02:00
Gwendal Roué f93e7579bc #92, #129: Test FTS3Pattern with valid patterns 2016-10-03 19:06:43 +02:00
Gwendal Roué a617053d97 #92, #129: Full-Text Search documentation 2016-10-03 15:32:57 +02:00
Gwendal Roué 3ebd5a95d4 #92, #129: FTS3Pattern cleanup 2016-10-03 14:46:16 +02:00
Gwendal Roué 4f4ecbf819 #92, #129: Full-Text Search documentation 2016-10-03 14:40:28 +02:00
Gwendal Roué cb81b63524 #92, #129: Full-Text Search documentation 2016-10-03 14:39:15 +02:00
Gwendal Roué 8bd3512bc8 #92, #129: Full-Text Search documentation 2016-10-03 14:37:58 +02:00
Gwendal Roué 7f0d3c89bd #92, #129: Full-Text Search documentation 2016-10-03 14:37:00 +02:00
Gwendal Roué f4d87458dd #92, #129: Full-Text Search documentation 2016-10-03 14:31:07 +02:00
Gwendal Roué 2c3c80e45c #92, #129: Full-Text Search documentation 2016-10-03 14:14:42 +02:00
Gwendal Roué 1a24193d2c #92, #129: Full-Text Search documentation 2016-10-03 14:08:36 +02:00
Gwendal Roué 92ac40e4da #92, #129: FTS3Pattern cleanup 2016-10-03 12:18:52 +02:00
Gwendal Roué fcc316674e #92, #129: FTS3Pattern cleanup 2016-10-03 09:07:26 +02:00
Gwendal Roué a0237d4259 #92, #129: FTS3Pattern ~= Column 2016-10-03 08:34:12 +02:00
Gwendal Roué bf061b9d4f #92, #129: FTS3Pattern(matchingAnyTokenIn:tokenizer:), FTS3Pattern(matchingAllTokensIn:tokenizer:), FTS3Pattern(matchingPhrase:tokenizer:) 2016-10-03 08:26:35 +02:00
Gwendal Roué 6f3b5b1c61 #92: introduce FTS4Pattern (addresses #129) 2016-09-30 10:47:36 +02:00
Gwendal Roué 1244b6b283 Move == operators inside their adopting type 2016-09-30 06:00:50 +02:00
Gwendal Roué b01303f5ae GRDBDemoiOS: make setupDatabase() a throwing function 2016-09-29 10:06:50 +02:00
Gwendal Roué 3a9d5730e5 Latest Swift 2.3 version: v0.81.2 2016-09-28 20:55:34 +02:00
Gwendal Roué 17a8a5984b v0.85.0 2016-09-28 20:47:22 +02:00
Gwendal Roué 0cd2c067b6 GRDB Extension Guide: link to future reference 2016-09-28 20:44:28 +02:00
Gwendal Roué b4342492d5 CHANGELOG.md 2016-09-28 20:38:01 +02:00
Gwendal Roué ccbbdd280d CHANGELOG.md 2016-09-28 20:37:14 +02:00
Gwendal Roué ada209dc75 TODO.md 2016-09-28 20:20:58 +02:00
Gwendal Roué a602e3c88a TODO.md 2016-09-28 20:17:24 +02:00
Gwendal Roué b507d527e3 TODO.md 2016-09-28 20:16:59 +02:00
Gwendal Roué 6d1ce4bca2 Documentation: how to access the SQLite C Interface (ping #132) 2016-09-28 20:13:59 +02:00
Gwendal Roué 36eda331d1 ROUND() is a weird beast... Don't use it as an documentation example (and fix extensibility tests) 2016-09-28 19:03:23 +02:00
Gwendal Roué a2eca89fb8 TODO.md 2016-09-28 18:55:31 +02:00
Gwendal Roué a555ba09f1 Documentation 2016-09-28 13:59:02 +02:00
Gwendal Roué 313104a01b TODO.md 2016-09-28 09:49:53 +02:00
Gwendal Roué 744d2a535f Failing extensibility tests 2016-09-28 09:13:00 +02:00
Gwendal Roué f08d9d2775 Document the release process 2016-09-28 09:12:51 +02:00
Gwendal Roué 224cf9b88d Project fixes for SQLCipher and Custom SQLite tests on OSX 2016-09-28 08:49:25 +02:00
Gwendal Roué 5ba06a74a0 Remove support for text encodings 2016-09-28 07:14:22 +02:00
Gwendal Roué 1f14cc35dd CHANGELOG.md 2016-09-28 06:49:12 +02:00
Gwendal Roué 4953307e1e Documentation 2016-09-28 06:47:18 +02:00
Gwendal Roué b33d429212 Documentation 2016-09-28 06:46:25 +02:00
Gwendal Roué d3a17b64f4 Documentation 2016-09-28 06:45:10 +02:00
Gwendal Roué 5a572b25a0 Refactor the query interface types to enhance extensibility 2016-09-27 23:11:21 +02:00
Gwendal Roué 03187804c4 Minor 2016-09-23 08:04:45 +02:00
Gwendal Roué 99b005f0cc Minor 2016-09-23 07:40:57 +02:00
Gwendal Roué 7bf5d027bf TODO: FTS needs =~ match operator 2016-09-22 22:45:46 +02:00
Gwendal Roué e6f7cc8d74 README.md 2016-09-22 15:36:24 +02:00
Gwendal Roué 4224c01925 README.md 2016-09-22 09:14:57 +02:00
Gwendal Roué ea85d577d8 Clarification the behavior of the REPLACE conflict handling regarding transaction observers 2016-09-22 07:48:37 +02:00
Gwendal Roué add0e43723 TODO.md 2016-09-22 07:45:46 +02:00
Gwendal Roué e7378cbba0 Test that the truncate optimization does not prevent transaction observers from observing individual deletions 2016-09-22 07:45:32 +02:00
Gwendal Roué dc58ff19d4 Clarification the behavior of the REPLACE conflict handling regarding transaction observers 2016-09-22 07:44:43 +02:00
Gwendal Roué 7bce331eb1 Clarification the behavior of the REPLACE conflict handling regarding transaction observers 2016-09-22 06:48:18 +02:00
Gwendal Roué 141dc247d6 Playgrounds/MyPlayground.swift 2016-09-21 19:51:23 +02:00
Gwendal Roué dda8df678a Documentation 2016-09-21 09:15:27 +02:00
Gwendal Roué e06abbc354 Documentation 2016-09-21 09:14:00 +02:00
Gwendal Roué 26938c245b Documentation 2016-09-21 09:12:51 +02:00
Gwendal Roué 54e9803080 Rename SchedulingWatchdog.makeSerializedQueueAllowing(database:) to SchedulingWatchdog.makeSerializedQueue(allowingDatabase:) 2016-09-21 09:11:23 +02:00
Gwendal Roué bf30c7cb01 TODO.md 2016-09-17 13:00:35 +02:00
Gwendal Roué 32f063fd2b TODO.md 2016-09-17 12:57:56 +02:00
Gwendal Roué e4c27a31fa TODO.md 2016-09-17 12:53:05 +02:00
Gwendal Roué 365e44e376 TableMapping.deleteAll(db) 2016-09-17 12:50:57 +02:00
Gwendal Roué 7e55a8558a Documentation 2016-09-17 11:05:27 +02:00
Gwendal Roué e38b007743 Documentation 2016-09-17 11:03:09 +02:00
Gwendal Roué f2dd248200 Documentation 2016-09-17 11:02:02 +02:00
Gwendal Roué ce8673e7e2 Documentation 2016-09-17 10:35:59 +02:00
Gwendal Roué aaf4deee2c Documentation 2016-09-17 06:30:44 +02:00
Gwendal Roué 7a0895f872 Documentation 2016-09-17 06:13:37 +02:00
Gwendal Roué d052c32f7a Documentation 2016-09-17 06:01:12 +02:00
Gwendal Roué 07dbee52cd Documentation 2016-09-17 05:58:50 +02:00
Gwendal Roué aa8b1f39b3 Documentation 2016-09-17 05:39:16 +02:00
Gwendal Roué 849c550191 Typo 2016-09-17 05:35:30 +02:00
Gwendal Roué 41cdb4911c CHANGELOG.md 2016-09-17 05:26:19 +02:00
Gwendal Roué 15c4efcbe4 Typo 2016-09-17 05:20:12 +02:00
Gwendal Roué 6b776f0b92 Documentation of DatabaseValue.fromDatabaseValue 2016-09-16 22:25:58 +02:00
Gwendal Roué b8005deaa4 Fix typo 2016-09-16 22:23:48 +02:00
Gwendal Roué 2fc35e2543 Documentation of DatabaseValue.fromDatabaseValue 2016-09-16 22:23:12 +02:00
Gwendal Roué e7fcfff370 Documentation of DatabaseValue conversion from NULL 2016-09-16 22:16:08 +02:00
Gwendal Roué 4bc9033205 Documentation of DatabaseValue conversion from NULL 2016-09-16 22:14:10 +02:00
Gwendal Roué 8673550b69 Conflict resolution documentation 2016-09-16 20:29:06 +02:00
Gwendal Roué e47ed9c012 Conflict resolution documentation 2016-09-16 20:25:47 +02:00
Gwendal Roué bdd58a50b1 Conflict resolution documentation 2016-09-16 20:23:26 +02:00
Gwendal Roué e3d8deba0c v0.84.0 2016-09-16 20:05:44 +02:00
Gwendal Roué b386832256 Conflict resolution documentation 2016-09-16 19:56:43 +02:00
Gwendal Roué 26564cfeda Conflict resolution documentation 2016-09-16 19:55:52 +02:00
Gwendal Roué 78e560318d Conflict resolution documentation 2016-09-16 19:54:51 +02:00
Gwendal Roué 7a88044edb Conflict resolution documentation 2016-09-16 19:53:19 +02:00
Gwendal Roué cc06968c42 Conflict resolution documentation 2016-09-16 19:40:34 +02:00
Gwendal Roué ae7c89d746 Conflict resolution documentation 2016-09-16 19:37:29 +02:00
Gwendal Roué 0c525a8e52 Only the IGNORE conflict policy invalidates the last inserted rowID (#118) 2016-09-16 19:37:14 +02:00
Gwendal Roué 4ac562a55a Fixes #118 2016-09-16 13:52:43 +02:00
Gwendal Roué 5180673b6d v0.83.0 2016-09-16 07:50:35 +02:00
Gwendal Roué f573046107 Merge branch 'Swift2.3' of github.com:groue/GRDB.swift
Conflicts:
	CHANGELOG.md
	GRDB.swift.podspec
	GRDB/Core/DatabaseValue.swift
	GRDB/Core/Row.swift
	GRDB/Core/RowAdapter.swift
	GRDB/Record/Record.swift
	README.md
	Support/Info.plist
	Tests/Public/Core/DatabaseValue/DatabaseValueTests.swift
	Tests/Public/Record/MinimalPrimaryKeyRowIDTests.swift
	Tests/Public/Record/MinimalPrimaryKeySingleTests.swift
	Tests/Public/Record/PrimaryKeyMultipleTests.swift
	Tests/Public/Record/PrimaryKeyRowIDTests.swift
	Tests/Public/Record/PrimaryKeySingleTests.swift
	Tests/Public/Record/PrimaryKeySingleWithReplaceConflictResolutionTests.swift
2016-09-16 06:46:42 +02:00
Gwendal Roué a24878209b v0.81.1 2016-09-16 06:00:16 +02:00
Gwendal Roué f12d69a4f6 CHANGELOG.md 2016-09-16 05:59:42 +02:00
Gwendal Roué 4a1706ede6 Remove Row.databaseValue(atIndex:) and Row.databaseValue(named:) 2016-09-16 05:58:17 +02:00
Gwendal Roué f5cb34f506 DatabaseValue no longer adopts StatementColumnConvertible; DatabaseValue.fromDatabaseValue() no longer returns nil for NULL (fixes #119) 2016-09-16 05:48:09 +02:00
Gwendal Roué 2f1e758eb4 Upgrade SQLiteCustom to v3.14.1 2016-09-16 05:46:37 +02:00
Gwendal Roué f825f43528 Upgrade custom SQLite builds to v3.14.1, and restore support for SQLite pre-update hooks 2016-09-15 09:05:09 +02:00
Gwendal Roué 8f1844921e README.md 2016-09-15 07:24:20 +02:00
Gwendal Roué 1cd887d3ec TODO.md 2016-09-15 06:42:05 +02:00
Gwendal Roué 0bb53a73a8 README.md 2016-09-14 21:31:05 +02:00
Gwendal Roué 6ede5dda6b README.md 2016-09-14 21:29:25 +02:00
Gwendal Roué 3dbf92bb58 README.md 2016-09-14 21:21:33 +02:00
Gwendal Roué f447d7f423 README.md 2016-09-14 16:08:37 +02:00
Gwendal Roué a3f6a330e2 README.md 2016-09-14 13:28:35 +02:00
Gwendal Roué 0c26670bf6 README.md 2016-09-14 13:19:55 +02:00
Gwendal Roué 97884af83d Documentation 2016-09-14 09:13:26 +02:00
Gwendal Roué 946df5f8d6 Documentation 2016-09-14 09:05:20 +02:00
Gwendal Roué e98a12c797 v0.82.1 2016-09-14 08:59:27 +02:00
Gwendal Roué 7444870741 CocoaPods support: .swift-version 2016-09-14 08:57:20 +02:00
Gwendal Roué 2bcf6a5da8 Restore FetchedRecordsController (fixes #117)
The Swift 3 compiler in Release configuration collapses when a property of type DatabaseWriter calls its rethrowing write() method. This commit introduces an ad-hoc non-rethrowing method to make the compiler happy.
2016-09-13 13:39:01 +02:00
Gwendal Roué b77fa8d57b Revert "Disable FetchedRecordsController which does not compile in Release configuration (fixes #116)"
This reverts commit cfd6f063e1.
2016-09-13 13:10:26 +02:00
Gwendal Roué cfd6f063e1 Disable FetchedRecordsController which does not compile in Release configuration (fixes #116)
Tests won't run in Release mode (because of compilation errors around the DatabaseReader protocol), but at least Carthage can build the iOS, macOS, and watchOS frameworks.
2016-09-13 09:02:51 +02:00
Gwendal Roué a8906da890 Fix documentation typo 2016-09-11 13:44:45 +02:00
Gwendal Roué b63046b20a v0.82.0 2016-09-11 13:16:40 +02:00
Gwendal Roué df91e31397 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	README.md
2016-09-11 13:11:27 +02:00
Gwendal Roué b40622c093 More renaming Fix-its for the Swift 2.x -> Swift 3 API changes 2016-09-11 12:56:31 +02:00
Gwendal Roué a925aac1df Project settings 2016-09-11 12:30:28 +02:00
Gwendal Roué 2081b6a4a8 Merge pull request #114 from swiftlyfalling/Swift3-Swift2-conversion-fixits
Automatic renaming Fix-Its for many of the Swift 2.x -> Swift 3 GRDB API changes
2016-09-11 08:07:36 +02:00
Gwendal Roué 7b66f5afb3 Fix repo URL in Podfile snippet (fixes #113) 2016-09-11 07:48:55 +02:00
swiftlyfalling a14da417a7 Add automatic renaming Fix-Its that cover many of the Swift 2.x -> Swift 3 GRDB API changes. 2016-09-10 17:44:48 -04:00
Gwendal Roué 5af4e1db67 README.md 2016-09-10 18:44:02 +02:00
Gwendal Roué e90e0f7d57 Database event filtering documentation 2016-09-10 18:40:43 +02:00
Gwendal Roué eac0901af0 Refactor database event filtering 2016-09-10 18:28:44 +02:00
Gwendal Roué 79f3f69827 Revert "Tests for numeric overflows depend on architecture"
This reverts commit 88cc17b530.
2016-09-10 17:55:46 +02:00
Gwendal Roué 7c0ca54249 Swift 3: move some types declarations inside the Database class 2016-09-10 17:52:15 +02:00
Gwendal Roué d10d4220a8 README.md 2016-09-10 17:25:13 +02:00
Gwendal Roué ab8ef25f89 Remove SQLCipher support from Carthage 2016-09-10 17:22:16 +02:00
Gwendal Roué 8ff60854ac CHANGELOG.md 2016-09-10 17:15:47 +02:00
Gwendal Roué 41938a5f16 CHANGELOG.md 2016-09-10 16:36:19 +02:00
Gwendal Roué 10f8a2e807 CHANGELOG.md 2016-09-10 16:31:57 +02:00
Gwendal Roué 2d8de7009b Swift 3 and watchOS 2016-09-10 16:28:18 +02:00
Gwendal Roué 88cc17b530 Tests for numeric overflows depend on architecture 2016-09-10 16:15:35 +02:00
Gwendal Roué df09d0c8bb Swift 3 and SQLCipher 2016-09-10 16:03:42 +02:00
Gwendal Roué 749aa28b9a Merge branch 'Swift2.3' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	CHANGELOG.md
	DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Support/Foundation/NSURL.swift
	README.md
	TODO.md
	Tests/Public/SQLTableBuilder/SQLTableBuilderTests.swift
2016-09-10 15:36:56 +02:00
Gwendal Roué 912ec6a9e9 Cleanup 2016-09-10 15:34:32 +02:00
Gwendal Roué e49957b2b2 v0.81.0 2016-09-10 13:28:17 +02:00
Gwendal Roué 06e74ffb47 Update link to latest Swift2.2 version 2016-09-09 13:46:45 +02:00
Gwendal Roué 4ebbc638da Merge branch 'Swift2.2' of github.com:groue/GRDB.swift 2016-09-09 13:45:39 +02:00
Gwendal Roué 757fbbdd88 v0.80.2 2016-09-09 13:35:36 +02:00
Gwendal Roué c73965f69a Fix SQLiteWatchOS module 2016-09-09 13:33:54 +02:00
Gwendal Roué 2af0f73473 Swift 2.3 requires Xcode 8 2016-09-09 09:15:35 +02:00
Gwendal Roué 305ecf8a7c watchOS requirement 2016-09-09 09:10:38 +02:00
Gwendal Roué da56090604 Typo 2016-09-09 09:02:45 +02:00
Gwendal Roué 98eb5640ed Typo 2016-09-09 09:02:19 +02:00
Gwendal Roué 1e1b1baad5 Update README about various Swift versions 2016-09-09 09:00:41 +02:00
Gwendal Roué a68103e8ba Apply https://github.com/groue/GRDB.swift/issues/101#issuecomment-240568714 2016-09-09 08:48:10 +02:00
Gwendal Roué 3438addf6c Swift 2.3 (addresses #110, #112) 2016-09-09 08:44:03 +02:00
Gwendal Roué 6fc7c4e2c0 TODO.md 2016-09-08 13:57:30 +02:00
Gwendal Roué dc7537ac0a Apply https://github.com/groue/GRDB.swift/issues/101#issuecomment-240568714 2016-09-08 13:56:59 +02:00
Gwendal Roué d7a83f3361 TODO.md 2016-09-08 13:25:06 +02:00
Gwendal Roué 5e75b1e7dc v0.80.1 2016-09-08 13:04:01 +02:00
Gwendal Roué a11a16a700 Project cleanup 2016-09-08 12:58:14 +02:00
Gwendal Roué a3de8281ef Ooops add watchOS to the podspec 2016-09-08 09:13:23 +02:00
Gwendal Roué 7960528464 Update GRDBDemo iOS/watchOS for Xcode 8 GM 2016-09-08 09:06:44 +02:00
Gwendal Roué a8b067885f Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	README.md
	TODO.md
2016-09-08 08:37:58 +02:00
Gwendal Roué 945fabbdd6 Disable macOS tests that trigger a linker error 2016-09-08 08:10:00 +02:00
Gwendal Roué c12bf0aead Xcode is no longer beta 2016-09-08 08:09:10 +02:00
Gwendal Roué 12f25ddafd Fix Xcode 8.0 GM compilation errors 2016-09-08 08:08:38 +02:00
Gwendal Roué 55f07e913a v0.80.0 2016-09-07 22:59:03 +02:00
Gwendal Roué 0bd22281f7 GRDBDemoWatchOS 2016-09-07 22:51:12 +02:00
Gwendal Roué 72ab62b21b Merge branch 'WatchOS' of github.com:groue/GRDB.swift 2016-09-07 22:17:08 +02:00
Gwendal Roué 796d30d863 TODO.md 2016-09-07 22:16:01 +02:00
Gwendal Roué b191323e2b Query Interface deletion documentation 2016-09-07 18:06:30 +02:00
Gwendal Roué e4ae0988a4 QueryInterfaceRequest.deleteAll (for @pakko972) 2016-09-07 14:10:16 +02:00
Gwendal Roué 238ebdeed8 Fix the documentation of delete/Fetch/One/All(keys:) so that it makes clear that arguments are unique keys. 2016-09-07 13:44:25 +02:00
Gwendal Roué 68ebe1a4ff TODO.md 2016-09-07 13:39:37 +02:00
Gwendal Roué 8a89be6999 Pass test for Database.tableExists() and temporary table 2016-09-07 13:33:31 +02:00
Gwendal Roué 0620fc9f17 Failing test for Database.tableExists() and temporary table 2016-09-07 13:29:06 +02:00
Gwendal Roué 1e95e38505 TODO.md 2016-09-07 04:24:18 +02:00
Gwendal Roué 5b4e5f9d1d TODO.md 2016-09-06 10:08:05 +02:00
Gwendal Roué 6285fd9f98 TODO.md 2016-09-06 06:25:37 +02:00
Gwendal Roué 401d5cab66 TODO.md 2016-09-02 12:46:29 +02:00
Gwendal Roué d7e2df5ca9 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	README.md
2016-08-19 09:01:59 +02:00
Gwendal Roué b38177bb32 Fix reference Swift 2.2 version 2016-08-19 09:00:34 +02:00
Gwendal Roué 27b9cbda38 Documentation 2016-08-19 08:59:06 +02:00
Gwendal Roué a71e08ad2a TODO: attempt to read from the database in DatabasePool.init() and throw eventual error (see #99) 2016-08-18 11:16:47 +02:00
Gwendal Roué 5e0c9165ba Update project settings 2016-08-17 13:06:17 +02:00
Gwendal Roué cb2a6cd3b5 TODO 2016-08-17 12:59:55 +02:00
Gwendal Roué 81c0e73751 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Core/Row.swift
	GRDB/QueryInterface/SQLTableBuilder.swift
	README.md
2016-08-17 12:58:41 +02:00
Gwendal Roué 6f12594b3e v0.79.4 2016-08-17 08:04:01 +02:00
Gwendal Roué 5a296b1238 Fix #102 2016-08-17 07:54:13 +02:00
Gwendal Roué 249456c916 Add failing test for #102 (DatabasePool can't open a non-WAL database and then read, with error 14) 2016-08-17 07:20:25 +02:00
Gwendal Roué 5aa2554584 v0.79.3 2016-08-16 19:21:11 +02:00
Gwendal Roué 9999ced817 Pass tests for table creation DSL with auto references
Conflicts:
	CHANGELOG.md
2016-08-16 19:03:35 +02:00
Gwendal Roué 6c137b29c2 Failing tests for table creation DSL with auto references 2016-08-16 19:01:53 +02:00
Gwendal Roué 854c070b82 Xcode Version 8.0 beta 6 (8S201h) 2016-08-16 17:47:57 +02:00
Gwendal Roué 6a5a4664e9 CHANGELOG.md 2016-08-13 11:01:20 +02:00
Gwendal Roué 5aaecd3946 Row.value(SQLColumn) 2016-08-13 10:59:16 +02:00
Gwendal Roué 425310710f TODO.md 2016-08-11 09:09:08 +02:00
Gwendal Roué af990fb666 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3 2016-08-11 08:12:29 +02:00
Gwendal Roué c0b2669c46 Tests for generated UPDATE queries allow some variation 2016-08-11 08:11:48 +02:00
Gwendal Roué edc615f487 Tests for generated UPDATE queries allow some variation 2016-08-11 08:07:58 +02:00
Gwendal Roué 04b8b8dd5a Update version 2016-08-10 21:30:19 +02:00
Gwendal Roué 34ef36544e Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Record/Persistable.swift
	README.md
	Tests/Public/Core/Persistable/MutablePersistableTests.swift
	Tests/Public/Core/Persistable/PersistableTests.swift
2016-08-10 21:29:30 +02:00
Gwendal Roué 4a9deadcf4 v0.79.2 2016-08-10 21:19:06 +02:00
Gwendal Roué e1eb1d705a Pass tests for partial update case insensitivity 2016-08-10 21:14:35 +02:00
Gwendal Roué ab035a3887 Failing tests for partial update case insensitivity 2016-08-10 21:14:26 +02:00
Gwendal Roué c92f0f3edf Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/QueryInterface/SQLTableBuilder.swift
	GRDB/Record/Persistable.swift
	GRDB/Record/Record.swift
	README.md
	TODO.md
	Tests/Public/Core/Persistable/MutablePersistableTests.swift
	Tests/Public/SQLTableBuilder/SQLTableBuilderTests.swift
2016-08-10 20:43:24 +02:00
Gwendal Roué ceb73730c2 v0.79.1 2016-08-10 18:56:23 +02:00
Gwendal Roué 60e0a731ad Partial updates now requires updated columns to be present in the persistentDictionary. 2016-08-10 18:54:32 +02:00
Gwendal Roué d9e77284c1 Pass test for multiple foreign keys on a column 2016-08-10 13:23:24 +02:00
Gwendal Roué 4d9c7d0dcb Failing test for multiple foreign keys on a column 2016-08-10 13:23:19 +02:00
Gwendal Roué 936d2e56ea CHANGELOG.md 2016-08-10 09:08:06 +02:00
Gwendal Roué 4be1923921 Pass test for multiple check constraints on a column 2016-08-10 08:48:24 +02:00
Gwendal Roué 7bb5866164 Failing test for multiple check constraints on a column 2016-08-10 08:48:06 +02:00
Gwendal Roué 0f2854fe17 CHANGELOG.md 2016-08-10 08:26:43 +02:00
Gwendal Roué 548b2f4b77 Rename DataMapper to DAO 2016-08-10 08:24:31 +02:00
Gwendal Roué cd776e4b64 Passing tests for delete() when primary key is nil 2016-08-10 08:20:15 +02:00
Gwendal Roué aeca4c0f9c Failing tests that delete() returns false when primary key is nil 2016-08-10 08:16:32 +02:00
Gwendal Roué d96b1bb9f8 Passing tests for update() and exists() when primary key is nil 2016-08-10 08:14:37 +02:00
Gwendal Roué 944bdd5bba Failing tests that update() throws PersistenceError.NotFound when primary key is nil 2016-08-10 08:03:41 +02:00
Gwendal Roué e61550841b Failing tests that exists() returns false when primary key is nil 2016-08-10 08:00:27 +02:00
Gwendal Roué ff5e171d4a Date format documentation (addresses #97) 2016-08-10 07:45:04 +02:00
Gwendal Roué b5bb92459d WatchOS framework (adresses #96) 2016-08-10 06:27:50 +02:00
Gwendal Roué b9ea94e9be TODO.md 2016-08-10 06:15:53 +02:00
Gwendal Roué f42186f7c9 TODO.md 2016-08-10 06:10:59 +02:00
Gwendal Roué b510bff195 Documentation 2016-08-09 18:41:30 +02:00
Gwendal Roué c1b85c0d21 TODO.md 2016-08-09 18:35:50 +02:00
Gwendal Roué 08f84bdc07 TODO.md 2016-08-09 14:36:56 +02:00
Gwendal Roué 187c93377f Documentation 2016-08-09 09:09:11 +02:00
Gwendal Roué eb4b85dc79 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3 2016-08-09 09:08:48 +02:00
Gwendal Roué 36d7bf77e3 Documentation 2016-08-09 09:07:45 +02:00
Gwendal Roué 2a47e5f32c TODO.md 2016-08-08 21:28:15 +02:00
Gwendal Roué b522abffb5 TODO.md 2016-08-08 21:24:01 +02:00
Gwendal Roué ba272061b7 Documentation 2016-08-08 13:54:02 +02:00
Gwendal Roué 142542da1e Merge branch 'master' of github.com:groue/GRDB.swift into Swift3 2016-08-08 13:47:19 +02:00
Gwendal Roué c79c4d265c Documentation 2016-08-08 13:46:26 +02:00
Gwendal Roué 95289f1715 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/QueryInterface/SQLTableBuilder.swift
	README.md
	TODO.md
	Tests/Public/SQLTableBuilder/SQLTableBuilderTests.swift
2016-08-08 13:35:59 +02:00
Gwendal Roué a35d5c4c3a v0.79.0 2016-08-08 13:22:49 +02:00
Gwendal Roué c6fd36b75d SQLTableBuilder: column.defaults(to:) 2016-08-08 13:19:43 +02:00
Gwendal Roué 985eb69c50 TODO.md 2016-08-08 10:42:09 +02:00
Gwendal Roué 17912ebffe Documentation 2016-08-08 09:19:41 +02:00
Gwendal Roué a9b41d4a21 TODO.md 2016-08-08 08:57:10 +02:00
Gwendal Roué 0b020ce1ac Documentation 2016-08-08 08:12:18 +02:00
Gwendal Roué 580532aeca Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Core/Statement.swift
2016-08-08 08:10:48 +02:00
Gwendal Roué 8c43047c95 Documentation 2016-08-08 08:06:43 +02:00
Gwendal Roué 05aeef0ea0 Documentation 2016-08-08 08:06:09 +02:00
Gwendal Roué ced9493069 Better compilation time 2016-08-07 15:26:39 +02:00
Gwendal Roué 76ab3fd1ab Better compilation time 2016-08-07 15:26:30 +02:00
Gwendal Roué 7d6fcda03e slow_methods.sh output methods that are slow to compile 2016-08-07 15:26:18 +02:00
Gwendal Roué a7d2c1137c CHANGELOG.md 2016-08-07 13:53:25 +02:00
Gwendal Roué 033ad18779 CHANGELOG.md 2016-08-07 13:51:34 +02:00
Gwendal Roué 404706a3db Swift 3 tests 2016-08-07 13:19:53 +02:00
Gwendal Roué 2c3bf06740 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/QueryInterface/QueryInterfaceRequest.swift
	GRDB/QueryInterface/SQLCollation.swift
	GRDB/QueryInterface/SQLFunction.swift
	GRDB/QueryInterface/SQLOperator.swift
	GRDB/QueryInterface/SQLSelectQuery.swift
	GRDB/QueryInterface/SQLTableBuilder.swift
2016-08-07 12:57:48 +02:00
Gwendal Roué a132b58227 Promote _SQLExpressible protocol to SQLExpressible 2016-08-07 12:46:19 +02:00
Gwendal Roué 8d91141d6a Swift 3 : lowercase enum cases for DatabasePreUpdateEvent.Kind 2016-08-07 12:25:13 +02:00
Gwendal Roué a8ac895998 Swift 3 documentation 2016-08-07 12:24:32 +02:00
Gwendal Roué ee8aa1d9c6 Swift 3: move @noescape qualifiers 2016-08-07 11:04:04 +02:00
Gwendal Roué 206e45214f Merge branch 'master' of github.com:groue/GRDB.swift into Swift3 2016-08-07 11:00:25 +02:00
Gwendal Roué ba2aef0468 Documentation 2016-08-07 10:59:56 +02:00
Gwendal Roué 7642b522f9 SQLTableBuilder: add missing @noescape qualifiers 2016-08-07 10:57:26 +02:00
Gwendal Roué b8960c4549 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/PersonsViewController.swift
2016-08-07 10:48:46 +02:00
Gwendal Roué 358b823e00 GRDBDemoiOS: use table creation DSL 2016-08-07 10:44:19 +02:00
Gwendal Roué aa3a95f528 Swift 3 GRDBDemoiOS 2016-08-07 10:38:51 +02:00
Gwendal Roué 00a1eebf60 Swift 3 Grand Renaming: SQLColumn -> Column 2016-08-07 10:38:24 +02:00
Gwendal Roué b6587da081 Swift 3 Documentation 2016-08-07 10:20:07 +02:00
Gwendal Roué bcd6e6767a Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseSchemaCache.swift
	GRDB/QueryInterface/SQLCollation.swift
	README.md
	TODO.md
	Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConversionTests.swift
	Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleTests.swift
	Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift
2016-08-07 10:11:31 +02:00
Gwendal Roué 7d21772f87 Documentation 2016-08-07 05:01:27 +02:00
Gwendal Roué 949d706eaa Documentation 2016-08-07 04:41:43 +02:00
Gwendal Roué c8445b9b5f Documentation 2016-08-07 04:35:31 +02:00
Gwendal Roué d3c901678c Documentation 2016-08-07 04:18:44 +02:00
Gwendal Roué 1549affd5c Documentation 2016-08-07 04:14:29 +02:00
Gwendal Roué f9e875a7cc Documentation 2016-08-07 04:11:37 +02:00
Gwendal Roué 5b65279a0a Documentation 2016-08-07 04:00:57 +02:00
Gwendal Roué ccd58d2909 Documentation 2016-08-07 03:41:18 +02:00
Gwendal Roué 714f56c17c Fix version links 2016-08-06 20:50:38 +02:00
Gwendal Roué a820a96996 v0.78.0 2016-08-06 15:40:11 +02:00
Gwendal Roué 1d77523e41 Merge pull request #93 from groue/SQLTableBuilder
Table Creation DSL
2016-08-06 15:38:06 +02:00
Gwendal Roué 107c1529ff Merge branch 'master' of github.com:groue/GRDB.swift into SQLTableBuilder
Conflicts:
	TODO.md
2016-08-06 15:29:06 +02:00
Gwendal Roué a7f80ef144 CHANGELOG.md 2016-08-06 15:27:32 +02:00
Gwendal Roué 9274864a83 Identity 2016-08-06 15:09:47 +02:00
Gwendal Roué f51bbd8a39 Documentation tweaks 2016-08-06 15:07:07 +02:00
Gwendal Roué 1534e1a1ee Documentation tweaks 2016-08-06 15:05:16 +02:00
Gwendal Roué 0c9c176223 SQLTableBuilder documentation 2016-08-06 15:00:38 +02:00
Gwendal Roué e58ed7a3dc SQLTableBuilder documentation 2016-08-06 14:59:01 +02:00
Gwendal Roué adde65f757 SQLTableBuilder documentation 2016-08-06 14:58:21 +02:00
Gwendal Roué b45939ed26 SQLTableBuilder documentation 2016-08-06 14:57:01 +02:00
Gwendal Roué 3de4920385 SQLTableBuilder documentation 2016-08-06 14:54:53 +02:00
Gwendal Roué 0ab4df99b7 SQLTableBuilder documentation 2016-08-06 14:43:43 +02:00
Gwendal Roué adaabcb8e5 SQLTableBuilder documentation 2016-08-06 14:38:20 +02:00
Gwendal Roué 68403ee142 SQLTableBuilder documentation 2016-08-06 14:33:31 +02:00
Gwendal Roué 1eb0040126 SQLTableBuilder documentation 2016-08-06 14:21:57 +02:00
Gwendal Roué 6cca2fd991 Rename PrimaryKey to PrimaryKeyInfo 2016-08-06 14:21:39 +02:00
Gwendal Roué f276ab830a README.md 2016-08-06 14:02:00 +02:00
Gwendal Roué 2d3f45bad5 README.md 2016-08-06 13:57:03 +02:00
Gwendal Roué 30259c4360 SQLTableBuilder polish 2016-08-06 13:49:46 +02:00
Gwendal Roué cfa091dbc4 SQLTableBuilder documentation + drop support for explicit primary key ordering until someone asks for it. 2016-08-06 13:40:04 +02:00
Gwendal Roué eb18f474c8 Error handling documentation 2016-08-06 12:12:04 +02:00
Gwendal Roué 6554a027d7 Error handling documentation 2016-08-06 12:07:12 +02:00
Gwendal Roué 0e83f0b217 Error handling documentation 2016-08-06 12:05:45 +02:00
Gwendal Roué b45d6945b1 Error handling documentation 2016-08-06 11:15:41 +02:00
Gwendal Roué c2e32c0bf2 Error handling documentation 2016-08-06 11:13:27 +02:00
Gwendal Roué 926b9b1d1a Error handling documentation 2016-08-06 11:11:38 +02:00
Gwendal Roué 57b51cec9c TODO.md 2016-08-06 11:11:06 +02:00
Gwendal Roué ebfcc2e23a SQLTableBuilder documentation 2016-08-06 10:16:43 +02:00
Gwendal Roué 980b3234d5 SQLTableBuilder documentation 2016-08-06 10:14:04 +02:00
Gwendal Roué a25b914085 SQLTableBuilder documentation 2016-08-06 10:11:56 +02:00
Gwendal Roué c936000d62 SQLTableBuilder documentation 2016-08-06 10:08:00 +02:00
Gwendal Roué e1f3adafb7 Typo 2016-08-06 10:02:24 +02:00
Gwendal Roué 4745eb190a Query Interface Request documentation 2016-08-06 10:00:13 +02:00
Gwendal Roué d78784e45e SQLTableBuilder documentation 2016-08-06 09:54:30 +02:00
Gwendal Roué 6e60ff2062 SQLTableBuilder documentation 2016-08-06 09:53:34 +02:00
Gwendal Roué b8c1c1ef1e Length function documentation 2016-08-06 09:51:35 +02:00
Gwendal Roué d918f0fb03 SQLTableBuilder: limit WITHOUT ROWID availability 2016-08-06 07:08:59 +02:00
Gwendal Roué 91d6880218 SQLTableBuilder documentation 2016-08-06 00:13:56 +02:00
Gwendal Roué ea30075602 SQLTableBuilder documentation 2016-08-06 00:10:15 +02:00
Gwendal Roué a00ca647f5 SQLTableBuilder documentation 2016-08-05 23:53:05 +02:00
Gwendal Roué f6260087c3 SQLTableBuilder documentation 2016-08-05 23:51:58 +02:00
Gwendal Roué 81e1d86047 SQLTableBuilder documentation 2016-08-05 23:51:01 +02:00
Gwendal Roué 988ac8e60b SQLTableBuilder polish 2016-08-05 23:45:27 +02:00
Gwendal Roué cc624f9ed2 SQLTableBuilder documentation 2016-08-05 23:39:28 +02:00
Gwendal Roué 8d2984c572 SQLTableBuilder documentation 2016-08-05 23:36:54 +02:00
Gwendal Roué 29d4396956 SQLTableBuilder: tests for unicode default strings 2016-08-05 23:35:56 +02:00
Gwendal Roué 0ba0023099 SQLTableBuilder documentation + support for LENGTH SQLite function 2016-08-05 23:22:47 +02:00
Gwendal Roué 2ef26e9681 SQLTableBuilder documentation 2016-08-05 23:06:38 +02:00
Gwendal Roué 3be6b6966b SQLTableBuilder documentation 2016-08-05 23:04:44 +02:00
Gwendal Roué 415aeb1ef5 SQLTableBuilder documentation 2016-08-05 23:02:39 +02:00
Gwendal Roué 2fc25e9b13 SQLTableBuilder documentation 2016-08-05 23:00:23 +02:00
Gwendal Roué 00a032e6b0 SQLTableBuilder documentation 2016-08-05 22:58:03 +02:00
Gwendal Roué 04ab95ab76 README.md 2016-08-05 20:51:15 +02:00
Gwendal Roué 2f3c7eb550 README.md 2016-08-05 20:49:57 +02:00
Gwendal Roué dce6d50350 README.md 2016-08-05 20:49:32 +02:00
Gwendal Roué 6ac63436f7 README.md 2016-08-05 20:48:16 +02:00
Gwendal Roué 03979d8665 README.md 2016-08-05 20:45:58 +02:00
Gwendal Roué 8991232681 SQLTableBuilder: alter(table:) { $0.add(column:) } 2016-08-05 20:31:18 +02:00
Gwendal Roué 31a0604341 SQLTableBuilder: rename(table:to:) 2016-08-05 20:04:28 +02:00
Gwendal Roué 8b6ac9c736 SQLTableBuilder: create(index:), drop(index:) 2016-08-05 19:58:12 +02:00
Gwendal Roué ac5279fa70 Use SQLCollation instead of String 2016-08-05 18:51:06 +02:00
Gwendal Roué ed2ea88cb5 TODO.md 2016-08-05 14:55:07 +02:00
Gwendal Roué f2a7706bdf SQLTableBuilder: test ordering of DSL statements is not the ordering of SQL clauses 2016-08-05 14:06:11 +02:00
Gwendal Roué b88d2fe111 SQLTableBuilder: table.check() 2016-08-05 14:03:50 +02:00
Gwendal Roué 9b9b4d4bdf SQLTableBuilder: column.defaults() and column.check() now accept SQL literal 2016-08-05 13:52:09 +02:00
Gwendal Roué 41037eb425 SQLTableBuilder: column.defaults() requires a constant value (so does SQLite) 2016-08-05 13:33:47 +02:00
Gwendal Roué ba126f1f1a SQLTableBuilder: code organization 2016-08-05 13:24:10 +02:00
Gwendal Roué 88894a6d54 SQLTableBuilder: TODO 2016-08-05 09:12:25 +02:00
Gwendal Roué 61cb276b94 SQLTableBuilder: table.foreignKey() 2016-08-05 09:05:32 +02:00
Gwendal Roué f83f5455c2 SQLTableBuilder: table.primaryKey(), table.uniqueKey() 2016-08-05 08:48:46 +02:00
Gwendal Roué 09e409cb79 SQLTableBuilder: documentation 2016-08-05 08:25:46 +02:00
Gwendal Roué 39e3cba80e SQLTableBuilder: column.references(deferred: true) 2016-08-05 08:24:00 +02:00
Gwendal Roué 8246f1c990 SQLTableBuilder: column.references() 2016-08-05 08:17:09 +02:00
Gwendal Roué 10c32381d4 SQLTableBuilder: column.collate() 2016-08-04 23:05:56 +02:00
Gwendal Roué 5b6efbbb5f SQLTableBuilder: column.defaults() 2016-08-04 22:57:14 +02:00
Gwendal Roué 5edb5276f8 SQLTableBuilder: column.check() 2016-08-04 13:57:32 +02:00
Gwendal Roué b1109780ed SQLTableBuilder: column.notNull() and unique() 2016-08-04 13:48:08 +02:00
Gwendal Roué 62070c50ff SQLTableBuilder WIP 2016-08-04 13:38:39 +02:00
Gwendal Roué 8332dc188a SQLTableBuilder tests 2016-08-04 13:34:14 +02:00
Gwendal Roué 3e28fd69b3 SQLTableBuilder: table & column primary key options 2016-08-04 09:10:32 +02:00
Gwendal Roué 4cf6f7bd7c SQLTableBuilder: first passing test 2016-08-04 08:51:00 +02:00
Gwendal Roué a2b0a57971 Realm 1.0.2 2016-08-03 13:27:50 +02:00
Gwendal Roué df7d5c6075 Performance tips 2016-08-02 09:03:34 +02:00
Gwendal Roué e6f9811162 Performance tips 2016-08-02 09:00:59 +02:00
Gwendal Roué 7625c75dc7 Swift 3: update project settings 2016-08-02 08:43:29 +02:00
Gwendal Roué 07ab79d8dd Swift 3 2016-08-02 08:38:59 +02:00
Gwendal Roué 54f8550229 Swift 3 2016-08-02 08:38:45 +02:00
Gwendal Roué f6ae7587ea More where clause to end of function declarations 2016-08-02 08:20:05 +02:00
Gwendal Roué 2d78d04d52 Update for Xcode Version 8.0 beta 4 (8S188o) 2016-08-01 22:33:50 +02:00
Gwendal Roué 5a26ee2ca9 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis 2016-08-01 19:02:42 +02:00
Gwendal Roué 8971d7b876 Performance tips 2016-08-01 19:02:25 +02:00
Gwendal Roué 158894c7cc Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis 2016-08-01 18:59:05 +02:00
Gwendal Roué 589f98bcc2 Performance tips 2016-08-01 18:58:46 +02:00
Gwendal Roué 9b250b0dda Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis 2016-08-01 18:47:53 +02:00
Gwendal Roué ebe147ee34 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Row.swift
	README.md
	TODO.md
2016-08-01 18:47:42 +02:00
Gwendal Roué 4cd0334ed1 Performance tips 2016-08-01 18:38:23 +02:00
Gwendal Roué c49506e588 Performance tips 2016-08-01 17:27:49 +02:00
Gwendal Roué 238f5a9af3 didInsertWithRowID documentation 2016-08-01 17:25:30 +02:00
Gwendal Roué 5d81d0e640 Performance tips 2016-08-01 17:21:37 +02:00
Gwendal Roué 4baa0b102d Performance tips 2016-08-01 17:17:21 +02:00
Gwendal Roué 0cd17f15d7 Performance tips 2016-08-01 17:15:47 +02:00
Gwendal Roué 1fa08bbbc3 Performance tips 2016-08-01 17:09:39 +02:00
Gwendal Roué 9e06242c1d Performance tips 2016-08-01 15:19:16 +02:00
Gwendal Roué 5b7006d695 Performance tips 2016-08-01 15:15:31 +02:00
Gwendal Roué cd3273bb51 Performance tips 2016-08-01 14:02:32 +02:00
Gwendal Roué 917ad5f750 Performance tips 2016-08-01 13:59:04 +02:00
Gwendal Roué 29ee22f6cc TODO: Document Statement.unsafeSetArguments (addresses #91) 2016-08-01 12:14:44 +02:00
Gwendal Roué 4ad8157ba0 TODO.md 2016-08-01 07:45:14 +02:00
Gwendal Roué 69a8bd1761 TODO.md 2016-07-31 12:38:33 +02:00
Gwendal Roué 2bdeae0ddb README.md 2016-07-31 06:26:16 +02:00
Gwendal Roué 0fb1eec3cd Row adopts DictionaryLiteralConvertible 2016-07-31 06:18:16 +02:00
Gwendal Roué 243d6ebd2c TODO.md 2016-07-31 05:48:38 +02:00
Gwendal Roué 6b2882fe47 TODO.md 2016-07-30 21:09:49 +02:00
Gwendal Roué 6ad8dc7f3e CHANGELOG.md 2016-07-30 18:13:57 +02:00
Gwendal Roué fcedab74c0 sqlcipher v3.4.0 2016-07-30 18:09:47 +02:00
Gwendal Roué 7404c642e3 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseSchemaCache.swift
	GRDB/Record/Persistable.swift
	GRDB/Record/Record.swift
	README.md
	Tests/Private/DatabasePoolSchemaCacheTests.swift
	Tests/Public/Core/Persistable/MutablePersistableTests.swift
	Tests/Public/Core/Persistable/PersistableTests.swift
	Tests/Public/Record/RecordSubClassTests.swift
2016-07-30 12:58:10 +02:00
Gwendal Roué d922961112 Remove documentation for DatabaseValue.value() 2016-07-29 09:03:40 +02:00
Gwendal Roué c679970832 README.md 2016-07-29 08:31:49 +02:00
Gwendal Roué 8393cd4b86 CHANGELOG.md 2016-07-29 03:57:25 +02:00
Gwendal Roué 42125c756e v0.77.0 2016-07-28 19:32:20 +02:00
Gwendal Roué 447df0af17 Partial update WIP: changelog 2016-07-28 19:31:02 +02:00
Gwendal Roué 38d5646975 Merge branch 'master' of github.com:groue/GRDB.swift 2016-07-28 19:28:51 +02:00
Gwendal Roué b16656bd23 Partial update WIP: cache & column case insensitivity 2016-07-28 19:28:46 +02:00
Gwendal Roué 0f987916b7 Redirect Core Data and Realm users to "How to build an iOS application with SQLite and GRDB.swift" 2016-07-28 17:03:37 +02:00
Gwendal Roué 21e419ff8a Typo 2016-07-28 10:00:10 +02:00
Gwendal Roué d2acc351a2 README.md: link to the new blog post 2016-07-28 09:59:45 +02:00
Gwendal Roué faa076c1e9 TODO.md 2016-07-28 09:09:08 +02:00
Gwendal Roué 1eac28a145 Fix typo 2016-07-28 09:07:31 +02:00
Gwendal Roué df7791a3e7 Partial update WIP: documentation 2016-07-28 09:05:46 +02:00
Gwendal Roué 176a23fe97 Partial update WIP: tests 2016-07-28 08:53:17 +02:00
Gwendal Roué 548ff068fd Partial update WIP: implementation 2016-07-28 08:41:22 +02:00
Gwendal Roué 50ce433bcb Partial update WIP: public API 2016-07-28 08:25:08 +02:00
Gwendal Roué d8ada8c9d3 TODO.md 2016-07-26 06:47:33 +02:00
Gwendal Roué f04972a902 Documentation 2016-07-25 09:00:57 +02:00
Gwendal Roué 0b2ec35324 TODO.md 2016-07-23 15:01:42 +02:00
Gwendal Roué 77278e77eb Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB/QueryInterface/QueryInterfaceRequest.swift
	GRDB/QueryInterface/SQLCollation.swift
	GRDB/QueryInterface/SQLSelectQuery.swift
2016-07-22 13:48:39 +02:00
Gwendal Roué c6f2c8a3f5 Remove dead code 2016-07-22 13:40:07 +02:00
Gwendal Roué e037972dbb Remove dead code 2016-07-22 13:38:31 +02:00
Gwendal Roué ba24c55d41 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/QueryInterface/QueryInterfaceRequest.swift
	GRDB/QueryInterface/SQLCollation.swift
	GRDB/QueryInterface/SQLSelectQuery.swift
2016-07-22 13:04:20 +02:00
Gwendal Roué 034a24dfe3 _SQLExpression.sql(_:_:) turns all values into safely escaped SQL literals when given nil arguments. (addresses #83) 2016-07-22 12:56:26 +02:00
Gwendal Roué 9f7851a178 TODO.md 2016-07-22 11:11:13 +02:00
Gwendal Roué 7ea2d7d1ab Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Core/DatabaseValueConvertible.swift
2016-07-22 10:08:48 +02:00
Gwendal Roué 8ecfb872b6 Simplify DatabaseValueConvertible.sqlLiteral 2016-07-22 10:01:36 +02:00
Gwendal Roué 2a91ab07b9 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseSchemaCache.swift
	GRDB/Core/Statement.swift
	TODO.md
	Tests/Private/RecordUniqueIndexTests.swift
2016-07-22 09:01:39 +02:00
Gwendal Roué 111d11a71b DatabaseValueConvertible.sqlLiteral returns a safely escaped SQL literal (addresses #83) 2016-07-22 08:49:35 +02:00
Gwendal Roué 6aeee05e8a Code cleanup 2016-07-22 08:18:04 +02:00
Gwendal Roué 472586e772 TODO.md 2016-07-21 19:27:39 +02:00
Gwendal Roué 4f15322cec CHANGELOG.md 2016-07-21 19:10:46 +02:00
Gwendal Roué 0e46ff2b6d Documentation 2016-07-21 19:10:41 +02:00
Gwendal Roué fcf90a053a Database.indexes(on:) and Database.table(_:hasUniqueKey:) are public 2016-07-21 19:08:27 +02:00
Gwendal Roué b9e19e84d4 TODO.md 2016-07-21 09:11:23 +02:00
Gwendal Roué 1fc60cf410 TODO.md 2016-07-21 09:09:59 +02:00
Gwendal Roué 21bc1fd5a6 TODO.md 2016-07-21 09:04:01 +02:00
Gwendal Roué 3989f0c332 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB/Record/Persistable.swift
2016-07-20 18:47:41 +02:00
Gwendal Roué 23ffef8943 Swift3: turn TableMapping.databaseTableName() into a read-only property 2016-07-20 18:38:56 +02:00
Gwendal Roué c3105fa66f Documentation 2016-07-20 14:00:25 +02:00
Gwendal Roué 8b09b2cdba Improve error messages for MutablePersistable.update(), delete() & exist() (see #81) 2016-07-20 13:49:16 +02:00
Gwendal Roué 315426a4b6 TODO.md 2016-07-19 23:40:17 +02:00
Gwendal Roué 51d948fc29 TODO.md 2016-07-19 17:29:26 +02:00
Gwendal Roué 68f4f011b7 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/QueryInterface/QueryInterfaceRequest.swift
	README.md
	Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift
2016-07-19 14:08:05 +02:00
Gwendal Roué ebdd6c5a4d Update for Xcode Version 8.0 beta 3 (8S174q) 2016-07-19 14:01:46 +02:00
Gwendal Roué deda8dcd97 CHANGELOG.md 2016-07-19 09:00:36 +02:00
Gwendal Roué f19f29a4bd v0.76.0 2016-07-19 08:54:35 +02:00
Gwendal Roué 0677a8a21a The query interface order method replaces any previously applied ordering (see #85) 2016-07-19 08:53:43 +02:00
Gwendal Roué b3c12c33b7 Merge branch 'master' into Swift3bis 2016-07-19 08:20:22 +02:00
Gwendal Roué 09f57d3bb6 TODO.md 2016-07-18 20:58:30 +02:00
Gwendal Roué 6b9b249e22 TODO.md 2016-07-18 19:24:20 +02:00
Gwendal Roué 78327f648d v0.75.2 2016-07-18 13:16:36 +02:00
Gwendal Roué df32c1c5d5 Allow SelectStatement to perform database changes - Fixes #80 and #82 for good. 2016-07-18 12:57:38 +02:00
Gwendal Roué e93f13f6b0 Remove dead documentation 2016-07-09 08:57:39 +02:00
Gwendal Roué 02d2b89a4d Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseScheduler.swift
	GRDB/Core/SerializedDatabase.swift
	GRDB/Core/Statement.swift
2016-07-08 18:30:16 +02:00
Gwendal Roué 34ff64b103 Rename DatabaseScheduler to SchedulingWatchdog 2016-07-08 18:22:34 +02:00
Gwendal Roué 827dc3da8b Cleanup 2016-07-08 18:02:06 +02:00
Gwendal Roué 1cd9c8f817 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Core/DatabaseScheduler.swift
	GRDB/Core/SerializedDatabase.swift
2016-07-08 17:52:27 +02:00
Gwendal Roué e8a9035e68 Simplify DatabaseScheduler, and let SerializedDatabase implement the serialization constraints. 2016-07-08 17:38:52 +02:00
Gwendal Roué a288c8d7fb Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB/Core/Database.swift
	GRDB/Core/RowAdapter.swift
	README.md
	Tests/Public/Core/Row/AdapterRowTests.swift
	Tests/Public/Core/Row/RowConvertibleTests.swift
2016-07-08 16:57:16 +02:00
Gwendal Roué 88e8c2ba33 #80 cleanup 2016-07-08 16:10:38 +02:00
Gwendal Roué 252ec6fe59 v0.75.1 2016-07-08 14:33:24 +02:00
Gwendal Roué e664ab18ee Fixes #80 2016-07-08 14:30:45 +02:00
Gwendal Roué b78c5b32c6 Documentation 2016-07-08 10:01:23 +02:00
Gwendal Roué 4ddc8f950e Row adapters: rename AdaptedColumnsDescription to ConcreteColumnMapping 2016-07-08 09:52:04 +02:00
Gwendal Roué 0260a33678 v0.75.0 2016-07-08 08:46:55 +02:00
Gwendal Roué 358c3ab0c3 Row adapters: rename "variants" to "scopes" 2016-07-08 08:44:41 +02:00
Gwendal Roué a658599406 Documentation fix 2016-07-07 09:15:24 +02:00
Gwendal Roué d0b1bde521 Add Cristian Filipov to the thanks section 2016-07-07 09:09:53 +02:00
Gwendal Roué b24075ca1c Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseSchemaCache.swift
	GRDB/Core/Utils.swift
	GRDB/Record/TableMapping.swift
	README.md
	Tests/Private/DatabasePoolSchemaCacheTests.swift
	Tests/Public/Encryption/EncryptionTests.swift
	Tests/Public/Record/PrimaryKeyNoneTests.swift
2016-07-07 08:41:17 +02:00
Gwendal Roué 88fb4051a4 Update playgrounds for Xcode Version 8.0 beta 2 (8S162m) 2016-07-07 08:07:30 +02:00
Gwendal Roué 0c7cff5602 Update for Xcode Version 8.0 beta 2 (8S162m) 2016-07-07 05:30:43 +02:00
Gwendal Roué f872f17d39 Fix project 2016-07-07 05:14:03 +02:00
Gwendal Roué 70917c19d1 TODO.md 2016-07-07 05:03:31 +02:00
Gwendal Roué 4353e997fc v0.74.0 2016-07-06 21:09:44 +02:00
Gwendal Roué e5bf8a8e75 Fix GRDBiOS 2016-07-06 21:09:24 +02:00
Gwendal Roué d3928b30de Typo 2016-07-06 19:31:03 +02:00
Gwendal Roué ec2bc5e8cb Typo 2016-07-06 19:30:47 +02:00
Gwendal Roué b74e3d389b #56: changelog 2016-07-06 19:29:33 +02:00
Gwendal Roué e567668346 #56: documentation 2016-07-06 19:25:43 +02:00
Gwendal Roué 6e31480ed9 #56: documentation 2016-07-06 19:18:56 +02:00
Gwendal Roué d35b65c9d2 #56: cleanup
- Dabase.indexes(tableName) returns actual indexes (no more fake index on INTEGER PRIMARY KEY column)
- Database.colums(_:uniquelyIdentifyRowsIn:) checks indexes, and primary key
- DatabaseSchemaCache caches table indexes (with invalidation on CREATE/DROP INDEX statements)
2016-07-06 19:09:25 +02:00
Gwendal Roué 0f27299586 #56: fetchOne(_:key:Dictionary) and deleteOne(_:key:Dictionary) raise a fatal error when there is no unique index on the key columns. 2016-07-06 08:39:18 +02:00
Gwendal Roué baff716ef6 #56: fetchOne(_:key:Dictionary) performs the same unique index check as deleteOne() 2016-07-06 08:18:14 +02:00
Gwendal Roué 1141676223 #56: Database.indexes(tableName) includes the implicit unique index on INTEGER PRIMARY KEY column. 2016-07-05 22:33:56 +02:00
Gwendal Roué a6ce80d39b #56: TableMapping.deleteOne(_🔑), TableMapping.deleteAll(_:keys:) 2016-07-05 22:16:23 +02:00
Gwendal Roué 6d3e0eaa22 More encryption documentation 2016-07-05 21:01:46 +02:00
Gwendal Roué 18c1333496 More encryption documentation 2016-07-05 20:59:32 +02:00
Gwendal Roué ab00d73d7a More encryption documentation 2016-07-05 20:57:40 +02:00
Gwendal Roué 5bc574025d Typo 2016-07-05 15:24:03 +02:00
Gwendal Roué 71e7d92d75 Typo 2016-07-05 14:50:22 +02:00
Gwendal Roué 723c7a97fc Typo 2016-07-05 14:41:39 +02:00
Gwendal Roué 16a3b88db5 Document how to encrypt an existing database (should help #77) 2016-07-05 14:37:28 +02:00
Gwendal Roué 19ed31a2c2 TODO.md: reconsider #56 in order to improve feature set with other ORMs 2016-07-04 11:31:38 +02:00
Gwendal Roué 93fd430863 TODO.md 2016-07-04 10:58:20 +02:00
Gwendal Roué c1ac810ff2 TODO.md 2016-07-01 09:09:06 +02:00
Gwendal Roué e785085d0d Cleanup our code thanks to DispatchQueue.sync<T>(block: @noescape () throws -> T) rethrows. 2016-06-30 18:38:16 +02:00
Gwendal Roué 334133ea61 TODO.md 2016-06-30 17:33:08 +02:00
Gwendal Roué 82b801498a Merge branch 'master' of github.com:groue/GRDB.swift into Swift3
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/DatabaseValueConvertible.swift
	GRDB/Core/Row.swift
	GRDB/Core/StatementColumnConvertible.swift
	GRDB/FetchRequest/FetchRequest.swift
	GRDB/QueryInterface/QueryInterfaceRequest.swift
	GRDB/Record/RowConvertible.swift
	README.md
	Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConvertibleFetchTests.swift
	Tests/Public/Core/SQLiteStatementConvertible/SQLiteStatementConvertibleFetchTests.swift
	Tests/Public/FetchRequest/FetchRequestTests.swift
	Tests/Public/Foundation/NSDateTests.swift
2016-06-29 13:38:24 +02:00
Gwendal Roué 83c74cf9e1 TODO.md 2016-06-28 15:04:10 +02:00
Gwendal Roué 3dc4dcf874 TODO.md 2016-06-28 14:50:59 +02:00
Gwendal Roué aaf184ddb3 Tests for StatementColumnConvertible fetching methods with adapter 2016-06-28 14:46:26 +02:00
Gwendal Roué 21e9e64b3d DatabaseValueConvertible and StatementColumnConvertible can now be fetched through a RowAdapter. DatabaseValueConvertible: raise a fatal error instead of converting to nil for invalid conversions triggered by fetch() methods. 2016-06-28 13:54:45 +02:00
Gwendal Roué 48c431c0a9 Backup clears the schema cache of the target database 2016-06-28 13:07:53 +02:00
Gwendal Roué 8992b4a284 Move FetchRequest to Core 2016-06-28 09:09:06 +02:00
Gwendal Roué c9d7da5951 TODO.md 2016-06-28 08:55:05 +02:00
Gwendal Roué f76744fc98 Typo 2016-06-23 15:59:16 +02:00
Gwendal Roué b624874768 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/Database.swift
	GRDB/Core/DatabaseWriter.swift
	GRDB/Core/Statement.swift
	GRDB/FetchRequest/QueryInterfaceRequest.swift
	GRDB/FetchRequest/SQLCollation.swift
	GRDB/FetchRequest/SQLSelectQuery.swift
	GRDB/Record/FetchedRecordsController.swift
	README.md
	Tests/Private/StatementInformationTests.swift
	Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConversionTests.swift
	Tests/Public/Core/SQLiteStatementConvertible/SQLiteStatementConversionTests.swift
2016-06-21 09:03:02 +02:00
Gwendal Roué ed84727938 v0.73.0 2016-06-20 22:55:28 +02:00
Gwendal Roué 10f8318883 README.md 2016-06-20 22:50:50 +02:00
Gwendal Roué 7dd7f1a32c README.md 2016-06-20 22:47:34 +02:00
Gwendal Roué a06fa75419 TODO.md 2016-06-20 22:39:48 +02:00
Gwendal Roué 7e0ca09bf7 NSUUID documentation 2016-06-20 22:38:13 +02:00
Gwendal Roué cae3d7b321 Support for NSUUID 2016-06-20 22:37:31 +02:00
Gwendal Roué 1c30a93da1 README.md 2016-06-20 21:05:28 +02:00
Gwendal Roué 03d30d7f99 CHANGELOG.md 2016-06-20 21:03:25 +02:00
Gwendal Roué 6e4aecb3dc README.md 2016-06-20 20:50:49 +02:00
Gwendal Roué 660d01c59a CHANGELOG.md 2016-06-20 20:44:28 +02:00
Gwendal Roué 81cccadf80 Database event filtering documentation 2016-06-20 20:41:20 +02:00
Gwendal Roué e0ea5af18e Refactor database events filtering 2016-06-20 20:38:31 +02:00
Gwendal Roué 4544759cff CHANGELOG.md 2016-06-20 15:23:43 +02:00
Gwendal Roué 6a466fcb12 Detailed database changes observation 2016-06-20 15:21:14 +02:00
Gwendal Roué a07c09b3d4 TODO.md 2016-06-20 10:14:10 +02:00
Gwendal Roué 2c3bee16c9 TODO.md 2016-06-19 12:04:26 +02:00
Gwendal Roué 9a397c1ff8 Emoji tests 2016-06-19 11:14:11 +02:00
Gwendal Roué c627363fca Update TODO.md 2016-06-19 07:30:44 +02:00
Gwendal Roué 219899fc9b Query Interface arguments to SQL snippets 2016-06-18 14:49:17 +02:00
Gwendal Roué d987d99913 TODO.md 2016-06-16 09:17:24 +02:00
Gwendal Roué 985c32510c Documentation 2016-06-16 09:14:55 +02:00
Gwendal Roué 01ab19a263 README.md 2016-06-16 09:11:08 +02:00
Gwendal Roué 0ba6d5de28 Typo 2016-06-16 09:10:23 +02:00
Gwendal Roué e6031addf5 README.md 2016-06-15 15:29:06 +02:00
Gwendal Roué 8845babb28 Documentation 2016-06-15 06:48:28 +02:00
Gwendal Roué ed34a59a0c Swift3 typo 2016-06-15 06:47:00 +02:00
Gwendal Roué 767cd877b8 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	README.md
2016-06-15 06:43:47 +02:00
Gwendal Roué fd7c4a0653 Typo 2016-06-15 06:41:56 +02:00
Gwendal Roué 26f08a59ad Documentation 2016-06-15 06:36:41 +02:00
Gwendal Roué 841b6f68dd Swift3 typo 2016-06-15 06:15:40 +02:00
Gwendal Roué dbe835912a .Rollback is .rollback in Swift3 2016-06-15 06:14:29 +02:00
Gwendal Roué 6b9182645d Fix link to DatabaseValue documentation 2016-06-14 21:13:03 +02:00
Gwendal Roué 16c1ca0bba Fix link to DatabaseValue documentation 2016-06-14 21:12:55 +02:00
Gwendal Roué 181aea9aec Support for URL 2016-06-14 21:09:11 +02:00
Gwendal Roué 422971d229 Link to Swift3 branch 2016-06-14 20:42:55 +02:00
Gwendal Roué 2010a3169d Describe the Swift3 branch 2016-06-14 20:41:22 +02:00
Gwendal Roué 397b538c9d Update README.md for Xcode 8 2016-06-14 20:34:01 +02:00
Gwendal Roué 1d1d843dc7 Xcode 8 WIP 2016-06-14 20:05:13 +02:00
Gwendal Roué abd6fe9f2d Xcode 8 WIP 2016-06-14 19:48:46 +02:00
Gwendal Roué f5db3c08e3 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Core/RowAdapter.swift
	GRDB/Core/Support/Foundation/NSNumber.swift
	README.md
	Tests/Public/Core/Row/RowConvertibleTests.swift
	Tests/Public/FetchRequest/FetchRequestTests.swift
2016-06-14 19:42:21 +02:00
Gwendal Roué 0b568b2d28 Documentation 2016-06-14 19:23:36 +02:00
Gwendal Roué 42885a3df0 Xcode 8 WIP 2016-06-14 19:14:10 +02:00
Gwendal Roué cd820c2dbe Xcode 8 WIP 2016-06-14 19:06:53 +02:00
Gwendal Roué 0944ed331b Xcode 8 WIP 2016-06-14 14:04:04 +02:00
Gwendal Roué f45b9a3757 Xcode 8 WIP 2016-06-14 13:45:08 +02:00
Gwendal Roué d52c552721 Xcode 8 WIP 2016-06-14 12:51:33 +02:00
Gwendal Roué 2a5bdbcbdc BROKEN - Xcode 8 WIP 2016-06-14 09:08:43 +02:00
Gwendal Roué 2606f7196e SuffixRowAdapter index preconditions 2016-06-09 09:11:44 +02:00
Gwendal Roué 09a672561d Update error handling documentation 2016-06-09 08:53:16 +02:00
Gwendal Roué cbabdf02de Update error handling documentation 2016-06-09 08:51:20 +02:00
Gwendal Roué a65d7cdc15 Documentation fix 2016-06-09 08:30:19 +02:00
Gwendal Roué 1a17efcf8e Documentation fix 2016-06-09 08:28:17 +02:00
Gwendal Roué 9f60d63a6b v0.72.0 2016-06-09 08:01:30 +02:00
Gwendal Roué 4426166f1d RowAdapter documentation 2016-06-09 07:54:34 +02:00
Gwendal Roué d97ceeaa6c RowAdapter documentation 2016-06-09 07:50:37 +02:00
Gwendal Roué a7ac615bb2 Merge branch 'master' into RowAdapter2 2016-06-09 07:33:42 +02:00
Gwendal Roué 90fc23205c Cleanup 2016-06-09 06:21:39 +02:00
Gwendal Roué c233fec9b9 CHANGELOG.md 2016-06-08 23:23:08 +02:00
Gwendal Roué a8df726bff NSDecimalNumber.databaseValue only returns a double when the decimal number does not contain an integer that fits in Int64. 2016-06-08 23:14:49 +02:00
Gwendal Roué ff3f26f935 Merge branch 'master' of github.com:groue/GRDB.swift into RowAdapter2 2016-06-08 20:54:59 +02:00
Gwendal Roué a882a5f346 RowAdapter documentation 2016-06-08 20:54:25 +02:00
Gwendal Roué 1b318154c2 TODO.md 2016-06-08 10:38:39 +02:00
Gwendal Roué 390cf44a88 RowAdapter documentation 2016-06-08 09:00:22 +02:00
Gwendal Roué 3e71253ffb RowAdapter documentation 2016-06-08 08:17:37 +02:00
Gwendal Roué 748e2a81ad RowAdapter documentation 2016-06-08 08:03:35 +02:00
Gwendal Roué d3ebe43cbd RowAdapter refactoring 2016-06-08 06:41:37 +02:00
Gwendal Roué 7a13b9c4b7 More RowAdapter tests 2016-06-08 06:20:27 +02:00
Gwendal Roué 15f9aabaf0 SuffixRowAdapter 2016-06-07 22:18:13 +02:00
Gwendal Roué c617a8f354 RowAdapter refactoring 2016-06-07 21:44:32 +02:00
Gwendal Roué 6ac2cd4686 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	DemoApps/GRDBDemoiOS7/GRDBDemoiOS7/AppDatabase.swift
	DemoApps/GRDBDemoiOS7/GRDBDemoiOS7/Person.swift
	DemoApps/GRDBDemoiOS7/GRDBDemoiOS7/PersonEditionViewController.swift
	DemoApps/GRDBDemoiOS7/GRDBDemoiOS7/PersonsViewController.swift
	GRDB/Core/Support/Foundation/NSNumber.swift
	GRDB/Core/Support/StandardLibrary/StandardLibrary.swift
	GRDB/Record/FetchedRecordsController.swift
	Tests/Public/Core/DatabaseValueConvertible/NSNumberTests.swift
	Tests/Public/FetchedRecordsController/FetchedRecordsControllerTests.swift
2016-06-07 19:01:08 +02:00
Gwendal Roué 2833da3b2d README.md 2016-06-07 09:09:42 +02:00
Gwendal Roué 8058a79ed0 README.md 2016-06-07 09:07:42 +02:00
Gwendal Roué 93755a62aa Typo 2016-06-07 09:01:27 +02:00
Gwendal Roué d4c7e00a19 README.md 2016-06-07 07:58:55 +02:00
Gwendal Roué 70deb7b388 Merge pull request #70 from schveiguy/patch-1
Add description of rollback without throwing error
2016-06-06 21:18:01 +02:00
Steven Schveighoffer c229439dec Add description of rollback without throwing error 2016-06-06 15:13:42 -04:00
Gwendal Roué cb2dda8421 README.md 2016-06-06 07:47:07 +02:00
Gwendal Roué 4558321ef7 v0.71.0 2016-06-05 16:45:34 +02:00
Gwendal Roué 9376f048be TODO.md 2016-06-05 16:45:27 +02:00
Gwendal Roué d038227941 #62: Don’t share GRDBCustomSQLite schemes (avoid messing with Carthage) 2016-06-05 16:43:00 +02:00
Gwendal Roué 2c885cb347 Document when it is safe to use unowned references in a FetchedRecordsController's callbacks 2016-06-05 16:03:40 +02:00
Gwendal Roué 01bf13189c Documentation 2016-06-05 15:59:41 +02:00
Gwendal Roué f92d433a3e Test for FetchedRecordsController.trackChanges(fetchAlongside:) 2016-06-05 15:35:05 +02:00
Gwendal Roué 25476f2973 Drop the unmaintained GRDBDemoiOS7 app 2016-06-05 15:06:51 +02:00
Gwendal Roué 1d4bff1add #68: conversion error messages contain the "database" word. 2016-06-05 14:57:07 +02:00
Gwendal Roué 30864a16a2 #68: numeric overflow error messages contain the faulty value 2016-06-05 14:02:28 +02:00
Gwendal Roué 7b492fe7ed CHANGELOG.md 2016-06-05 13:52:46 +02:00
Gwendal Roué 7186c9a3a0 #68: take care of Int, Int32 and Int64 overflow when converting from database values 2016-06-05 13:49:47 +02:00
Gwendal Roué a5760a7462 #68: NSNumber.databaseValue raises explicit fatal error when value doesn’t fit Int64 2016-06-05 12:16:37 +02:00
Gwendal Roué aa5c6283a7 #68: document NSNumber limits 2016-06-04 19:09:51 +02:00
Gwendal Roué 280955801c CHANGELOG.md 2016-06-04 18:41:11 +02:00
Gwendal Roué adc3f6d184 TODO.md 2016-06-04 18:41:07 +02:00
Gwendal Roué c9ebb6da00 FetchedRecordsController:
- make unowned references in the callbacks safe, as long as the unowned object is deallocated in the fetched records controller’s queue (usually the main queue).
- FetchedRecordsController.trackChanges(fetchAlong: { db in … }, …) allows the user to fetch values that are consistent with the fetched records.
2016-06-04 18:24:49 +02:00
Gwendal Roué a8f04a1ba5 GRDBDemoiOS: stress fetched records controller longer, so that we can check what happens when one leaves the table view controller as transactions are still running. Answer: we crash due to [unowned self] references being used after table view controller has been deallocated. 2016-06-04 18:22:18 +02:00
Gwendal Roué d478e4b1f4 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis 2016-06-04 12:39:27 +02:00
Gwendal Roué ac9b2e8ba4 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis 2016-06-04 12:10:36 +02:00
Gwendal Roué 770ee6aaec Merge pull request #69 from swiftlyfalling/fix-preupdate-hook-uninstall
Added missing call to uninstall the preupdate hook
2016-06-03 18:59:07 +02:00
swiftlyfalling 003a6ef4d2 Added missing call to uninstall the preupdate hook 2016-06-03 12:45:28 -04:00
Gwendal Roué f9e43fae29 Merge pull request #66 from swiftlyfalling/test-coverage-improvements
Test coverage improvements
2016-06-03 14:47:25 +02:00
swiftlyfalling 7e1eb5a970 Increase test coverage of DatabaseQueue 2016-06-03 08:36:25 -04:00
swiftlyfalling f231218a69 Increase test coverage of DatabaseValue.swift 2016-06-03 08:35:56 -04:00
swiftlyfalling e21c9cb8f0 Revert "Increase test coverage of DatabaseValue.swift"
This reverts commit 58084c6a65.
2016-06-03 08:35:04 -04:00
swiftlyfalling 8597808a61 Revert "Increase test coverage of DatabaseQueue"
This reverts commit 5ffac12f5b.
2016-06-03 08:34:41 -04:00
Gwendal Roué 1871eed0ab TODO.md 2016-06-03 10:49:38 +02:00
Gwendal Roué 8f2685b335 Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB/Core/Database.swift
2016-06-03 08:44:27 +02:00
Gwendal Roué cd85b54dd7 #63 follow-up: let DatabaseEventType dispatch events to the correct TransactionObserver method so that we avoid runtime checks on events type 2016-06-03 08:37:53 +02:00
Gwendal Roué 6dd04142b3 #63 follow-up: remove DatabaseEventType from public API 2016-06-03 08:31:17 +02:00
Gwendal Roué 0618054968 Thank @swiftlyfalling 2016-06-03 08:24:47 +02:00
Gwendal Roué e11673d15c Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts:
	GRDB/Core/Database.swift
	GRDB/FetchRequest/SQLSelectQuery.swift
	GRDB/Record/FetchedRecordsController.swift
	GRDB/Record/TableMapping.swift
	Tests/Public/Core/Persistable/MutablePersistableTests.swift
	Tests/Public/Core/Persistable/PersistableTests.swift
	Tests/Public/Core/Savepoint/SavepointTests.swift
	Tests/Public/Core/TransactionObserver/TransactionObserverSavepointsTests.swift
	Tests/Public/Core/TransactionObserver/TransactionObserverTests.swift
2016-06-03 05:17:11 +02:00
swiftlyfalling 066a4de15f Added tests
For:
- NSNull.swift
- NSNumber.swift
- NSString.swift
- NSURL.swift
- DatabaseValue+Foundation.swift
2016-06-02 19:25:42 -04:00
swiftlyfalling 5ffac12f5b Increase test coverage of DatabaseQueue 2016-06-02 18:20:08 -04:00
swiftlyfalling b24631345b Increase test coverage of NSData.swift 2016-06-02 18:08:28 -04:00
swiftlyfalling ab3332ed8f Add test of removeTransactionObserver() 2016-06-02 18:07:42 -04:00
swiftlyfalling 58084c6a65 Increase test coverage of DatabaseValue.swift 2016-06-02 18:06:35 -04:00
swiftlyfalling 6664733650 Increase test coverage of FetchRequest.swift
Existing DatabaseValueConvertible tests were only testing the
`extension DatabaseValueConvertible where Self:
StatementColumnConvertible` cases.

Added tests to explicitly cover the cases where something conforms to
`DatabaseValueConvertible` but *not* `StatementColumnConvertible`, and
renamed the old tests.
2016-06-02 18:05:31 -04:00
swiftlyfalling f7a537ab91 Increase test coverage of DatabaseCoder.swift
Test failure cases.
2016-06-02 18:02:08 -04:00
swiftlyfalling 0506d47a4f Increase test coverage of DatabaseDateComponents.swift
Test init from nil NSDateComponents case.
2016-06-02 18:01:31 -04:00
swiftlyfalling e06bcab62b Increase test coverage of Row+Foundation.swift
Add missing test to verify initialization failure if NSDictionary has
invalid (non-String) keys.
2016-06-02 18:01:13 -04:00
swiftlyfalling 90061a4b25 Increase test coverage of StatementArguments+Foundation.swift
Test initializing failure from invalid NSArray, NSDictionary.
2016-06-02 17:59:47 -04:00
Gwendal Roué 5a17fa53cd More TODO 2016-06-02 20:48:57 +02:00
Gwendal Roué 88c284dbf1 Merge branch 'master' into Swift3bis
Conflicts:
	GRDB/Core/Database.swift
	GRDB/FetchRequest/QueryInterfaceRequest.swift
	GRDB/FetchRequest/SQLCollation.swift
	GRDB/FetchRequest/SQLFunction.swift
	GRDB/FetchRequest/SQLOperator.swift
	GRDB/FetchRequest/SQLSelectQuery.swift
	README.md
2016-06-02 20:47:04 +02:00
Gwendal Roué dd98fdbee1 SE-0059: Update API Naming Guidelines and Rewrite Set APIs Accordingly 2016-06-02 20:16:26 +02:00
Gwendal Roué af43079e33 SE-0032: Add first(where:) method to Sequence 2016-06-02 20:10:31 +02:00
Gwendal Roué aa6097dff8 swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a 2016-06-02 19:58:58 +02:00
Gwendal Roué 7fa4346cd1 Merge pull request #65 from swiftlyfalling/patch-1
Add language, platform, and license badges to README.md
2016-06-02 15:30:49 +02:00
swiftlyfalling d286041e04 Add language, platform, and license badges to README.md 2016-06-02 09:05:13 -04:00
Gwendal Roué bf0f9e1fa2 Merge pull request #63 from swiftlyfalling/preupdate-hooks
Add support for SQLite Pre-Update Hooks (+ tests)
2016-06-02 13:29:26 +02:00
Gwendal Roué d4c0dd824b Merge pull request #64 from swiftlyfalling/fix-slow-compile
Slow compilation fixes
2016-06-02 13:05:26 +02:00
Gwendal Roué 528ce8c9de README.md 2016-06-02 08:38:55 +02:00
Gwendal Roué 7c4ff7677d swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a 2016-06-02 08:38:15 +02:00
Gwendal Roué cb36991cb2 Cleanup Query Interface protocols 2016-06-02 08:09:44 +02:00
swiftlyfalling f15a4df79e Slow compilation fixes
Implemented a workaround for the cause of the two slowest-to-compile
methods.
2016-06-01 21:12:33 -04:00
swiftlyfalling 901b7a0f12 Add support for SQLite Pre-Update Hooks (+ tests)
If SQLITE_ENABLE_PREUPDATE_HOOK is defined, and GRDB is built with a
custom SQLite library with the functionality (see: GRDBCustomSQLite),
enable support for SQLite Pre-Update Hooks and the new
`willChangeWithEvent` callback on TransactionObservers.
2016-06-01 20:42:21 -04:00
Gwendal Roué 687bcc3469 Merge pull request #62 from swiftlyfalling/Custom-SQLite
Add GRDBCustomSQLite to permit easily building GRDB with a custom, embedded SQLite library
2016-06-01 12:21:38 +02:00
Gwendal Roué a239e435a6 More transaction/savepoints documentation 2016-06-01 09:31:41 +02:00
Gwendal Roué 75728418af More savepoints documentation 2016-06-01 09:28:57 +02:00
swiftlyfalling 893714c968 Update README 2016-05-31 20:42:35 -04:00
swiftlyfalling 5cb4044408 Merge remote-tracking branch 'groue/master' into Custom-SQLite 2016-05-31 17:33:59 -04:00
swiftlyfalling 4966ce447f Add missing Target Dependency for GRDBCustomSQLite frameworks. 2016-05-31 17:33:04 -04:00
swiftlyfalling 8213bf5b6d Update to point to SQLiteLib-USER.xcconfig, and new SQLiteLib 2016-05-31 17:32:09 -04:00
swiftlyfalling 280d90cdc4 More tweaks to GRDBCustomSQLite run script phase 2016-05-31 09:39:42 -04:00
Gwendal Roué df5a327da4 Top-level Database.inSavepoint opens a transaction if the default transaction kind is not DEFERRED 2016-05-31 13:09:33 +02:00
Gwendal Roué e736923312 Typo 2016-05-31 12:14:49 +02:00
Gwendal Roué fe4f932be4 README.md 2016-05-31 09:08:25 +02:00
Gwendal Roué fe7e39776b Documentation 2016-05-31 06:49:35 +02:00
Gwendal Roué da33e480c3 Improve Database.execute() detection of white-space string endings 2016-05-31 06:47:44 +02:00
swiftlyfalling 19a0a7098d Add GRDBCustomSQLite USER configuration files to .gitignore 2016-05-30 21:56:04 -04:00
swiftlyfalling 74d46f201a Tweaks to GRDBCustomSQLite run script build phase 2016-05-30 21:54:07 -04:00
swiftlyfalling 0eec061d01 Improve first-time build of GRDBCustomSQLite
Define CUSTOM_OTHER_SWIFT_FLAGS in GRDB.xcconfig prior to including the
"GRDBCustomSQLite-USER.xcconfig" file.
2016-05-30 21:52:55 -04:00
swiftlyfalling 7c1ad9abab Updated .example files 2016-05-30 21:51:42 -04:00
swiftlyfalling 3ad99011f2 Remove User xcconfig from branch. 2016-05-30 21:17:37 -04:00
swiftlyfalling cb8331f213 Renamed customizable files to <file>-USER, added .example files, preserve user customizations.
Added .example files.
Added build phase script to copy .example files if user configuration
files are not already present.
2016-05-30 21:16:36 -04:00
swiftlyfalling ffa2858d82 Update SQLiteLib subproject commit 2016-05-30 19:56:05 -04:00
swiftlyfalling 1cf20da416 Add README for GRDBCustomSQLite 2016-05-30 19:39:11 -04:00
swiftlyfalling 30bc7e4f6c Replace most uses of #if SQLITE_HAS_CODEC with the appropriate USING_BUILTIN_SQLITE or USING_SQLCIPHER defines.
This enables easier compilation of a custom version of SQLite that
itself uses the SQLITE_HAS_CODEC define. (ex. If building SQLite with
the SQLite Encryption Extension.)
The SQLITE_HAS_CODEC define is now only used to guard use of the SQLite
encryption APIs.
GRDBCipher builds define USING_BUILTIN_SQLITE and USING_SQLCIPHER.
2016-05-30 18:19:45 -04:00
swiftlyfalling 9f406c6725 Add GRDBCustomSQLite targets and schemes.
To support building GRDB with a built-in custom SQLite build/version.
2016-05-30 18:16:04 -04:00
swiftlyfalling b1ff790e43 Add SQLiteLib submodule 2016-05-30 16:05:53 -04:00
Gwendal Roué 90f304a881 Typo 2016-05-30 12:33:42 +02:00
Gwendal Roué 99cbfa13cb v0.70.1 2016-05-30 12:27:42 +02:00
Gwendal Roué ce7736a4b8 Failed statements can not be reused: remove them from the statement cache. 2016-05-30 12:21:20 +02:00
Gwendal Roué c36ed7b660 Add failing test for Persistable.insert() after a previous failed insert. 2016-05-30 12:20:42 +02:00
Gwendal Roué d6c4705626 Fix documentation 2016-05-30 08:34:27 +02:00
Gwendal Roué 9df4455f07 Minor 2016-05-30 08:22:00 +02:00
Gwendal Roué 5e4923b5bc More tests and documentation for DatabaseScheduler 2016-05-30 08:10:39 +02:00
Gwendal Roué 9d00189ac0 Inner Documentation 2016-05-30 07:46:40 +02:00
Gwendal Roué 3af2d7c0df Inner Documentation 2016-05-29 20:03:33 +02:00
Gwendal Roué 521222ad19 Typo 2016-05-29 16:30:38 +02:00
Gwendal Roué e0f5a1c1a1 FetchedRecordsController: document that callbacks are invoked asynchronously 2016-05-29 15:45:35 +02:00
Gwendal Roué fa393a53b2 FetchedRecordsController: document that callbacks are invoked asynchronously 2016-05-29 15:44:21 +02:00
Gwendal Roué 43e81781a3 FetchedRecordsController documentation 2016-05-29 15:32:30 +02:00
Gwendal Roué b03e9922a4 FetchedRecordsController: document record identity where it is needed, for table view updates. 2016-05-29 15:29:45 +02:00
Gwendal Roué 7206e46377 Relax FetchedRecordsController compareRecordsByPrimaryKey initializer argument by only requiring TableMapping protocol 2016-05-29 15:28:50 +02:00
Gwendal Roué 554b9a03b5 FetchedRecordsController: avoid instantiate records when building table view updates 2016-05-29 15:20:17 +02:00
Gwendal Roué 20278d23e1 CHANGELOG.md 2016-05-28 21:45:48 +02:00
Gwendal Roué 81607da632 CHANGELOG.md 2016-05-28 21:45:21 +02:00
Gwendal Roué c1ec74a5b7 v0.70.0 2016-05-28 21:18:08 +02:00
Gwendal Roué eaed0c098b Issue #61: document interaction between Transaction observers and save points. 2016-05-28 21:11:52 +02:00
Gwendal Roué 886fb6b5a1 Typo 2016-05-28 21:07:54 +02:00
Gwendal Roué 9fe92bc669 Issue #61: Savepoint documentation 2016-05-28 21:05:56 +02:00
Gwendal Roué 098e9fee8c Issue #61: TODO 2016-05-28 20:40:51 +02:00
Gwendal Roué 1d0f670100 Issue #61: more savepoint tests 2016-05-28 20:39:27 +02:00
Gwendal Roué ee7f505cde Issue #61: add savepoint sanity check 2016-05-28 20:39:02 +02:00
Gwendal Roué 4581850b05 Issue #61: since savepoint names can be reused and nested, there is no purpose forcing the user to name them: use a single default savepoint name. And provide thorough testing. 2016-05-28 18:57:07 +02:00
Gwendal Roué bc757016af Issue #61: Database.inSavepoint(named:) 2016-05-28 18:46:12 +02:00
Gwendal Roué d3259a8430 v0.69.0 2016-05-28 16:37:55 +02:00
Gwendal Roué d57107ca2a Issue #61: document interaction between Transaction observers and save points. 2016-05-28 16:29:29 +02:00
Gwendal Roué 2cf606bdbd Issue #61: pass all tests for TransactionObserver and savepoints :-) 2016-05-28 15:59:20 +02:00
Gwendal Roué 32cd559379 Issue #61: fix failing test for TransactionObserver and savepoints 2016-05-28 15:57:32 +02:00
Gwendal Roué ad8551b746 Issue #61: fix failing test for TransactionObserver and savepoints 2016-05-28 15:54:26 +02:00
Gwendal Roué a26bef8813 Issue #61: failing test for TransactionObserver with several identically named savepoints 2016-05-28 15:09:56 +02:00
Gwendal Roué 34dad07393 Issue #61: failing test for Database.isInsideTransaction after a SAVEPOINT statement 2016-05-28 15:03:02 +02:00
Gwendal Roué 5453aec1d0 Issue #61: fix failing test for TransactionObserver and savepoints 2016-05-28 15:00:26 +02:00
Gwendal Roué 03a5671bb0 Issue #61: prevent SelectStatement from hiding the update statements we track 2016-05-28 14:51:54 +02:00
Gwendal Roué 37c16fbb48 Issue #61: recognize savepoints statements 2016-05-28 14:44:37 +02:00
Gwendal Roué 92431f20d7 Issue #61: DatabaseEvent.copy() returns an event that can outlive a transaction observer’s databaseDidChangeWithEvent callback. 2016-05-28 14:27:25 +02:00
Gwendal Roué 9b6b66d22d Issue #61: fix failing test for TransactionObserver and savepoints 2016-05-28 14:25:39 +02:00
Gwendal Roué 83477c67d7 Issue #61: failing tests for TransactionObserver and savepoints 2016-05-28 13:59:15 +02:00
Gwendal Roué ac31392b90 Issue #61: test TransactionObserver with a simple savepoint 2016-05-28 13:42:48 +02:00
Gwendal Roué 201485eed6 v0.68.0 2016-05-28 13:05:17 +02:00
Gwendal Roué 87992f9e75 Issue #60: PrimaryKey documentation 2016-05-28 12:56:19 +02:00
Gwendal Roué 0b24721b4a Issue #60: Cached statements documentation 2016-05-28 12:51:31 +02:00
Gwendal Roué 8d540751e1 Issue #60: PrimaryKey documentation 2016-05-28 12:03:58 +02:00
Gwendal Roué fc8b2ee679 Issue #60: make cachedUpdateStatement() and cachedSelectStatement() public 2016-05-25 08:55:05 +02:00
Gwendal Roué bc512e775c Issue #60: make PrimaryKey public 2016-05-25 08:41:54 +02:00
Gwendal Roué 7b9d54183c Fix RowAdapter documentation 2016-05-23 19:19:14 +02:00
Gwendal Roué 85d640c4f8 CHANGELOG.md 2016-05-22 20:49:05 +02:00
Gwendal Roué a0275aa413 v0.67.0 2016-05-22 20:39:33 +02:00
Gwendal Roué 7d1c4a9991 TODO.md 2016-05-22 20:27:33 +02:00
Gwendal Roué ade05d5d1b Merge branch 'master' into RowAdapter 2016-05-22 20:26:45 +02:00
Gwendal Roué 6e259f9a0e Rename SQLRequest to SQLFetchRequest 2016-05-22 20:21:30 +02:00
Gwendal Roué 02a21b8050 FetchRequest documentation 2016-05-22 20:18:49 +02:00
Gwendal Roué 5fe7c5d888 FetchRequest tests 2016-05-22 20:16:17 +02:00
Gwendal Roué 1ee4437970 Fix Row.fetch(db, request) and RowConvertible.fetch(db, request) by using the request’s adapter. 2016-05-22 19:55:57 +02:00
Gwendal Roué a8cebfe06c TODO.md 2016-05-22 19:38:54 +02:00
Gwendal Roué 0b73275933 maximumReaderCount documentation 2016-05-22 19:38:49 +02:00
Gwendal Roué 04fec2c2f0 More RowAdapter use case 2016-05-21 17:45:45 +02:00
Gwendal Roué ccd560cbc6 More RowAdapter use case 2016-05-21 17:44:37 +02:00
Gwendal Roué 43df7f18be Fix typo 2016-05-21 17:42:48 +02:00
Gwendal Roué 2f18d1ff8b Merge branch 'master' into RowAdapter
Conflicts:
	GRDB/Record/FetchedRecordsController.swift
2016-05-21 16:03:45 +02:00
Gwendal Roué 6c816bfdeb Minor 2016-05-21 16:01:22 +02:00
Gwendal Roué afa8cfce5e Minor 2016-05-21 15:43:27 +02:00
Gwendal Roué 49ad4bdb26 v0.66.0 2016-05-21 15:15:03 +02:00
Gwendal Roué e76e8b1404 CHANGELOG.md 2016-05-21 15:13:17 +02:00
Gwendal Roué 9794b72607 Fixes #55 2016-05-21 15:08:16 +02:00
Gwendal Roué 997a29e70b Fixes #58 2016-05-21 12:15:36 +02:00
Gwendal Roué a478a1c888 RowAdapter documentation 2016-05-21 11:48:31 +02:00
Gwendal Roué 5db11aa49a RowAdapter documentation 2016-05-21 11:48:01 +02:00
Gwendal Roué 24a650f562 RowAdapter documentation 2016-05-21 11:46:14 +02:00
Gwendal Roué a1d9bf297f RowAdapter documentation 2016-05-21 08:28:10 +02:00
Gwendal Roué 92682cb11f RowAdapter documentation 2016-05-21 08:26:39 +02:00
Gwendal Roué b51b02b1d3 RowAdapter documentation 2016-05-21 08:26:13 +02:00
Gwendal Roué df410d2444 RowAdapter documentation 2016-05-21 08:24:39 +02:00
Gwendal Roué ec07380055 RowAdapter documentation 2016-05-21 08:19:15 +02:00
Gwendal Roué 3a766cd826 RowAdapter documentation 2016-05-21 08:18:17 +02:00
Gwendal Roué eef7fa5b40 RowAdapter documentation 2016-05-21 08:09:40 +02:00
Gwendal Roué eb726e47c3 RowAdapter documentation 2016-05-21 08:07:20 +02:00
Gwendal Roué 5378cd07bf RowAdapter documentation 2016-05-20 23:37:11 +02:00
Gwendal Roué d8b935369b RowAdapter refactoring 2016-05-20 21:57:39 +02:00
Gwendal Roué 4e2f396b4a RowAdapter refactoring 2016-05-20 21:00:50 +02:00
Gwendal Roué 34c43a2bbe TODO.md 2016-05-20 16:51:42 +02:00
Gwendal Roué f7fddbc162 RowAdapter TODO 2016-05-20 15:55:49 +02:00
Gwendal Roué 4c2a53ac26 Issue #50: More MappedRowTests 2016-05-20 15:53:57 +02:00
Gwendal Roué ffe1021c2a TODO.md 2016-05-20 14:35:23 +02:00
Gwendal Roué 3fcbcb9455 Merge branch 'master' into RowAdapter
Conflicts:
	TODO.md
2016-05-20 10:56:02 +02:00
Gwendal Roué 19fbce4479 Configuration.maximumReaderCount documentation 2016-05-20 10:17:53 +02:00
Gwendal Roué b2e0874efa Configuration.maximumReaderCount documentation 2016-05-20 10:17:12 +02:00
Gwendal Roué ca81422c4b Issue #53: update FAQ entry for the Generic parameter 'T' could not be inferred error 2016-05-20 08:23:24 +02:00
Gwendal Roué 6bdf433e95 Issue #53: add a FAQ entry for the Generic parameter 'T' could not be inferred error 2016-05-20 08:19:39 +02:00
Gwendal Roué daba5b2102 Merge branch 'master' into RowAdapter
Conflicts:
	GRDB.xcodeproj/project.pbxproj
	GRDB/Record/FetchedRecordsController.swift
	TODO.md
2016-05-19 20:40:26 +02:00
Gwendal Roué 9dbf992c40 Configuration.maximumReaderCount replaces DatabasePool initializer option 2016-05-19 18:10:36 +02:00
Gwendal Roué 7772749e88 Fix DatabaseQueueTests for GRDBCipher tests 2016-05-19 15:28:56 +02:00
Gwendal Roué 0c0fd48700 v0.65.0 2016-05-19 14:19:46 +02:00
Gwendal Roué 41f2cdc6e6 Documentation 2016-05-19 14:08:21 +02:00
Gwendal Roué cf572ea931 Documentation 2016-05-19 14:03:41 +02:00
Gwendal Roué da372fbb93 TODO.md 2016-05-19 14:01:51 +02:00
Gwendal Roué 92e1336db0 Fix issue #54 2016-05-19 14:00:45 +02:00
Gwendal Roué a9d3dffd3c Failing test for issue #54 2016-05-19 13:57:25 +02:00
Gwendal Roué 5fac4abc07 Use FetchRequest instead of QueryInterfaceRequest where relevant 2016-05-19 13:35:45 +02:00
Gwendal Roué 28a795eddb Rename FetchRequestType to FetchRequest 2016-05-19 13:09:30 +02:00
Gwendal Roué 06b824928b Rename FetchRequest to QueryInterfaceRequest 2016-05-19 13:08:48 +02:00
Gwendal Roué 5b57707b86 Rename FetchRequest to QueryInterfaceRequest 2016-05-19 13:08:36 +02:00
Gwendal Roué a348febf3e Introduce FetchRequestType 2016-05-19 12:23:58 +02:00
Gwendal Roué 7f8a7ac628 TODO.md 2016-05-19 11:02:50 +02:00
Gwendal Roué a5fab4e0f6 TODO.md 2016-05-19 10:56:40 +02:00
Gwendal Roué 2724e90981 README.md 2016-05-19 09:14:13 +02:00
Gwendal Roué 26fc80213e README.md 2016-05-19 09:10:24 +02:00
Gwendal Roué 47890fa74e TODO.md 2016-05-19 09:08:05 +02:00
Gwendal Roué 49b35a9216 More failing tests for issue #53 2016-05-19 09:05:12 +02:00
Gwendal Roué a08bbbad29 Failing tests for issue #53 2016-05-19 09:02:20 +02:00
Gwendal Roué 3b93cf8e28 Issue #50: More MappedRowTests 2016-05-19 08:32:34 +02:00
Gwendal Roué 75258afb6c Issue #50: Tests for FetchedRecordsController(...:adapter:) 2016-05-19 08:26:28 +02:00
Gwendal Roué fca37601dd Issue #50: Tests for RowConvertible.fetch(…:adapter:) 2016-05-19 06:37:56 +02:00
Gwendal Roué 55301efa3e Issue #50: FetchedRecordsController(…:adapter:) 2016-05-19 06:03:22 +02:00
Gwendal Roué 82052848ee Issue #50: RowConvertible.fetch(…:adapter:) 2016-05-19 05:55:42 +02:00
Gwendal Roué 25dd52fdda Documentation 2016-05-19 05:55:06 +02:00
Gwendal Roué c891c3cff8 Merge branch 'master' into RowAdapter 2016-05-19 05:40:15 +02:00
Gwendal Roué 917e75050e Merge branch 'master' into RowAdapter
Conflicts:
	GRDB/Core/Row.swift
2016-05-19 05:35:20 +02:00
Gwendal Roué a46b3aa816 v0.64.0 2016-05-18 19:20:57 +02:00
Gwendal Roué 60fafd399f Fix Database closing in GRDBCipher targets 2016-05-18 19:20:09 +02:00
Gwendal Roué f3d3eb43dc TODO.md 2016-05-18 19:09:27 +02:00
Gwendal Roué 5ff030607e TODO.md 2016-05-18 19:06:39 +02:00
Gwendal Roué 71492c5d37 README.md: remove documentation for row subscripting by column name 2016-05-18 19:05:42 +02:00
Gwendal Roué f553f2d2b0 Remove Row subscripting by column name; row.databaseValue(named:) returns an optional DatabaseValue 2016-05-18 19:03:29 +02:00
Gwendal Roué 5fdff2dc6f TODO.md 2016-05-18 18:40:38 +02:00
Gwendal Roué 4185de77e0 Remove DatabaseValue.failableValue() 2016-05-18 18:40:03 +02:00
Gwendal Roué aa51a6c54e TODO.md 2016-05-18 16:38:46 +02:00
Gwendal Roué 092509b3c3 TODO.md 2016-05-18 16:33:22 +02:00
Gwendal Roué 695279e784 Issue #50: More MappedRowTests 2016-05-18 16:28:06 +02:00
Gwendal Roué 5c6bccd7b3 Issue #50: Row equality now compares subrows 2016-05-18 16:25:24 +02:00
Gwendal Roué 45c8b48b0a TODO.md 2016-05-18 13:58:33 +02:00
Gwendal Roué 51130c354b Issue #50: More MappedRowTests 2016-05-18 13:55:02 +02:00
Gwendal Roué 79d1845266 Issue #50: More RowAdapterTests 2016-05-18 09:16:03 +02:00
Gwendal Roué 4f1173e609 Issue #50: More RowAdapterTests 2016-05-18 09:10:48 +02:00
Gwendal Roué 23178a2727 Issue #50: More RowAdapterTests 2016-05-18 09:09:09 +02:00
Gwendal Roué 60ab73d8a4 Issue #50: AdaptedRowImpl preserves column ordering 2016-05-18 09:04:39 +02:00
Gwendal Roué 2a39120b38 Issue #50: RowAdapter mappings have mandatory matching columns in the iterated statement. 2016-05-18 08:27:52 +02:00
Gwendal Roué c5bc699c26 Merge branch 'master' into RowAdapter 2016-05-18 07:53:17 +02:00
Gwendal Roué 9cc225dede Document that fetchOne(_🔑) supports multiple-column primary keys 2016-05-17 21:11:31 +02:00
Gwendal Roué 5f743f4cad v0.63.0 2016-05-17 20:32:11 +02:00
Gwendal Roué a7266e38c4 Issue #51: Database.close() logs when sqlite_close() fails 2016-05-17 20:30:50 +02:00
Gwendal Roué ea2f202e4d registerMigrationWithDisabledForeignKeyChecks documentation 2016-05-17 20:12:20 +02:00
Gwendal Roué c1169f0d2c Issue #51: Restore statement caching, now that the database is closed in the correct queue. 2016-05-17 20:08:55 +02:00
Gwendal Roué 37d7c178f5 DatabaseMigratorTests: accept various error messages from various SQLite versions 2016-05-17 19:43:15 +02:00
Gwendal Roué c34d64b3bb DatabaseErrorTests: accept various error messages from various SQLite versions 2016-05-17 19:43:07 +02:00
Gwendal Roué 8934596527 DatabaseErrorTests: accept various error messages from various SQLite versions 2016-05-17 19:40:47 +02:00
Gwendal Roué c13ac87a5b Database.primaryKey(): work around an SQLite bug 2016-05-17 19:40:17 +02:00
Gwendal Roué 09ea2dcd10 PRAGMA defer_foreign_keys is not available until iOS 8.2 and OS X 10.10 2016-05-17 19:25:04 +02:00
Gwendal Roué 1dd6707070 Support for advanced migrations is not available until iOS 8.2 and OS X 10.10 2016-05-17 19:24:39 +02:00
Gwendal Roué d5367fc2b2 Issue #51: Perform Database.close() in the correct queue 2016-05-17 19:03:07 +02:00
Gwendal Roué 0333406fbc Fix tests for 32bits systems 2016-05-17 19:02:06 +02:00
Gwendal Roué 6f779faa05 Documentation 2016-05-17 13:45:39 +02:00
Gwendal Roué 82fa559962 Issue #51: sqlite3_close_v2() is not available until iOS 8.2 and OS X 10.10. Until then, use sqlite3_close(), and avoid caching statements. Disable the concurrency tests that check database deallocation while some statements are running. 2016-05-17 13:39:29 +02:00
Gwendal Roué eca93cb43f Fix some tests for iOS8 2016-05-17 13:00:34 +02:00
Gwendal Roué 04e648b3f9 More RowAdapter tests 2016-05-13 11:37:31 +02:00
Gwendal Roué 6de0debb49 More RowAdapter tests 2016-05-13 11:35:38 +02:00
Gwendal Roué 84929771be RowAdapter initial implementation 2016-05-13 11:30:44 +02:00
Gwendal Roué 3b00230580 README.md 2016-05-12 19:53:48 +02:00
Gwendal Roué 959b11d19e Fix v0.62.0 release date 2016-05-12 08:19:29 +02:00
Gwendal Roué 2ad59f1aa5 v0.62.0 2016-05-12 08:18:02 +02:00
Gwendal Roué 494682c2af FetchedRecordsController iOS fixes 2016-05-12 08:15:24 +02:00
Gwendal Roué d48d0e621f FetchedRecordsController documentation 2016-05-12 07:59:38 +02:00
Gwendal Roué 1a3382aa24 CHANGELOG.md 2016-05-12 07:56:36 +02:00
Gwendal Roué 5c065d3f8a FetchedRecordsController documentation 2016-05-12 07:54:57 +02:00
Gwendal Roué 4799957d08 CHANGELOG.md 2016-05-12 07:48:36 +02:00
Gwendal Roué 307f43ce12 FetchedRecordsController documentation 2016-05-11 23:25:21 +02:00
Gwendal Roué b13fc99797 FetchedRecordsController: hide all UITableView-related methods from OSX 2016-05-11 23:24:30 +02:00
Gwendal Roué 1f30f8dcf3 FetchedRecordsController: hide all UITableView-related methods from OSX 2016-05-11 19:35:45 +02:00
Gwendal Roué fbb40e1232 FetchedRecordsController: tests that trackChanges { ... } trailing closure is invoked after records have been changed. 2016-05-11 10:45:48 +02:00
Gwendal Roué 1d5999e50b FetchedRecordsController: expose UITableView-targetted callbacks to iOS only 2016-05-11 10:36:51 +02:00
Gwendal Roué 04713d9652 FetchedRecordsController: use unowned self in callbacks 2016-05-11 10:04:22 +02:00
Gwendal Roué 050f432c10 FetchedRecordsController: callbacks must be set all at once. Restore optional tracking. 2016-05-11 08:32:11 +02:00
Gwendal Roué 1201f4e008 FetchedRecordsController: replace delegate with callbacks 2016-05-10 14:16:13 +02:00
Gwendal Roué 5614f57f43 v0.61.0 2016-05-10 09:57:03 +02:00
Gwendal Roué f9d82b8ead FetchedRecordsController cleanup 2016-05-10 09:12:27 +02:00
Gwendal Roué fba181bfea FetchedRecordsController: notify delegate of eventual changes when the delegate is set after performFetch() has been called.
With this change, it doesn’t matter if the delegate setter is called before of after performFetch().
2016-05-10 08:17:20 +02:00
Gwendal Roué 10d20748ad SQLITE_FULL, SQLITE_IOERR, SQLITE_BUSY, and SQLITE_NOMEM errors can mean that a transaction has been automatically rollbacked: update isInsideTransaction flag accordingly. 2016-05-09 20:52:36 +02:00
Gwendal Roué 25fc832ae5 CHANGELOG.md 2016-05-09 20:19:13 +02:00
Gwendal Roué fe5ef03bc8 A failed COMMIT is repaired with a ROLLBACK 2016-05-09 20:17:30 +02:00
Gwendal Roué fe158d20ed Failing test that checks that a failed COMMIT is repaired with a ROLLBACK 2016-05-09 20:17:19 +02:00
Gwendal Roué 95cb311f6c More TODO 2016-05-09 08:06:26 +02:00
Gwendal Roué e1bb98ec94 Less TODO 2016-05-08 19:49:34 +02:00
Gwendal Roué d7e0e44de0 TODO.md 2016-05-07 19:48:24 +02:00
Gwendal Roué 8a54e4cd76 TODO.md 2016-05-07 14:46:55 +02:00
Gwendal Roué b89c4f95e8 CHANGELOG.md 2016-05-07 13:29:06 +02:00
Gwendal Roué 087a1a1af5 v0.60.1 2016-05-07 13:27:52 +02:00
Gwendal Roué db86ceca0e Tests that when Database is deallocated, there is no remaining busy update statement. 2016-05-07 13:18:50 +02:00
Gwendal Roué a54b0389ae Remove sharing of cached statements between database pool readers 2016-05-07 13:17:45 +02:00
Gwendal Roué 6c826b6ecf Statement: don’t store sql string, and use sqlite3_sql instead. Plus some cleanup. 2016-05-07 11:57:35 +02:00
Gwendal Roué 8e864b9df4 Use sqlite3_close_v2, and check its result 2016-05-07 11:37:33 +02:00
Gwendal Roué 6e0837325c Documentation 2016-05-07 11:34:24 +02:00
Gwendal Roué b237df4b6d Use sqlite3_close_v2 2016-05-07 11:34:18 +02:00
Gwendal Roué 96f8a57f44 minor 2016-05-07 09:50:55 +02:00
Gwendal Roué f5575510f5 README.md 2016-05-07 06:28:23 +02:00
Gwendal Roué 745a72a0c4 README.md 2016-05-07 06:15:58 +02:00
Gwendal Roué c34b9e77a1 README.md 2016-05-06 14:54:27 +02:00
Gwendal Roué 7e8a47cd92 README.md 2016-05-06 14:52:03 +02:00
Gwendal Roué a0ecab10ac Cleanup 2016-05-06 13:30:40 +02:00
Gwendal Roué 185c2575b6 Protect Persistable query cache with a thread-safe ReadWriteBox 2016-05-06 13:17:57 +02:00
Gwendal Roué 565f627429 Reimplement ReadWriteBox with GCD 2016-05-06 13:01:28 +02:00
Gwendal Roué ef4f483a9e Typo 2016-05-06 12:35:47 +02:00
Gwendal Roué 92538de969 Remove useless warnings in the documentation of DatabaseReader.backup(to:)
GRBD serializes uses of writer connections: it’s useless to warn the user against using a database during a backup.
2016-05-05 15:37:41 +02:00
Gwendal Roué 88fe1cae08 v0.60.0 2016-05-05 15:26:12 +02:00
Gwendal Roué fbb59d2d6c DatabaseReader.backup(to:) 2016-05-05 15:24:14 +02:00
Gwendal Roué 3b9688eb2f TODO.md 2016-05-05 13:54:55 +02:00
Gwendal Roué 03debbf434 Documentation 2016-05-05 13:51:27 +02:00
Gwendal Roué f3bc909a02 From future import Swift 3 2016-05-05 13:23:28 +02:00
Gwendal Roué c3c20acb80 TODO.md 2016-05-05 07:12:48 +02:00
Gwendal Roué eccb4530a1 TODO.md 2016-05-04 18:29:56 +02:00
Gwendal Roué 3dd81071a5 README.md 2016-05-03 19:24:31 +02:00
Gwendal Roué d95f98f67d README.md 2016-05-03 19:18:07 +02:00
Gwendal Roué 94797986a9 Expose FetchedRecordsController to OSX 2016-05-03 11:44:04 +02:00
Gwendal Roué ac5e7e8973 README.md 2016-05-03 08:46:26 +02:00
Gwendal Roué 2684c4a735 README.md 2016-05-03 08:45:36 +02:00
Gwendal Roué bd67f86769 FetchedRecordsController tests WIP 2016-05-02 09:13:07 +02:00
Gwendal Roué e2765a3fd6 README.md 2016-05-02 09:10:31 +02:00
Gwendal Roué 73714933d7 README.md 2016-05-02 08:57:56 +02:00
Gwendal Roué d3da0bf860 README.md 2016-05-02 08:52:14 +02:00
Gwendal Roué dc011d522f README.md 2016-05-02 08:28:00 +02:00
Gwendal Roué 3d1ecc1881 README.md 2016-05-01 20:02:33 +02:00
Gwendal Roué 7676f10e0c README.md 2016-05-01 19:55:18 +02:00
Gwendal Roué c83bdfa810 README.md 2016-05-01 19:53:50 +02:00
Gwendal Roué 282677b8fc README.md 2016-05-01 19:53:06 +02:00
Gwendal Roué b2d0080637 README.md 2016-05-01 19:32:34 +02:00
Gwendal Roué 5f1be7c815 README.md 2016-05-01 19:31:45 +02:00
Gwendal Roué d5e2d6b88b README.md 2016-05-01 19:30:56 +02:00
Gwendal Roué 39a2efbcd9 README.md 2016-05-01 19:28:20 +02:00
Gwendal Roué 063b367951 README.md 2016-05-01 19:21:23 +02:00
Gwendal Roué 37ce59af6e README.md 2016-05-01 19:20:07 +02:00
Gwendal Roué 2d0cd5d186 README.md 2016-05-01 19:17:43 +02:00
Gwendal Roué dbbded56cf README.md 2016-05-01 19:16:34 +02:00
Gwendal Roué 67d6ac1760 README.md 2016-05-01 19:14:30 +02:00
Gwendal Roué 48d2ce5a98 README.md 2016-05-01 18:31:55 +02:00
Gwendal Roué 96a8a0f1fa FetchedRecordsController tests WIP 2016-05-01 16:56:17 +02:00
Gwendal Roué 4253a46282 FetchedRecordsController tests WIP 2016-05-01 14:06:04 +02:00
Gwendal Roué 660c255532 Drop obsolete test 2016-05-01 14:05:55 +02:00
Gwendal Roué 3956f1d183 FetchedRecordsController tests WIP 2016-05-01 14:00:00 +02:00
Gwendal Roué 234e1e6810 FetchedRecordsController tests WIP 2016-04-30 14:50:10 +02:00
Gwendal Roué e9e2d0bf10 README.md 2016-04-30 14:49:51 +02:00
Gwendal Roué 5d8a380f86 README.md 2016-04-28 08:44:04 +02:00
Gwendal Roué a9a06a0652 README.md 2016-04-28 08:35:55 +02:00
Gwendal Roué 9f4b03c14f Mark methods that are slow to compile (thanks to https://medium.com/swift-programming/speeding-up-slow-swift-build-times-922feeba5780) 2016-04-28 06:36:23 +02:00
Gwendal Roué a8f93a5a9c TODO.md 2016-04-27 14:30:17 +02:00
Gwendal Roué 4c52d51aa2 Fix performance tests 2016-04-26 13:27:42 +02:00
Gwendal Roué 663b89a4a5 SQLite.swift 0.10.1 2016-04-26 13:13:51 +02:00
Gwendal Roué 0a4779ed8c Realm 0.99.1 2016-04-26 13:13:36 +02:00
Gwendal Roué c09463e529 README.md 2016-04-26 09:07:13 +02:00
Gwendal Roué f93b029b82 TODO 2016-04-26 08:49:27 +02:00
Gwendal Roué 929122934e v0.59.1 2016-04-25 20:42:44 +02:00
Gwendal Roué dfd38150f2 https://github.com/groue/GRDB.swift/issues/41 2016-04-25 20:24:53 +02:00
Gwendal Roué 11bb86a8ed TODO.md 2016-04-25 20:24:33 +02:00
Gwendal Roué 05dad7e0d6 TODO.md 2016-04-23 17:40:54 +02:00
Gwendal Roué 541316cd89 README.md 2016-04-23 10:53:54 +02:00
Gwendal Roué 08c75a2d06 README.md 2016-04-23 10:52:44 +02:00
Gwendal Roué 15a4aa3d1b Fix collation documentation 2016-04-23 10:51:20 +02:00
Gwendal Roué acb46d3e86 v0.59.0 2016-04-23 09:58:10 +02:00
Gwendal Roué 000bd1b200 Database.isInsideTransaction 2016-04-23 09:56:47 +02:00
Gwendal Roué baf87f837a TODO.md 2016-04-23 09:31:33 +02:00
Gwendal Roué 0bcc8639c1 Update playgrounds 2016-04-23 09:28:10 +02:00
Gwendal Roué e75b25c0c1 Update playgrounds 2016-04-23 09:22:04 +02:00
Gwendal Roué 2cc6d17014 README.md 2016-04-23 08:00:48 +02:00
Gwendal Roué 404bb0eafd README.md 2016-04-22 21:05:24 +02:00
Gwendal Roué 284f0e7ccb README.md 2016-04-22 21:03:42 +02:00
Gwendal Roué 081df4cad9 README.md 2016-04-22 20:48:43 +02:00
Gwendal Roué 13d25939ec README.md 2016-04-22 20:47:58 +02:00
Gwendal Roué 9b6c05ca04 TODO.md 2016-04-22 20:36:53 +02:00
Gwendal Roué 8b9e78e158 Update Tour.playground 2016-04-22 19:36:48 +02:00
Gwendal Roué a974f311d9 README.md 2016-04-22 19:04:27 +02:00
Gwendal Roué b034137516 README.md 2016-04-22 18:52:36 +02:00
Gwendal Roué b819271441 README.md 2016-04-22 18:51:34 +02:00
Gwendal Roué b898391124 README.md 2016-04-22 18:42:52 +02:00
Gwendal Roué 4c57436fe8 README.md 2016-04-22 18:42:25 +02:00
Gwendal Roué f0479a656a README.md 2016-04-22 18:40:14 +02:00
Gwendal Roué 41e0537eca README.md 2016-04-22 18:30:11 +02:00
Gwendal Roué dd04990143 TODO.md 2016-04-22 08:34:36 +02:00
Gwendal Roué d0d9344c8a README.md 2016-04-22 08:34:33 +02:00
Gwendal Roué 64ee2ef045 README.md 2016-04-22 05:18:15 +02:00
Gwendal Roué 061d444a8f README.md 2016-04-22 05:16:56 +02:00
Gwendal Roué d4cb690b8b CHANGELOG.md 2016-04-22 05:16:31 +02:00
Gwendal Roué bd50f1ce59 README.md 2016-04-22 05:10:41 +02:00
Gwendal Roué 944cae53de README.md 2016-04-22 05:03:27 +02:00
Gwendal Roué 17b43d021a README.md 2016-04-22 04:57:38 +02:00
Gwendal Roué 059af3a621 README.md 2016-04-22 04:52:58 +02:00
Gwendal Roué 524701caad README.md 2016-04-22 04:46:54 +02:00
Gwendal Roué 34111df889 README.md 2016-04-22 04:44:13 +02:00
Gwendal Roué 5dfca74327 README.md 2016-04-22 04:43:07 +02:00
Gwendal Roué 12cfdac1b0 README.md 2016-04-22 04:31:03 +02:00
Gwendal Roué 5ccf66bd9b README.md 2016-04-22 04:28:28 +02:00
Gwendal Roué 4f344ab1a6 README.md 2016-04-21 19:29:53 +02:00
Gwendal Roué 624ac5b81c README.md 2016-04-21 19:23:33 +02:00
Gwendal Roué 7c2fb3506c README.md 2016-04-21 19:16:46 +02:00
Gwendal Roué dc4ac5568c README.md 2016-04-21 19:16:24 +02:00
Gwendal Roué 460cfd05c6 README.md 2016-04-21 19:15:35 +02:00
Gwendal Roué 40525d9bcf README.md 2016-04-21 13:46:07 +02:00
Gwendal Roué 8dbf8c92cf README.md 2016-04-21 13:45:41 +02:00
Gwendal Roué 92d417dc0c README.md 2016-04-21 13:41:46 +02:00
Gwendal Roué 43e9a63210 FetchRequest.reverse() sort by descending rowID when no ordering has been specified. 2016-04-21 09:03:01 +02:00
Gwendal Roué 4483d748e9 TODO.md 2016-04-21 08:48:25 +02:00
Gwendal Roué 48f2581d07 TODO.md 2016-04-20 22:05:57 +02:00
Gwendal Roué f074f1ab36 v0.58.0 2016-04-20 22:05:26 +02:00
Gwendal Roué 42bea06b93 CHANGELOG.md 2016-04-20 22:04:22 +02:00
Gwendal Roué 6550454d1e Replace DatabaseChanges with Database.lastInsertedRowID and Database.changesCount 2016-04-20 21:58:58 +02:00
Gwendal Roué 0a80316d09 Close experiment with API diff 2016-04-20 20:45:38 +02:00
Gwendal Roué 64b98a8330 TODO.md 2016-04-18 10:00:54 +02:00
Gwendal Roué 992c63480d DatabasePool uses PRAGMA synchronous = NORMAL
As advised by https://www.sqlite.org/pragma.html#pragma_synchronous
2016-04-15 06:24:18 +02:00
Gwendal Roué 6566f3f83d Experiment with API diff 2016-04-14 19:50:12 +02:00
Gwendal Roué 973da2de61 Experiment with API diff 2016-04-14 19:06:42 +02:00
Gwendal Roué bf7fdd68f2 Typo 2016-04-13 09:09:54 +02:00
Gwendal Roué 1136d367c7 Code organization 2016-04-13 08:59:32 +02:00
Gwendal Roué e7b1c9b7cd Update README.md 2016-04-11 19:49:01 +02:00
Gwendal Roué 9a03e0866b README.md 2016-04-09 09:21:37 +02:00
Gwendal Roué a5d26bdc81 README.md 2016-04-09 09:11:44 +02:00
Gwendal Roué e9cca9657f CHANGELOG.md 2016-04-09 06:32:23 +02:00
Gwendal Roué 8498dd927f README.md 2016-04-08 18:29:36 +02:00
Gwendal Roué ccc8d2ba33 TODO.md 2016-04-08 17:59:21 +02:00
Gwendal Roué 1098b0254e Typo in CHANGELOG.md 2016-04-08 13:45:31 +02:00
Gwendal Roué 9eda86eb29 Update CHANGELOG.md 2016-04-08 13:17:15 +02:00
Gwendal Roué 2d126010bc Update documentation 2016-04-08 13:17:03 +02:00
Gwendal Roué 30f4744199 Remove dead code 2016-04-08 13:13:21 +02:00
Gwendal Roué e26892ad90 v0.57.0 2016-04-08 13:04:54 +02:00
Gwendal Roué 4976b7e648 Remove all direct database accesses examples from README.md 2016-04-08 09:00:04 +02:00
Gwendal Roué a539b629e7 Remove all direct database accesses examples from README.md 2016-04-08 08:57:24 +02:00
Gwendal Roué 8bd22b545c Update GRDBDemoiOS app to block-based database accesses. 2016-04-08 08:40:57 +02:00
Gwendal Roué 8d3796324d Update GRDBProfiling app to block-based database accesses. 2016-04-08 08:37:02 +02:00
Gwendal Roué af53fe8e79 Update playgrounds to block-based database accesses. 2016-04-08 08:35:48 +02:00
Gwendal Roué 4bcff181c7 Back to block-based database accesses.
Rationale: https://medium.com/@gwendal.roue/four-different-ways-to-handle-sqlite-concurrency-db3bcc74d00e
2016-04-08 08:29:58 +02:00
Gwendal Roué 783da0c45d TODO.md 2016-04-07 07:46:32 +02:00
Gwendal Roué 6ef4a6eb08 More tests for DatabasePool read that starts while a write is running. 2016-04-07 06:22:51 +02:00
Gwendal Roué 9e52513138 Explicit test for DatabasePool read that starts while a write is running. 2016-04-06 23:53:10 +02:00
Gwendal Roué e9043d1e93 Explicit test for DatabasePool read that starts while a write is running. 2016-04-06 21:29:49 +02:00
Gwendal Roué 3dd821a975 v0.56.2 2016-04-05 18:32:42 +02:00
Gwendal Roué 18ba7ed086 Restore save(DatabaseQueue/Pool) 2016-04-05 18:31:06 +02:00
Gwendal Roué 0128385195 CHANGELOG.md 2016-04-05 14:10:25 +02:00
Gwendal Roué 4c3efab946 Test app for Carthage integration of GRDBCipher 2016-04-05 13:57:57 +02:00
Gwendal Roué 858d427690 v0.56.1 2016-04-05 13:21:51 +02:00
Gwendal Roué 486666279d Revert "Document that CocoaPods is not supported until https://github.com/CocoaPods/CocoaPods/issues/5108"
This reverts commit 24d2ddada7.
2016-04-05 09:22:23 +02:00
Gwendal Roué 24d2ddada7 Document that CocoaPods is not supported until https://github.com/CocoaPods/CocoaPods/issues/5108
is solved.
2016-04-05 09:12:22 +02:00
Gwendal Roué 023d757964 Attempt to fix CocoaPods 2016-04-05 08:53:02 +02:00
Gwendal Roué e4b12d6a2d v0.56.0 2016-04-05 08:23:59 +02:00
Gwendal Roué d67625a966 README.md 2016-04-05 08:18:50 +02:00
Gwendal Roué 608f671c48 TODO.md 2016-04-05 07:51:45 +02:00
Gwendal Roué 9ef1c70eb2 Encryption documentation 2016-04-05 06:55:29 +02:00
Gwendal Roué b7e236a693 Encryption documentation 2016-04-05 06:50:35 +02:00
Gwendal Roué d519a92719 testExportPlainTextDatabaseToEncryptedDatabase 2016-04-05 06:33:11 +02:00
Gwendal Roué a83d7c6140 CHANGELOG.md 2016-04-05 05:53:55 +02:00
Gwendal Roué d74a8636b3 TODO.md 2016-04-05 05:53:49 +02:00
Gwendal Roué d010271f5d Update SQLCipher deployment targets 2016-04-05 05:51:50 +02:00
Gwendal Roué f868d3eead changePassphrase() 2016-04-05 05:51:19 +02:00
Gwendal Roué 166ae08465 EncryptionTests: make sure we can not open a database encrypted with PRAGMA key 2016-04-04 13:34:32 +02:00
Gwendal Roué 15f3450f8c GRDBTestCase cleanup 2016-04-04 13:31:57 +02:00
Gwendal Roué b2bc2700b3 Fix https://github.com/sqlcipher/sqlcipher/issues/162 2016-04-04 13:18:37 +02:00
Gwendal Roué 8183f57b85 Fix SQLCipher 2016-04-04 09:01:26 +02:00
Gwendal Roué 79ffb7b9b8 TODO.md 2016-04-04 08:23:46 +02:00
Gwendal Roué af108e1ac9 Change SQLCipher commit target. 2016-04-04 08:22:38 +02:00
Gwendal Roué 627bca09c0 SQLCipher: test compatibility between Configuration.passphrase and PRAGMA key 2016-04-03 22:57:12 +02:00
Gwendal Roué 08de2cc920 Remove explicit deployment targets for OS X tests 2016-04-03 22:46:20 +02:00
Gwendal Roué f1c87b6604 CHANGELOG.md 2016-04-03 22:24:24 +02:00
Gwendal Roué 9f6c5ccccb Fix availability attributes of localizedCapitalizedString, etc. Restore iOS7 compatibility. 2016-04-03 22:22:06 +02:00
Gwendal Roué 41fab091d0 GRDBCipheriOS 2016-04-03 22:16:30 +02:00
Gwendal Roué 484d5a5968 Framework for GRDB+SQLCipher is named GRDBCipher 2016-04-03 21:30:22 +02:00
Gwendal Roué eabacfafb2 Encryption tests 2016-04-03 20:39:20 +02:00
Gwendal Roué 2ec2e85679 Passing tests for encrypted databases 2016-04-03 18:42:31 +02:00
Gwendal Roué e0bb6d106c Failing tests for encrypted databases 2016-04-03 17:58:58 +02:00
Gwendal Roué 20a16de9de DatabaseWriter.setKey() and reKey() 2016-04-03 17:58:03 +02:00
Gwendal Roué e3d8c06ad0 Refactor tests so that DatabasePool can be configured at the target level. We are preparing tests for encrypted databases. 2016-04-03 16:55:04 +02:00
Gwendal Roué 7e3563f64b Refactor tests so that DatabaseQueue can be configured at the target level. We are preparing tests for encrypted databases. 2016-04-03 16:20:45 +02:00
Gwendal Roué f188db2dab TODO.md 2016-04-03 14:04:12 +02:00
Gwendal Roué 0473d232ed Tests for GRDBOSX, GRDBiOS, and GRDBCipherOSX (without encryption) 2016-04-03 14:04:04 +02:00
Gwendal Roué 861e43a25b SQLCipher/README.md 2016-04-03 11:41:29 +02:00
Gwendal Roué 3e0fcc4b87 New GRDBCipherOSX target + tests 2016-04-03 11:40:34 +02:00
Gwendal Roué a355892ce5 FetchedRecordsController.setRequest(sql:arguments:) 2016-04-02 08:52:38 +02:00
Gwendal Roué 52c0f31578 FetchedRecordsController: rename writer property to databaseWriter 2016-04-02 08:46:04 +02:00
Gwendal Roué e132b54c9f FetchedRecordsController documentation 2016-04-02 08:41:19 +02:00
Gwendal Roué dc942c5734 The save() method now requires a Database connection argument, and won’t accept DatabaseQueue or DatabasePool directly. 2016-04-02 08:37:30 +02:00
Gwendal Roué a7038a9eaf TODO.md 2016-04-02 08:17:20 +02:00
Gwendal Roué 7664e0b187 TODO.md 2016-04-01 23:14:25 +02:00
Gwendal Roué e8ccc48815 Add performance tests README in project so that I don’t have to look after it in order to build Realm 2016-04-01 20:20:15 +02:00
Gwendal Roué eda40621c4 TODO.md 2016-04-01 13:25:09 +02:00
Gwendal Roué 5b4c6b62a7 README.md 2016-04-01 08:12:17 +02:00
Gwendal Roué b7bab76232 v0.55.0 2016-03-31 16:42:21 +02:00
Gwendal Roué bd3c39eaaf setupMemoryManagement() documentation 2016-03-31 16:38:57 +02:00
Gwendal Roué 2fb1d6f731 setupMemoryManagement() documentation 2016-03-31 16:37:55 +02:00
Gwendal Roué ef299acbe8 Memory management is not automatic when GRDB is built for iOS, but easier. 2016-03-31 16:26:07 +02:00
Gwendal Roué 005c4ded24 Memory management is automatic when GRDB is built for iOS 2016-03-31 14:26:59 +02:00
Gwendal Roué cfceabb4ec v0.54.2 2016-03-31 10:31:00 +02:00
Gwendal Roué 06095ec343 Fix #37 2016-03-31 10:27:12 +02:00
Gwendal Roué a753a654ca GRDBDemoiOS WIP 2016-03-31 07:57:03 +02:00
Gwendal Roué 2dfd6c79c0 Fix Carthage test app 2016-03-31 06:55:41 +02:00
Gwendal Roué abbf0cd856 README.md: even though "column == true" condition is supported, we don't have to foster it. 2016-03-30 09:58:58 +02:00
Gwendal Roué 83ec50e4ab GRDBDemoiOS WIP 2016-03-30 08:34:57 +02:00
Gwendal Roué d51b6fd61d GRDBDemoiOS WIP 2016-03-30 08:33:42 +02:00
Gwendal Roué 894bb05cba GRDBDemoiOS: simplify view controllers’ names 2016-03-30 08:00:50 +02:00
Gwendal Roué 669720c6dc v0.54.1 2016-03-29 19:07:32 +02:00
Gwendal Roué fdcbc2db86 v0.54.1 2016-03-29 18:52:12 +02:00
Gwendal Roué 37f0e4af3e TODO.md 2016-03-29 16:01:08 +02:00
Gwendal Roué 7c14e63fef v0.54.0 2016-03-29 13:31:59 +02:00
Gwendal Roué 7b5088b921 DatabaseWriter documentation 2016-03-29 13:10:11 +02:00
Gwendal Roué 66fe22d716 Update Carthage test application 2016-03-29 13:07:40 +02:00
Gwendal Roué d2339cc7c2 Merge branch 'master' of github.com:groue/GRDB.swift into FetchedRecordsController 2016-03-29 12:45:19 +02:00
Gwendal Roué d53c7f5d2d DatabaseWriter documentation 2016-03-29 09:08:32 +02:00
Gwendal Roué efdc6053ff FetchedRecordsController: fix concurrency bug 2016-03-29 08:53:55 +02:00
Gwendal Roué ab3ec443d2 Simplify SerializedDatabase 2016-03-29 08:26:07 +02:00
Gwendal Roué f5873ae0e4 README.md 2016-03-28 20:30:22 +02:00
Gwendal Roué e9197817f5 README.md 2016-03-28 20:21:25 +02:00
Gwendal Roué c04c8ef815 Merge branch 'master' of github.com:groue/GRDB.swift into FetchedRecordsController 2016-03-28 19:34:52 +02:00
Gwendal Roué c5d1181d72 README.md 2016-03-28 19:34:18 +02:00
Gwendal Roué 4b479ad327 Merge branch 'master' into FetchedRecordsController
Conflicts:
	CHANGELOG.md
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/Assets.xcassets/AppIcon.appiconset/Contents.json
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/Database.swift
	TODO.md
2016-03-28 18:54:59 +02:00
Gwendal Roué be4497f768 Update GRDBDemoiOS so that it uses built-in collation 2016-03-28 18:28:40 +02:00
Gwendal Roué 6ad79b12a6 README.md 2016-03-28 18:20:28 +02:00
Gwendal Roué 24fe6b3c4d README.md 2016-03-28 18:18:18 +02:00
Gwendal Roué f4d5f1c584 README.md 2016-03-28 18:16:51 +02:00
Gwendal Roué 9a18ab44a6 Default unicode-aware collations 2016-03-28 18:12:29 +02:00
Gwendal Roué a97530bde8 The Query interface no longer use non-unicode aware UPPER and LOWER functions 2016-03-28 16:35:20 +02:00
Gwendal Roué ec176bbec5 Xcode hiccup 2016-03-28 16:33:10 +02:00
Gwendal Roué 76e194ab1a GRDBDemoiOS WIP 2016-03-28 15:19:49 +02:00
Gwendal Roué 460e1c87d9 GRDBDemoiOS WIP 2016-03-28 15:06:18 +02:00
Gwendal Roué 66db3fd6d6 GRDBDemoiOS WIP 2016-03-28 15:06:15 +02:00
Gwendal Roué 15ec342519 FetchedRecordsController documentation 2016-03-28 14:25:34 +02:00
Gwendal Roué 136d262d4c FetchedRecordsController documentation 2016-03-28 14:15:55 +02:00
Gwendal Roué 582dafd50d Thanks 2016-03-28 00:17:50 +02:00
Gwendal Roué a827a1b105 FetchedRecordsController documentation 2016-03-28 00:13:22 +02:00
Gwendal Roué 50a62edbaf FetchedRecordsController documentation 2016-03-28 00:08:46 +02:00
Gwendal Roué 4924b39f93 FetchedRecordsController documentation 2016-03-28 00:08:12 +02:00
Gwendal Roué afe2c9db2f FetchedRecordsController documentation 2016-03-28 00:05:20 +02:00
Gwendal Roué d18b30da10 FetchedRecordsController documentation 2016-03-28 00:03:11 +02:00
Gwendal Roué d6b07185ae FetchedRecordsController documentation 2016-03-28 00:00:11 +02:00
Gwendal Roué 1a32753ce9 CHANGELOG.md 2016-03-27 23:14:58 +02:00
Gwendal Roué 0bab743936 GRDBDemoiOS WIP 2016-03-27 23:05:40 +02:00
Gwendal Roué 6f82912701 Merge branch 'master' into FetchedRecordsController 2016-03-27 19:26:50 +02:00
Gwendal Roué 827ffa88fe README.md 2016-03-27 19:26:28 +02:00
Gwendal Roué 83534e2848 GRDBDemoiOS WIP 2016-03-27 16:55:29 +02:00
Gwendal Roué a7dcbea8ef GRDBDemoiOS WIP 2016-03-27 16:32:41 +02:00
Gwendal Roué 36a35ef303 [Swift bug] Prevent a memory leak 2016-03-27 15:48:07 +02:00
Gwendal Roué 91eced4b26 GRDBDemoiOS WIP 2016-03-27 15:47:45 +02:00
Gwendal Roué ec5f33179a Merge branch 'master' of github.com:groue/GRDB.swift into FetchedRecordsController 2016-03-27 15:05:05 +02:00
Gwendal Roué e180ae4cbd README.md 2016-03-27 15:00:49 +02:00
Gwendal Roué 98bc81cdd5 README.md 2016-03-27 14:56:44 +02:00
Gwendal Roué 2b549c358d README.md 2016-03-27 14:54:46 +02:00
Gwendal Roué d170b0d0e1 DatabaseEvent: make it lazy 2016-03-27 14:39:12 +02:00
Gwendal Roué 5fbdd03acb Restore disabled tests (???) 2016-03-27 14:38:03 +02:00
Gwendal Roué 3e3ba6e7ed FetchedRecordsController optimization for DatabasePool: release the writer dispatch queue before the end of the fetch 2016-03-27 14:22:32 +02:00
Gwendal Roué ea929a78e0 FetchedRecordsController TODO 2016-03-27 11:15:56 +02:00
Gwendal Roué c845c19477 FetchedRecordsController TODO 2016-03-27 11:15:31 +02:00
Gwendal Roué ef0d2c6234 GRDBDemoiOS WIP 2016-03-27 11:14:19 +02:00
Gwendal Roué 8af5f54767 GRDBDemoiOS WIP 2016-03-27 01:44:43 +01:00
Gwendal Roué fb601ee80f GRDBDemoiOS WIP 2016-03-26 18:51:44 +01:00
Gwendal Roué 72fa9d1a4a GRDBDemoiOS WIP 2016-03-26 18:49:44 +01:00
Gwendal Roué d1b21708e6 Merge FetchedRecordsController demo in GRDBDemoiOS 2016-03-26 18:39:03 +01:00
Gwendal Roué 703aa07407 GRDBFetchedRecordsControllerDemo WIP 2016-03-26 18:33:39 +01:00
Gwendal Roué 6e2ed61743 GRDBFetchedRecordsControllerDemo WIP 2016-03-26 18:30:20 +01:00
Gwendal Roué c9ce98c5d5 GRDBFetchedRecordsControllerDemo WIP 2016-03-26 17:55:50 +01:00
Gwendal Roué f0c23b7244 GRDBFetchedRecordsControllerDemo WIP 2016-03-26 17:50:09 +01:00
Gwendal Roué 00e49e76be GRDBFetchedRecordsControllerDemo WIP 2016-03-26 17:49:47 +01:00
Gwendal Roué 05eb7b35f8 FetchedRecordsController can change its fetch request, and notify the delegate of changes 2016-03-26 17:41:45 +01:00
Gwendal Roué f6df412350 GRDBFetchedRecordsControllerDemo WIP 2016-03-26 17:03:32 +01:00
Gwendal Roué f952b9bbcb GRDBFetchedRecordsControllerDemo WIP 2016-03-26 16:52:08 +01:00
Gwendal Roué 9160021442 New GRDBFetchedRecordsControllerDemo app 2016-03-26 16:28:40 +01:00
Gwendal Roué 77e245aec3 Make FetchedRecordsControllerDelegate methods optional 2016-03-26 16:26:39 +01:00
Gwendal Roué eaf8193d37 Documentation of didInsertWithRowID(rowID:forColumn:) 2016-03-26 16:26:28 +01:00
Gwendal Roué 8257b05c8f FetchedRecordsController documentation 2016-03-26 14:21:17 +01:00
Gwendal Roué 0912139fc5 FetchedRecordsController documentation 2016-03-26 14:10:40 +01:00
Gwendal Roué 4592566748 FetchedRecordsController documentation 2016-03-26 13:41:00 +01:00
Gwendal Roué 22851dd9e8 FetchedRecordsController: fix indexPathForRecord 2016-03-26 13:37:56 +01:00
Gwendal Roué 87bab96097 FetchedRecordsController only tracks changes when it has a delegate. 2016-03-26 13:35:00 +01:00
Gwendal Roué 81ed566467 FetchedRecordsController TODO 2016-03-26 12:17:52 +01:00
Gwendal Roué 336220d998 FetchedRecordsController documentation 2016-03-26 08:34:08 +01:00
Gwendal Roué 859e71d976 FetchedRecordsController documentation 2016-03-26 08:23:09 +01:00
Gwendal Roué deb25d916d Merge branch 'master' into FetchedRecordsController
Conflicts:
	TODO.md
2016-03-26 07:36:59 +01:00
Gwendal Roué c412a01fa6 README.md 2016-03-25 21:13:04 +01:00
Gwendal Roué 2a9be8a28c README.md 2016-03-25 21:08:00 +01:00
Gwendal Roué 310704e0c5 README.md 2016-03-25 21:07:17 +01:00
Gwendal Roué 03f89c9131 TODO.md 2016-03-25 20:57:43 +01:00
Gwendal Roué 8ed39f43b4 v0.53.0 2016-03-25 20:56:06 +01:00
Gwendal Roué 84292beef9 Document convenience conversions of SQLite 2016-03-25 20:43:41 +01:00
Gwendal Roué d612b86d7f Document the new behavior of Row.value() and DatabaseValue.value() 2016-03-25 20:18:07 +01:00
Gwendal Roué 93180d6843 CHANGELOG.md 2016-03-25 20:17:42 +01:00
Gwendal Roué 644ec3caec DatabaseValue.value() raises a fatal error when conversion of a non-NULL value fails. 2016-03-25 20:17:31 +01:00
Gwendal Roué bb5aa47d7b Tests for Row.databaseValue(atIndex:) and Row.databaseValue(named:) 2016-03-25 20:16:31 +01:00
Gwendal Roué b9338b31bc Row.databaseValue(atIndex:) and Row.databaseValue(named:) 2016-03-25 20:16:23 +01:00
Gwendal Roué 5ed3b39219 Rename DatabaseValue.unsafeValue() to failableValue() 2016-03-25 18:46:24 +01:00
Gwendal Roué ee55afe8c0 Row.value() no longer turns non-NULL values to nil, should the conversion fail. 2016-03-25 18:28:42 +01:00
Gwendal Roué 6bfab3d04a DatabaseValue.value() no longer turns non-NULL values to nil, should the conversion fail. The new method DatabaseValue.unsafeValue() has the old, information-discarding, behavior. 2016-03-25 13:56:38 +01:00
Gwendal Roué 5f84f1378b TODO.md 2016-03-25 09:32:09 +01:00
Gwendal Roué 18a63504ed FetchedRecordsController documentation 2016-03-25 08:45:12 +01:00
Gwendal Roué 44f80dc385 README.md 2016-03-24 14:19:43 +01:00
Gwendal Roué fe5af8308c CHANGELOG.md 2016-03-24 14:10:04 +01:00
Gwendal Roué 197fc48d92 v0.52.1 2016-03-24 14:06:57 +01:00
Gwendal Roué 293268a004 Query interface: fix SQL generation for boolean tests
For example,`valid == true` now generates `"valid"`
2016-03-24 13:59:43 +01:00
Gwendal Roué c558d8fcaa Query interface: fix SQL generation for boolean tests
For example,`valid == true` now generates `"valid" <> 0`
2016-03-24 13:50:52 +01:00
Gwendal Roué b13ad57ea5 FetchedRecordsController: Back to delegate pattern 2016-03-24 13:35:11 +01:00
Gwendal Roué eba839b58e FetchedRecordsController: Cleanup 2016-03-24 08:37:19 +01:00
Gwendal Roué 36a480a5fc FetchedRecordsController: Clean up 2016-03-24 06:33:05 +01:00
Gwendal Roué 68c83ea156 README.md 2016-03-24 05:16:33 +01:00
Gwendal Roué 9102c94db2 FetchedRecordsController: Fix tableView crashes 2016-03-23 20:04:00 +01:00
Gwendal Roué 26d6330771 TODO.md 2016-03-23 14:18:22 +01:00
Gwendal Roué c123d27b89 README.md 2016-03-23 13:59:03 +01:00
Gwendal Roué 8aa5324892 README.md 2016-03-23 13:56:09 +01:00
Gwendal Roué fb448e27ad FetchedRecordsController: Still some tableView crashes 2016-03-23 13:50:21 +01:00
Gwendal Roué b24c872b52 RowConvertible.awakeFromFetch loses its database argument. FetchedRecordsController lazily instantiates records. 2016-03-23 13:44:05 +01:00
Gwendal Roué fdb31f37ba FetchedRecordsController: let the user choose the callback queue 2016-03-23 13:24:52 +01:00
Gwendal Roué 87733729b1 Merge branch 'master' into FetchedRecordsController
Conflicts:
	GRDB.xcworkspace/contents.xcworkspacedata
2016-03-23 13:15:35 +01:00
Gwendal Roué 09cbbb4570 Fix GRDBiOSTests target 2016-03-23 13:13:40 +01:00
Gwendal Roué cc2489e4ed Fix path to Tour.playground 2016-03-23 09:53:21 +01:00
Gwendal Roué 82d71b637d FetchedRecordsController: TODO 2016-03-23 09:08:46 +01:00
Gwendal Roué c4c0e67407 FetchedRecordsController.recordAtIndexPath returns a non-optional (as NSFetchedResultsController does) 2016-03-23 09:08:38 +01:00
Gwendal Roué d0c5e98366 FetchedRecordsController: add initializer that compares record by primary key (if the record adopts MutablePersistable) 2016-03-23 08:54:02 +01:00
Gwendal Roué 83c5afdd2d FetchedRecordsController: define record comparison function in the controller’s initializer 2016-03-23 08:32:57 +01:00
Gwendal Roué c46663007b Merge branch 'master' into FetchedRecordsController
Conflicts:
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/MasterViewController.swift
2016-03-23 08:22:55 +01:00
Gwendal Roué df748e5e75 README.md 2016-03-23 08:19:05 +01:00
Gwendal Roué e98685b6cc Modernize GRDBDemoiOS 2016-03-23 08:07:28 +01:00
Gwendal Roué 2374c67975 TODO.md 2016-03-23 07:59:35 +01:00
Gwendal Roué 30f288a6b9 FetchedRecordsController: update for Swift 2.2 2016-03-22 21:34:47 +01:00
Gwendal Roué aea7609e0b Merge branch 'master' into FetchedRecordsController 2016-03-22 21:29:46 +01:00
Gwendal Roué 700b256cad Merge commit 'a0b5f87b7d83655efa010c24f654ab03a97a1afa' into FetchedRecordsController 2016-03-22 21:06:59 +01:00
Gwendal Roué 64b4372a18 Merge commit '557fbc21efd227e50e790b1149907720a91fe346' into FetchedRecordsController 2016-03-22 21:06:42 +01:00
Gwendal Roué 32461d221a Merge commit '7de27389aa89f731b977e2d046c8b12ff2191e5d' into FetchedRecordsController 2016-03-22 21:06:04 +01:00
Gwendal Roué b9190e116a README.md 2016-03-22 20:54:00 +01:00
Gwendal Roué 2d6247d48a README.md 2016-03-22 20:52:37 +01:00
Gwendal Roué 4aaf001885 README.md 2016-03-22 20:50:36 +01:00
Gwendal Roué cc5726577e README.md 2016-03-22 20:34:44 +01:00
Gwendal Roué 626ae53057 README.md 2016-03-22 20:33:18 +01:00
Gwendal Roué ff69f6fdfc README.md 2016-03-22 20:31:28 +01:00
Gwendal Roué 3178af0074 README.md 2016-03-22 20:29:44 +01:00
Gwendal Roué 98a93346fc Refactor concurrency documentation 2016-03-22 20:27:14 +01:00
Gwendal Roué 01eea12f4e Typo 2016-03-22 14:12:21 +01:00
Gwendal Roué 1b78881f78 Update performance tests 2016-03-22 14:11:36 +01:00
Gwendal Roué a0b5f87b7d Replace prebuilt Realm frameworks with source (v0.98.5) 2016-03-22 13:38:45 +01:00
Gwendal Roué 557fbc21ef Performance tests target ccgus/fmdb v2.6.2 and stephencelis/SQLite.swift v0.9.2 2016-03-22 09:26:30 +01:00
Gwendal Roué 7de27389aa TODO.md 2016-03-22 08:49:30 +01:00
Gwendal Roué 049148305f Simplify throwing initializers since Swift 2.2 allows partial initialization 2016-03-22 08:28:55 +01:00
Gwendal Roué 90f468c329 Remove Swift warning 2016-03-21 23:31:10 +01:00
Gwendal Roué cd7acbc4ce v0.52.0 2016-03-21 23:18:45 +01:00
Gwendal Roué 907f020bf6 Update module.modulemap for latest Xcode 7.3 2016-03-21 23:14:37 +01:00
Gwendal Roué a6af89755d Merge branch 'master' into Swift2.2 2016-03-21 23:09:02 +01:00
Gwendal Roué e3ee49a868 FetchedRecordsController: properly serialize computations, require client access from main thread, fix known crashers 2016-03-21 14:08:36 +01:00
Gwendal Roué af538c4feb Improve test for migration with disabled foreign key checks 2016-03-18 06:44:24 +01:00
Gwendal Roué 4e5d5aac8c CHANGELOG.md 2016-03-18 06:26:47 +01:00
Gwendal Roué 5c8526d197 TODO.md 2016-03-18 06:26:40 +01:00
Gwendal Roué 4f13055a45 README.md 2016-03-18 06:22:26 +01:00
Gwendal Roué 2d7a035297 TODO.md 2016-03-18 06:21:32 +01:00
Gwendal Roué cc6f2c00df Fix ==(Row, Row) 2016-03-18 06:21:22 +01:00
Gwendal Roué 3293a33f38 Row adopts Equatable 2016-03-18 06:21:16 +01:00
Gwendal Roué 5e6dd56933 README.md 2016-03-18 06:20:25 +01:00
Gwendal Roué 6104d6193c FetchedRecordsController: found crashers 2016-03-18 06:17:13 +01:00
Gwendal Roué b45c711483 FetchedResultsController: replace "Result" by "Record", and "Change" by "Event" (this leaves changes free for actual row changes) 2016-03-17 13:27:06 +01:00
Gwendal Roué bebcefddcc FetchedResultsController: replace Delegate protocol with callbacks.
This change was required because the generic delegate methods did prevent the delegate to know the type of the changed objects.
2016-03-17 13:15:27 +01:00
Gwendal Roué 68a9089d14 Fix Tour.playground path 2016-03-17 13:14:41 +01:00
Gwendal Roué c6f96906ca Avoid build errors by using ad-hoc Swift modules that import the right sqlite3 header depending on the platform (MacOSX, iPhoneOS, iPhoneSimulator). 2016-03-17 08:54:09 +01:00
Gwendal Roué 9733fb22fd Merge branch 'master' into Swift2.2 2016-03-17 08:19:51 +01:00
Gwendal Roué e6010e334a One modulemap per target 2016-03-17 08:18:49 +01:00
Gwendal Roué 4f427601d4 Dictionary(_ sequence:) renamed to Dictionary(keyValueSequence:) 2016-03-17 08:08:26 +01:00
Gwendal Roué a716a5788d JSONSynchronization.playground: update for Swift 2.2 2016-03-17 08:07:59 +01:00
Gwendal Roué a308ffebeb Merge branch 'master' of github.com:groue/GRDB.swift into Swift2.2 2016-03-17 08:02:06 +01:00
Gwendal Roué 649667a403 Merge pull request #29 from mpurland/Swift2.2
Fixed Swift 2.2 compile error
2016-03-17 07:11:56 +01:00
Matthew Purland 97f9805afa Fixed Swift 2.2 compile error 2016-03-16 23:01:26 -07:00
Gwendal Roué 6d0cdcd20b FetchedResultsController: improve delegate API by extracting the rarely used changed object from the ResultChange enum 2016-03-16 23:33:31 +01:00
Gwendal Roué a8e85f2c41 FetchedResultsController: cleanup 2016-03-16 22:43:04 +01:00
Gwendal Roué 2e11551bd7 FetchedResultsController: cleanup 2016-03-16 22:04:23 +01:00
Gwendal Roué ea7aae603d FetchedResultsController: full features! 2016-03-16 21:49:30 +01:00
Gwendal Roué 6c3976e657 FetchedResultsController demo app tweak 2016-03-16 20:06:11 +01:00
Gwendal Roué 09abd1e5cd FetchedResultsController: don’t notify delegate when there is no change 2016-03-16 20:05:13 +01:00
Gwendal Roué d5d467192d TODO.md 2016-03-16 15:49:04 +01:00
Gwendal Roué d455e50a27 FetchedResultsController (breaking commit): attempt to communicate updates and changes 2016-03-16 14:11:15 +01:00
Gwendal Roué f7d9970842 Fix ==(Row, Row) 2016-03-16 14:09:29 +01:00
Gwendal Roué b4a7ba239c FetchedResultsController: improve general API consistency: use unlabelled arguments 2016-03-16 09:12:10 +01:00
Gwendal Roué 86e3fc7075 FetchedResultsController: improve resultAtIndexPath performance 2016-03-16 09:07:00 +01:00
Gwendal Roué be2ef28fad FetchedResultsController: throw errors for invalid sql arguments 2016-03-16 09:02:44 +01:00
Gwendal Roué 97fcdf9ce6 FetchedResultsController: remove Equatable requirement on fetched type. 2016-03-16 08:59:28 +01:00
Gwendal Roué b9f7ea187d FetchedResultsController: remove Equatable requirement on fetched type. 2016-03-16 08:40:24 +01:00
Gwendal Roué c8f5f1ae1d Row adopts Equatable 2016-03-16 08:36:55 +01:00
Gwendal Roué 92b8b00a49 FetchedResultsController: remove TableMapping requirement 2016-03-15 20:26:34 +01:00
Gwendal Roué eeddb32ab6 FetchedResultsController: only listen to changes in observed tables 2016-03-15 20:23:23 +01:00
Gwendal Roué c1a59a015c FetchedResultsController: perform the changes computation in a background queue 2016-03-15 19:49:00 +01:00
Gwendal Roué bc3b13d719 FetchedResultsController.indexPathForResult(_) is not implemented 2016-03-15 19:30:06 +01:00
Gwendal Roué 29dcbaeaa3 FetchedResultsController: add optional arguments to the sql initializer (be consistent with the rest of the library) 2016-03-15 19:29:17 +01:00
Gwendal Roué 46f6e6d1ea FetchedResultsController: gather SQL and FetchRequest in a common Source enum 2016-03-15 19:27:33 +01:00
Gwendal Roué c76b7a8b77 FetchedResultsController: gather SQL and FetchRequest in a common Source enum 2016-03-15 19:21:35 +01:00
Gwendal Roué 8514513af3 FetchedResultsController: register as a transaction observer once and only once. Don’t unregister, since transaction observers are weakly referenced. 2016-03-15 19:15:12 +01:00
Gwendal Roué dc2ee92404 Up to date GRDBDemoiOS demo of FetchedResultsController 2016-03-15 19:13:27 +01:00
Gwendal Roué 7cd5b881b2 Merge branch 'master' into FetchedRecordsController 2016-03-15 19:05:20 +01:00
Gwendal Roué 63545c1f08 Documentation 2016-03-15 19:05:04 +01:00
Gwendal Roué 171862097e Merge branch 'master' into FetchedRecordsController
Conflicts:
	GRDB.xcworkspace/contents.xcworkspacedata
2016-03-15 13:48:13 +01:00
Gwendal Roué ab69f64957 TODO.md 2016-03-15 09:51:49 +01:00
Gwendal Roué 91bf2a85d0 README.md 2016-03-15 09:12:34 +01:00
Gwendal Roué 6315aad0bc Improve performance of row copy 2016-03-15 08:43:48 +01:00
Gwendal Roué 613a0386bd Performance tests sure "modern" API calls 2016-03-15 08:42:51 +01:00
Gwendal Roué a79565bb65 README.md 2016-03-14 13:49:44 +01:00
Gwendal Roué 63213d7f10 v0.51.2 2016-03-14 13:46:35 +01:00
Gwendal Roué 218d7a7f15 DatabaseStore: fix a race condition that could make us miss file attributes 2016-03-14 09:59:33 +01:00
Gwendal Roué 4f5e87b1e1 Documentation 2016-03-14 09:01:33 +01:00
Gwendal Roué 8ef27ccbf6 Documentation 2016-03-14 08:55:00 +01:00
Gwendal Roué b1e3aaf399 README.md 2016-03-14 05:33:23 +01:00
Gwendal Roué 1af1c84132 README.md 2016-03-14 05:32:02 +01:00
Gwendal Roué c6a00d0e45 Performance tests for Realm 0.98.4 2016-03-13 22:00:48 +01:00
Gwendal Roué 319556daec README.md 2016-03-13 19:55:23 +01:00
Gwendal Roué c096736e2b v0.51.1 2016-03-13 19:52:23 +01:00
Gwendal Roué afea1c4175 Remove useless complexity 2016-03-13 19:45:54 +01:00
Gwendal Roué f00dda7f43 Improve performance by removing useless retain/release 2016-03-13 19:20:52 +01:00
Gwendal Roué 8bc52b29e7 Attempt at optimizing reference counting 2016-03-13 17:42:06 +01:00
Gwendal Roué 967b10311e Cleanup tests 2016-03-13 17:41:38 +01:00
Gwendal Roué 09a600d955 Make DatabaseReader a class protocol 2016-03-13 17:38:33 +01:00
Gwendal Roué a99e064c28 v0.51.0 2016-03-13 14:49:08 +01:00
Gwendal Roué 01f1043e1a Fix project organization 2016-03-13 14:39:13 +01:00
Gwendal Roué c3316346ac Documentation 2016-03-13 14:33:06 +01:00
Gwendal Roué 19da676caf Configuration.fileAttributes: apply file attributes to database files 2016-03-13 14:16:17 +01:00
Gwendal Roué 39a14d6528 Documentation 2016-03-13 10:01:35 +01:00
Gwendal Roué 198c4c7b5a Documentation 2016-03-13 09:54:32 +01:00
Gwendal Roué 698f3b4fad Documentation 2016-03-13 09:31:59 +01:00
Gwendal Roué f3bee9e85f Documentation 2016-03-13 09:30:53 +01:00
Gwendal Roué 75f1b045c9 Documentation 2016-03-13 09:27:56 +01:00
Gwendal Roué 24bcee02c1 Documentation 2016-03-13 07:38:23 +01:00
Gwendal Roué 2b159dfb02 Documentation 2016-03-13 07:36:58 +01:00
Gwendal Roué 67f79f20dc Documentation 2016-03-13 07:35:40 +01:00
Gwendal Roué a992871cb9 Documentation 2016-03-13 07:32:35 +01:00
Gwendal Roué 802e67d8ba Documentation 2016-03-13 07:31:46 +01:00
Gwendal Roué 5169ba8798 Documentation 2016-03-13 07:30:13 +01:00
Gwendal Roué f41f9c2d87 Documentation 2016-03-13 07:28:49 +01:00
Gwendal Roué d720433880 Documentation 2016-03-13 07:21:02 +01:00
Gwendal Roué 11747f43ee Documentation 2016-03-13 07:02:36 +01:00
Gwendal Roué 66b0163f7b Documentation 2016-03-12 23:45:43 +01:00
Gwendal Roué e7006a9ac4 Documentation 2016-03-12 23:42:11 +01:00
Gwendal Roué 9ace4d7cc6 Documentation 2016-03-12 23:28:43 +01:00
Gwendal Roué d3d8641053 Documentation 2016-03-12 21:55:21 +01:00
Gwendal Roué 2de46d7038 TODO.md 2016-03-12 21:55:17 +01:00
Gwendal Roué d1062ec050 Documentation 2016-03-12 21:40:08 +01:00
Gwendal Roué 079ba05b88 Documentation 2016-03-12 21:16:26 +01:00
Gwendal Roué a47fef9d19 Documentation 2016-03-12 21:06:01 +01:00
Gwendal Roué adbca4ba1a TODO.md 2016-03-12 21:03:08 +01:00
Gwendal Roué 41ac9563ef Documentation 2016-03-12 20:36:07 +01:00
Gwendal Roué 9a48bcc013 Documentation 2016-03-12 20:34:21 +01:00
Gwendal Roué aba08042ed Documentation 2016-03-12 20:32:05 +01:00
Gwendal Roué 9f9804c8a3 Documentation 2016-03-12 20:30:33 +01:00
Gwendal Roué 1f1ac06c91 Documentation 2016-03-12 19:22:26 +01:00
Gwendal Roué d2f3f9d1b5 Documentation 2016-03-12 18:57:22 +01:00
Gwendal Roué 111688ff18 Typo 2016-03-12 18:53:38 +01:00
Gwendal Roué a81a29c952 Documentation 2016-03-12 18:48:57 +01:00
Gwendal Roué 9c3e677e0c Make Database.read() conform to the isolation level required by DatabaseReader. 2016-03-12 18:36:06 +01:00
Gwendal Roué 02ce13c858 v0.50.1 2016-03-12 18:04:32 +01:00
Gwendal Roué 523d111ec6 Documentation 2016-03-12 18:02:21 +01:00
Gwendal Roué dd6d186a08 README.md 2016-03-12 17:43:30 +01:00
Gwendal Roué 9b8aae29dd README.md 2016-03-12 17:40:39 +01:00
Gwendal Roué cf406c280d README.md 2016-03-12 17:30:46 +01:00
Gwendal Roué 7917343593 README.md 2016-03-12 17:20:19 +01:00
Gwendal Roué 588e0c9bbc README.md 2016-03-12 16:22:07 +01:00
Gwendal Roué f054a0f4fd README.md 2016-03-12 15:39:38 +01:00
Gwendal Roué dac5b6cae8 README.md 2016-03-12 15:35:04 +01:00
Gwendal Roué 4c1fe51786 README.md 2016-03-12 15:32:31 +01:00
Gwendal Roué bcafd3c9b9 README.md 2016-03-12 15:32:15 +01:00
Gwendal Roué 318a485a92 README.md 2016-03-12 15:31:19 +01:00
Gwendal Roué 1a46f37e92 README.md 2016-03-12 15:25:46 +01:00
Gwendal Roué f9484c1ba5 README.md 2016-03-12 15:09:22 +01:00
Gwendal Roué 6f3a3c9514 Unicode chapter 2016-03-12 15:07:12 +01:00
Gwendal Roué 2e9b009aa5 README.md 2016-03-12 14:52:34 +01:00
Gwendal Roué 4458ebd03e README.md 2016-03-12 14:51:49 +01:00
Gwendal Roué 84e5e488a9 DatabaseGenerator retain the database connection. Tests for various opportunities of memory leaking, and misuse of weak references. 2016-03-12 14:47:53 +01:00
Gwendal Roué 1df41fbd29 Tests for DatabaseQueue/Pool connection closing 2016-03-12 13:53:49 +01:00
Gwendal Roué b5d95fda22 TODO.md 2016-03-12 12:56:01 +01:00
Gwendal Roué 3c5e144493 README.md 2016-03-12 12:50:22 +01:00
Gwendal Roué b1e467d34f README.md 2016-03-12 12:46:52 +01:00
Gwendal Roué 390bc93e54 README.md 2016-03-12 12:43:42 +01:00
Gwendal Roué a7b2a1ed70 README.md 2016-03-12 12:41:21 +01:00
Gwendal Roué 7e7fd97075 README.md 2016-03-12 12:40:38 +01:00
Gwendal Roué 4bf97204d1 README.md organization 2016-03-12 12:36:14 +01:00
Gwendal Roué b9b2b179e1 v0.50.0 2016-03-12 12:04:49 +01:00
Gwendal Roué e3ef424a41 DatabaseReader and DatabaseWriter cleanup 2016-03-12 12:00:06 +01:00
Gwendal Roué 387e7bc2f5 Tour.playground 2016-03-12 11:09:35 +01:00
Gwendal Roué 328d21e526 Documentation 2016-03-12 10:07:01 +01:00
Gwendal Roué 85579403e9 CHANGELOG.md 2016-03-12 09:15:48 +01:00
Gwendal Roué 08358a52a7 Drop UserDefaults.registerDefaults() 2016-03-12 09:15:15 +01:00
Gwendal Roué 6d1c190a13 TODO.md 2016-03-12 09:03:58 +01:00
Gwendal Roué 4208c9f2ff Update UserDefaults.playground 2016-03-12 08:58:54 +01:00
Gwendal Roué a14c3a2a60 Documentation 2016-03-12 08:47:33 +01:00
Gwendal Roué c8afca6485 Tests for DatabaseQueue.execute() and DatabasePool.execute() 2016-03-12 08:46:58 +01:00
Gwendal Roué eecaa2a394 Documentation 2016-03-12 08:27:51 +01:00
Gwendal Roué 62a37ac1f4 Documentation 2016-03-12 08:25:58 +01:00
Gwendal Roué a8dd424211 DatabaseMigrator uses DatabaseWriter 2016-03-12 08:25:50 +01:00
Gwendal Roué 9e9fafcc5c Documentation 2016-03-12 08:21:17 +01:00
Gwendal Roué 78dc8c3188 Documentation 2016-03-12 07:36:35 +01:00
Gwendal Roué 6ddcc74697 Documentation 2016-03-12 07:35:34 +01:00
Gwendal Roué 79c34eb6d2 Documentation 2016-03-12 07:17:29 +01:00
Gwendal Roué cdf08821bb Documentation 2016-03-12 07:14:55 +01:00
Gwendal Roué e54e9068dc Documentation 2016-03-12 07:13:00 +01:00
Gwendal Roué 2af32c76eb TODO 2016-03-12 07:12:40 +01:00
Gwendal Roué ae8ffeabc9 Cleanup 2016-03-12 07:12:35 +01:00
Gwendal Roué e818d40c2a Documentation 2016-03-11 19:44:31 +01:00
Gwendal Roué e52a01abbe Documentation 2016-03-11 19:41:39 +01:00
Gwendal Roué b81f57f1c9 Documentation 2016-03-11 19:35:25 +01:00
Gwendal Roué 8221ff520c Tests for DatabasePool and DatabaseQueue as DatabaseWriter 2016-03-11 19:15:23 +01:00
Gwendal Roué b68f1e278e DatabasePool and DatabaseQueue adopt DatabaseWriter 2016-03-11 19:14:59 +01:00
Gwendal Roué 18b996e5bd Persistable.delete() uses DatabaseWriter instead of Database 2016-03-11 18:56:09 +01:00
Gwendal Roué 50cc857a3a Persistable.save() uses DatabaseWriter instead of Database 2016-03-11 18:51:34 +01:00
Gwendal Roué ea04588865 Persistable.update() uses DatabaseWriter instead of Database 2016-03-11 18:47:03 +01:00
Gwendal Roué 47d1202e57 Introduce DatabaseWriter 2016-03-11 18:42:02 +01:00
Gwendal Roué 1ab5b8ed9c Documentation 2016-03-11 18:24:40 +01:00
Gwendal Roué 61f944fdaa Cleanup 2016-03-11 18:12:42 +01:00
Gwendal Roué 5d2ee3140e v0.49.0 2016-03-11 17:43:23 +01:00
Gwendal Roué ba461c7e98 Documentation 2016-03-11 17:40:26 +01:00
Gwendal Roué 389ddefc1d Documentation 2016-03-11 17:39:24 +01:00
Gwendal Roué 2a2421896d Documentation 2016-03-11 17:36:07 +01:00
Gwendal Roué b3c0d021fd Documentation 2016-03-11 17:34:54 +01:00
Gwendal Roué f21ddc0f7f Documentation 2016-03-11 17:25:12 +01:00
Gwendal Roué 2e4dec741a Documentation 2016-03-11 17:24:08 +01:00
Gwendal Roué 2fc1253836 CHANGELOG.md 2016-03-11 17:21:21 +01:00
Gwendal Roué 479308637d Test that read-only DatabasePool has concurrent reads, without activating the WAL mode 2016-03-11 17:21:11 +01:00
Gwendal Roué eb513e87d2 Transaction observers are now added to database queues and pools 2016-03-11 17:08:31 +01:00
Gwendal Roué 96ead6d1c6 Documentation 2016-03-11 16:52:19 +01:00
Gwendal Roué a9db99c569 Documentation 2016-03-11 15:31:02 +01:00
Gwendal Roué 42084e1302 TODO.md 2016-03-11 14:34:51 +01:00
Gwendal Roué 3e75af7c14 Make DatabaseReader a class protocol 2016-03-11 14:34:49 +01:00
Gwendal Roué c7ad60522d Modernize Record.playground 2016-03-11 14:30:28 +01:00
Gwendal Roué 7d8834027d Documentation 2016-03-11 14:22:03 +01:00
Gwendal Roué 7a64719708 Documentation 2016-03-11 14:19:56 +01:00
Gwendal Roué 228c36d164 Documentation 2016-03-11 14:02:57 +01:00
Gwendal Roué 085a542b4b Documentation 2016-03-11 13:59:28 +01:00
Gwendal Roué db6546a959 Documentation 2016-03-11 13:48:17 +01:00
Gwendal Roué d47f443a25 Documentation 2016-03-11 13:37:25 +01:00
Gwendal Roué 4c261ff49e Documentation 2016-03-11 13:26:50 +01:00
Gwendal Roué 02d11108de Documentation 2016-03-11 13:26:08 +01:00
Gwendal Roué 3534325d7c Documentation 2016-03-11 13:24:29 +01:00
Gwendal Roué ce48a29499 Documentation 2016-03-11 13:23:40 +01:00
Gwendal Roué 4a34a610fe Documentation 2016-03-11 13:22:15 +01:00
Gwendal Roué 840e2b6b0b Documentation 2016-03-11 13:20:31 +01:00
Gwendal Roué f95b058b99 Read-only DatabasePool 2016-03-11 13:20:18 +01:00
Gwendal Roué cafe8b5953 Documentation 2016-03-11 12:27:09 +01:00
Gwendal Roué dbce44fe24 Documentation 2016-03-11 12:06:53 +01:00
Gwendal Roué 04289d5233 TODO.md 2016-03-11 09:56:08 +01:00
Gwendal Roué 67afe993a7 Documentation 2016-03-11 09:04:14 +01:00
Gwendal Roué fadfa11ea1 Documentation 2016-03-11 09:02:36 +01:00
Gwendal Roué decfcad2af Documentation 2016-03-11 09:01:31 +01:00
Gwendal Roué bb29f633c5 Documentation 2016-03-11 08:59:17 +01:00
Gwendal Roué 5fd2212278 DatabaseReader WIP 2016-03-11 08:13:10 +01:00
Gwendal Roué 6f4a29e6f8 DatabaseReader WIP 2016-03-11 07:34:44 +01:00
Gwendal Roué 517552fed8 Merge branch 'master' into DatabaseAccess 2016-03-11 06:41:46 +01:00
Gwendal Roué 9427c89456 README.md 2016-03-11 06:41:14 +01:00
Gwendal Roué 758663c3a1 README.md 2016-03-11 06:36:41 +01:00
Gwendal Roué 7364d99b6b WIP 2016-03-10 18:51:08 +01:00
Gwendal Roué 694c38dc62 README.md 2016-03-10 14:46:29 +01:00
Gwendal Roué 164a751f3e TODO.md 2016-03-10 14:02:56 +01:00
Gwendal Roué 44dddd28ef Use sqlite3.h stored in /Applications/Xcode-beta.app/ 2016-02-10 19:10:24 +01:00
Gwendal Roué d74cf435ed Swift2.2 2016-02-10 19:09:28 +01:00
Pascal Edmond 0808a10b03 merge 2016-02-09 17:44:33 +01:00
Pascal Edmond 3ec52fa83d Use FetchedResultController with brand new FetchRequest 2016-01-29 16:08:41 +01:00
Pascal Edmond 46e44131d3 Add visible and position's columns to be used in FetchRequest 2016-01-29 16:05:06 +01:00
Pascal Edmond 3c28277f15 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2016-01-29 15:55:27 +01:00
Pascal Edmond 2c7334b1c1 Change<T> become ResultChange<T> + Prepare for FetchRequest 2016-01-29 15:55:09 +01:00
Pascal Edmond 85e578f5ae Disable manual ordering for now 2016-01-29 12:12:07 +01:00
Pascal Edmond 7b31e75298 move FetchedResultsController tests 2016-01-29 11:56:18 +01:00
Pascal Edmond ccda6ba9ba DatabaseTableMapping protocol has been renamed TableMapping 2016-01-29 11:55:55 +01:00
Pascal Edmond 042163eb58 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController
Conflicts:
	DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/AppDelegate.swift
	DemoApps/GRDBDemoiOS/GRDBDemoiOS/MasterViewController.swift
	GRDB.xcodeproj/project.pbxproj
	Tests/Performance/fmdb
2016-01-29 11:49:57 +01:00
Pascal Edmond 3518b4d2de WIP 2016-01-29 11:33:09 +01:00
Pascal Edmond 07afc8a130 WIP 2016-01-29 11:30:09 +01:00
Pascal Edmond 9c7e13fc64 WIP 2016-01-29 11:13:00 +01:00
Pascal Edmond 45b184b628 Person order shuffle 2016-01-29 11:12:42 +01:00
Pascal Edmond c589080ef2 Person ordering 2016-01-29 10:57:40 +01:00
Pascal Edmond 34850a89fa WIP 2016-01-21 18:03:01 +01:00
Pascal Edmond 469d398988 Refactoring + better descriptions 2016-01-21 18:02:48 +01:00
Pascal Edmond b127e90e93 Prepare for reordering 2016-01-21 18:01:45 +01:00
Pascal Edmond 0d49108cb1 GRDBiOSTests building again 2016-01-21 10:58:18 +01:00
Pascal Edmond 629a98bbb5 First tests passing 2016-01-20 19:34:35 +01:00
Pascal Edmond 0cea2b2e3c Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2016-01-20 16:50:10 +01:00
Pascal Edmond a336b44ddb Refactor FetchedResultsController 2016-01-19 15:33:02 +01:00
Pascal Edmond 16c26c09fb Refactor : FetchedRecordsController > FetchedResultsController 2016-01-19 13:46:04 +01:00
Gwendal Roué b0d60cc9da Merge branch 'MultipleTransactionObservers' of github.com:groue/GRDB.swift into FetchedRecordsController
Conflicts:
	GRDB/Core/Configuration.swift
	GRDB/Core/Database.swift
2016-01-15 15:07:08 +01:00
Pascal Edmond fe2be594be merge 2016-01-12 14:15:59 +01:00
Pascal Edmond dce273f714 Tests : disable all test but FetchedRecordsController's 2016-01-04 13:04:43 +01:00
Pascal Edmond 82813f57e1 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2016-01-04 13:03:37 +01:00
Pascal Edmond f76cb3bcba WIP 2016-01-04 13:03:22 +01:00
Pascal Edmond 9321bfa207 Tests : disable all test but FetchedRecordsController's 2016-01-04 13:03:17 +01:00
Pascal Edmond 6ecd147aad FetchedRecordsController : more tests 2015-12-23 17:03:59 +01:00
Pascal Edmond dc24c1faad FetchedRecordsController : bug fix 2015-12-23 17:03:46 +01:00
Pascal Edmond 03ce9602ea FetchedRecordsController : more Tests 2015-12-23 15:41:21 +01:00
Pascal Edmond 35772ab786 Database Transaction Observation : allow multiple observers 2015-12-23 15:03:06 +01:00
Pascal Edmond 0dad966d26 WIP Tests 2015-12-21 12:32:27 +01:00
Pascal Edmond e43bbe79bd WIP Tests 2015-12-18 13:14:24 +01:00
Pascal Edmond cec026495f WIP Tests 2015-12-17 16:42:50 +01:00
Pascal Edmond 0225f481de Update Tests 2015-12-17 16:35:17 +01:00
Pascal Edmond 67f00e70a3 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2015-12-17 16:06:14 +01:00
Pascal Edmond 8146bbca65 WIP 2015-12-17 16:06:00 +01:00
Pascal Edmond e8d5d6a190 WIP tests 2015-12-16 16:47:57 +01:00
Pascal Edmond 32f73fb816 merge 2015-12-16 16:25:05 +01:00
Pascal Edmond e0dc84c14a wit report object changes if possible 2015-12-16 16:15:13 +01:00
Pascal Edmond 65414f2b55 Person update to adopt new protocols 2015-12-16 16:14:52 +01:00
Pascal Edmond b3feaf91d4 Merge branch 'FetchedRecordsController' of github.com:pakko972/GRDB.swift into FetchedRecordsController 2015-12-15 12:01:31 +01:00
Pascal Edmond 587fc99023 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2015-12-15 12:01:14 +01:00
Pascal Edmond e1396673d9 Protocols 2015-12-15 12:00:50 +01:00
Pascal EDMOND c490721d6a Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2015-12-13 16:37:42 +01:00
Pascal Edmond 8fadc40656 Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController 2015-12-11 14:22:21 +01:00
Pascal Edmond 5ee6ccdf48 Update FetchedRecordsController + make use of its update APIs 2015-12-11 14:21:56 +01:00
Pascal Edmond 81c22fcbc2 Merge branch 'master' of https://github.com/groue/GRDB.swift 2015-12-09 18:15:49 +01:00
Pascal Edmond 0139618f37 WIP : Welcome FetchedRecordsController 2015-12-09 18:15:45 +01:00
464 changed files with 69802 additions and 27128 deletions

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
source 'https://rubygems.org'
gem 'xcpretty'
gem 'xcpretty-travis-formatter'
+16
View File
@@ -95,3 +95,19 @@ xcuserdata
# Performance test baselines
*.xcbaseline
# GRDBCustomSQLite USER configuration files
SQLiteCustom/GRDBCustomSQLite-USER.h
SQLiteCustom/GRDBCustomSQLite-USER.xcconfig
# CocoaPods test
Podfile.lock
Pods
# SPM
.build
Package.resolved
Tests/SPM/Packages
# Ruby
.ruby-version
+9
View File
@@ -4,3 +4,12 @@
[submodule "Tests/Performance/SQLite.swift"]
path = Tests/Performance/SQLite.swift
url = https://github.com/stephencelis/SQLite.swift.git
[submodule "Tests/Performance/Realm"]
path = Tests/Performance/Realm
url = https://github.com/realm/realm-cocoa.git
[submodule "SQLCipher/src"]
path = SQLCipher/src
url = https://github.com/groue/sqlcipher.git
[submodule "SQLiteCustom/src"]
path = SQLiteCustom/src
url = https://github.com/swiftlyfalling/SQLiteLib
+1
View File
@@ -0,0 +1 @@
4.0
+151
View File
@@ -0,0 +1,151 @@
language: objective-c
xcode_project: GRDB.xcodeproj
# Disable the default Travis-CI submodule logic
# The various make commands ensure that the appropriate submodules are retrieved
git:
submodules: false
jobs:
include:
###########################################
## Test GRDB
# Test GRDBOSX (Xcode 9)
- stage: Test GRDB
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBOSX (Xcode 9, macOS 10.12)
script: make test_framework_GRDBOSX
# Test GRDBWatchOS (Xcode 9)
- stage: Test GRDB
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBWatchOS (Xcode 9, watchOS)
script: make test_framework_GRDBWatchOS
# Test GRDBiOS (Xcode 9, iOS <MAXIMUM VERSION>)
- stage: Test GRDB
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBiOS (Xcode 9, iOS <MAX>)
script: make test_framework_GRDBiOS_maxTarget
# Test GRDBiOS (Xcode 9, iOS <MINIMUM VERSION>))
- stage: Test GRDB
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBiOS (Xcode 9, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget
# Test GRDB [SPM] (Xcode 9, macOS 10.12)
- stage: Test GRDB
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDB [SPM] (Xcode 9, macOS 10.12)
script: make test_SPM
###########################################
## Test GRDB (Custom SQLite)
# Test GRDBCustomSQLiteOSX (Xcode 9)
- stage: Test GRDB + Custom SQLite
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCustomSQLiteOSX (Xcode 9, macOS 10.12)
script: make test_framework_GRDBCustomSQLiteOSX
# Test GRDBCustomSQLiteiOS (Xcode 9, iOS <MAXIMUM VERSION>)
- stage: Test GRDB + Custom SQLite
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCustomSQLiteiOS (Xcode 9, iOS <MAX>)
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget
# Test GRDBCustomSQLiteiOS (Xcode 9, iOS <MINIMUM VERSION>))
- stage: Test GRDB + Custom SQLite
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCustomSQLiteiOS (Xcode 9, iOS <MIN>)
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test GRDB (SQLCipher)
# Test GRDBCipherOSX (Xcode 9)
- stage: Test GRDB + SQLCipher
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCipherOSX (Xcode 9, macOS 10.12)
script: make test_framework_GRDBCipherOSX
# Test GRDBCipheriOS (Xcode 9, iOS <MAXIMUM VERSION>)
- stage: Test GRDB + SQLCipher
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCipheriOS (Xcode 9, iOS <MAX>)
script: make test_framework_GRDBCipheriOS_maxTarget
# Test GRDBCipheriOS (Xcode 9, iOS <MINIMUM VERSION>))
- stage: Test GRDB + SQLCipher
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=GRDBCipheriOS (Xcode 9, iOS <MIN>)
script: make test_framework_GRDBCipheriOS_minTarget
###########################################
## Test Installation Methods
# Manual Install
- stage: Test Installation
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=Manual Install
script: make test_install_manual
# Manual Install (GRDBCipher)
- stage: Test Installation
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode9
env:
- TID=Manual Install (GRDBCipher)
script: make test_install_GRDBCipher
# Cocoapods Lint
- stage: Test Installation
osx_image: xcode9
install:
- gem install cocoapods # Since Travis is not always on latest version
env:
- TID=Cocoapods
script: make test_CocoaPodsLint
# SPM Install
- stage: Test Installation
osx_image: xcode9
env:
- TID=SPM
script: make test_install_SPM
## The following doesn’t work, as `make test_CarthageBuild` does not yet work.
## Carthage Build
#- stage: Carthage
# osx_image: xcode9
# before_install:
# - brew update
# - brew outdated carthage || brew upgrade carthage
# script: make test_CarthageBuild
+2803 -3
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"screenWidth" : "{130,145}",
"scale" : "2x"
},
{
"idiom" : "watch",
"screenWidth" : "{146,165}",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,28 @@
{
"assets" : [
{
"idiom" : "watch",
"filename" : "Circular.imageset",
"role" : "circular"
},
{
"idiom" : "watch",
"filename" : "Extra Large.imageset",
"role" : "extra-large"
},
{
"idiom" : "watch",
"filename" : "Modular.imageset",
"role" : "modular"
},
{
"idiom" : "watch",
"filename" : "Utilitarian.imageset",
"role" : "utilitarian"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"screenWidth" : "{130,145}",
"scale" : "2x"
},
{
"idiom" : "watch",
"screenWidth" : "{146,165}",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"screenWidth" : "{130,145}",
"scale" : "2x"
},
{
"idiom" : "watch",
"screenWidth" : "{146,165}",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"screenWidth" : "{130,145}",
"scale" : "2x"
},
{
"idiom" : "watch",
"screenWidth" : "{146,165}",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,42 @@
import WatchKit
class ExtensionDelegate: NSObject, WKExtensionDelegate {
func applicationDidFinishLaunching() {
// Perform any final initialization of your application.
}
func applicationDidBecomeActive() {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillResignActive() {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, etc.
}
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 {
// Use a switch statement to check the task type
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
// Be sure to complete the background task once you’re done.
backgroundTask.setTaskCompleted()
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()
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
// Be sure to complete the URL session task once you’re done.
urlSessionTask.setTaskCompleted()
default:
// make sure to complete unhandled task types
task.setTaskCompleted()
}
}
}
}
@@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>GRDBDemoWatchOS Extension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -13,12 +15,22 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>com.github.groue.GRDBDemoiOS.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
<key>WKExtensionDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
</dict>
</plist>
@@ -0,0 +1,16 @@
import WatchKit
import Foundation
import GRDB
import SQLite3
class InterfaceController: WKInterfaceController {
@IBOutlet var versionLabel: WKInterfaceLabel!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
let sqliteVersion = String(cString: sqlite3_libversion(), encoding: .utf8)
versionLabel.setText(sqliteVersion)
}
}
@@ -0,0 +1,55 @@
{
"images" : [
{
"size" : "24x24",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="12029"/>
</dependencies>
<scenes>
<!--Interface Controller-->
<scene sceneID="aou-V4-d1y">
<objects>
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModule="GRDBDemoWatchOS" customModuleProvider="target">
<items>
<group width="1" alignment="left" verticalAlignment="center" layout="vertical" id="tkk-aG-QQF">
<items>
<label alignment="center" text="SQLite version" id="dGA-xX-x8V"/>
<label alignment="center" text="Label" id="whi-N6-h8U"/>
</items>
</group>
</items>
<connections>
<outlet property="versionLabel" destination="whi-N6-h8U" id="5xN-Gj-yNt"/>
</connections>
</controller>
</objects>
</scene>
</scenes>
</document>
@@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>GRDBDemoiOS</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -13,12 +15,19 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>WKCompanionAppBundleIdentifier</key>
<string>com.github.groue.GRDBDemoiOS</string>
<key>WKWatchKitApp</key>
<true/>
</dict>
</plist>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FCA1E926430002582E0"
BuildableName = "GRDBDemoWatchOS Extension.appex"
BlueprintName = "GRDBDemoWatchOS Extension"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/GRDBDemoiOS">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "568E5FBE1E926430002582E0"
BuildableName = "GRDBDemoWatchOS.app"
BlueprintName = "GRDBDemoWatchOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56B036021E8D9EBE003B6DA4"
BuildableName = "GRDBDemoiOS.app"
BlueprintName = "GRDBDemoiOS"
ReferencedContainer = "container:GRDBDemoiOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,49 +1,11 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Set up database
setupDatabase()
// Set up view controllers
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
try! setupDatabase(application)
return true
}
func applicationDidReceiveMemoryWarning(application: UIApplication) {
// Release as much memory as possible.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) {
dbQueue.releaseMemory()
}
}
func applicationDidEnterBackground(application: UIApplication) {
let task = application.beginBackgroundTaskWithExpirationHandler(nil)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
// Release as much memory as possible.
dbQueue.releaseMemory()
application.endBackgroundTask(task)
}
}
// MARK: - Split view
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController, ontoPrimaryViewController primaryViewController:UIViewController) -> Bool {
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
if topAsDetailController.person == nil {
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
return true
}
return false
}
}
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
@@ -21,15 +31,27 @@
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
@@ -59,6 +81,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -16,29 +15,8 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 Gwendal Roué. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="20" y="559" width="560" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GRDBDemoiOS" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="20" y="180" width="560" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -1,131 +1,114 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11129.15" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UAh-8N-CM8">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11103.10"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Master-->
<scene sceneID="pY4-Hu-kfo">
<!--Hall Of Fame-->
<scene sceneID="8jG-C9-QsI">
<objects>
<navigationController title="Master" id="RMx-3f-FxP" sceneMemberID="viewController">
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Pmd-2v-anx">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="7bK-jq-Zjz" kind="relationship" relationship="rootViewController" id="tsl-Nk-0bq"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8fS-aE-onr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-38" y="-630"/>
</scene>
<!--Detail-->
<scene sceneID="yUG-lL-AsK">
<objects>
<viewController title="Detail" id="JEX-9P-axG" customClass="DetailViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="SYR-Wa-9uf"/>
<viewControllerLayoutGuide type="bottom" id="GAO-Cl-Wes"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="svH-Pt-448">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<tableViewController id="cyv-nk-Plb" customClass="SimplePersonsViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="oON-zg-8kO">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Detail view content goes here" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="0XM-y9-sOw">
<rect key="frame" x="20" y="292" width="560" height="17"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" size="system"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="0XM-y9-sOw" firstAttribute="leading" secondItem="svH-Pt-448" secondAttribute="leading" constant="20" symbolic="YES" id="Tsc-yG-G1q"/>
<constraint firstItem="0XM-y9-sOw" firstAttribute="centerY" secondItem="svH-Pt-448" secondAttribute="centerY" id="jWN-iV-94e"/>
<constraint firstAttribute="trailing" secondItem="0XM-y9-sOw" secondAttribute="trailing" constant="20" symbolic="YES" id="tHV-ZD-HQj"/>
</constraints>
</view>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Person" textLabel="XIE-DF-pSO" detailTextLabel="vyz-CH-eMb" style="IBUITableViewCellStyleValue1" id="V5t-oJ-KD9">
<frame key="frameInset" minY="92" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="V5t-oJ-KD9" id="Coo-th-ywF">
<frame key="frameInset" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XIE-DF-pSO">
<frame key="frameInset" minX="15" minY="12" width="31.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="vyz-CH-eMb">
<frame key="frameInset" minX="298.5" minY="12" width="41.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="iNr-Oe-muq" kind="show" identifier="EditPerson" id="czF-1h-sYn"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="cyv-nk-Plb" id="uBb-Bn-Lhg"/>
<outlet property="delegate" destination="cyv-nk-Plb" id="nLb-Ak-ZXS"/>
</connections>
</tableView>
<toolbarItems/>
<navigationItem key="navigationItem" title="Detail" id="mOI-FS-AaM"/>
<navigationItem key="navigationItem" title="Hall Of Fame" id="YLU-iz-PGw"/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="detailDescriptionLabel" destination="0XM-y9-sOw" id="deQ-Na-JPF"/>
<segue destination="ein-Sr-i8w" kind="presentation" identifier="NewPerson" id="zii-bJ-cOA"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FJe-Yq-33r" sceneMemberID="firstResponder"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="PrM-ex-2C8" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="709" y="129"/>
<point key="canvasLocation" x="630" y="640"/>
</scene>
<!--Person Edition View Controller-->
<scene sceneID="hZT-8U-F5G">
<scene sceneID="Juk-Ad-tZ2">
<objects>
<tableViewController id="yMU-Wr-YuI" customClass="PersonEditionViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="W7Z-fg-c9y">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<tableViewController id="iNr-Oe-muq" customClass="PersonEditionViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="vlV-lc-eQA">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<sections>
<tableViewSection id="jAm-13-xC3">
<tableViewSection id="Nzq-eO-jT3">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="M9a-av-50p">
<rect key="frame" x="0.0" y="99" width="600" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="2gb-gB-918">
<rect key="frame" x="0.0" y="64" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="M9a-av-50p" id="z18-Cs-DYr">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2gb-gB-918" id="iyM-TJ-JB4">
<frame key="frameInset" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="BDD-vR-uvL">
<rect key="frame" x="106" y="11" width="479" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no"/>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Name" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="m5m-Zs-j0z">
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
<connections>
<outlet property="delegate" destination="yMU-Wr-YuI" id="kl9-oG-bcm"/>
<outlet property="delegate" destination="iNr-Oe-muq" id="K2p-7d-teD"/>
</connections>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="First Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fUF-iv-npM">
<rect key="frame" x="15" y="11" width="83" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.1137254902" green="0.47843137250000001" blue="0.98039215690000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="BDD-vR-uvL" firstAttribute="centerY" secondItem="z18-Cs-DYr" secondAttribute="centerY" id="9Rw-U2-gEE"/>
<constraint firstAttribute="trailing" secondItem="BDD-vR-uvL" secondAttribute="trailing" constant="15" id="nQF-Sy-r5l"/>
<constraint firstItem="fUF-iv-npM" firstAttribute="centerY" secondItem="z18-Cs-DYr" secondAttribute="centerY" id="ofb-oL-lAk"/>
<constraint firstItem="BDD-vR-uvL" firstAttribute="leading" secondItem="fUF-iv-npM" secondAttribute="trailing" constant="8" symbolic="YES" id="pL4-Tm-5q7"/>
<constraint firstItem="fUF-iv-npM" firstAttribute="leading" secondItem="z18-Cs-DYr" secondAttribute="leading" constant="15" id="tBn-VL-Q7E"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="leading" secondItem="iyM-TJ-JB4" secondAttribute="leadingMargin" constant="10" id="9cK-nj-70V"/>
<constraint firstAttribute="trailingMargin" secondItem="m5m-Zs-j0z" secondAttribute="trailing" id="JsE-8v-XAS"/>
<constraint firstItem="m5m-Zs-j0z" firstAttribute="centerY" secondItem="iyM-TJ-JB4" secondAttribute="centerY" id="psG-tW-QrM"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="TEu-C2-7tX">
<rect key="frame" x="0.0" y="143" width="600" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="vp3-Ft-Gth">
<rect key="frame" x="0.0" y="108" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TEu-C2-7tX" id="awh-JA-Hz6">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vp3-Ft-Gth" id="ccO-0O-u72">
<frame key="frameInset" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="iqx-ux-kA0">
<rect key="frame" x="105" y="11" width="480" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no"/>
<connections>
<outlet property="delegate" destination="yMU-Wr-YuI" id="pIN-qZ-ntI"/>
</connections>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Score" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="rZ9-Fa-cyr">
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="done"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="Last Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7dD-VT-wdQ">
<rect key="frame" x="15" y="11" width="82" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.1137254902" green="0.47843137250000001" blue="0.98039215690000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="iqx-ux-kA0" secondAttribute="trailing" constant="15" id="UVH-DD-pHC"/>
<constraint firstItem="7dD-VT-wdQ" firstAttribute="centerY" secondItem="awh-JA-Hz6" secondAttribute="centerY" id="Vwn-I3-e7h"/>
<constraint firstItem="iqx-ux-kA0" firstAttribute="centerY" secondItem="awh-JA-Hz6" secondAttribute="centerY" id="VzL-HK-apN"/>
<constraint firstItem="iqx-ux-kA0" firstAttribute="leading" secondItem="7dD-VT-wdQ" secondAttribute="trailing" constant="8" symbolic="YES" id="fDY-Ju-iSw"/>
<constraint firstItem="7dD-VT-wdQ" firstAttribute="leading" secondItem="awh-JA-Hz6" secondAttribute="leading" constant="15" id="j64-an-fjP"/>
<constraint firstAttribute="trailingMargin" secondItem="rZ9-Fa-cyr" secondAttribute="trailing" id="Gso-FU-Ct1"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="centerY" secondItem="ccO-0O-u72" secondAttribute="centerY" id="UqA-ea-emb"/>
<constraint firstItem="rZ9-Fa-cyr" firstAttribute="leading" secondItem="ccO-0O-u72" secondAttribute="leadingMargin" constant="10" id="WrY-St-72v"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
@@ -133,129 +116,195 @@
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="yMU-Wr-YuI" id="fDY-MJ-pJo"/>
<outlet property="delegate" destination="yMU-Wr-YuI" id="Un1-A3-CJp"/>
<outlet property="dataSource" destination="iNr-Oe-muq" id="67O-XE-MeV"/>
<outlet property="delegate" destination="iNr-Oe-muq" id="vLD-QQ-zR2"/>
</connections>
</tableView>
<toolbarItems/>
<navigationItem key="navigationItem" id="Rwz-Rp-lmd">
<barButtonItem key="rightBarButtonItem" style="done" systemItem="done" id="NJu-k4-mIi">
<navigationItem key="navigationItem" id="U4g-xG-W8b">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="VIN-Hi-Twt">
<connections>
<segue destination="FMm-Lo-i3b" kind="unwind" identifier="commit" unwindAction="commitPersonEdition:" id="dkC-cp-6iC"/>
<segue destination="lTz-K0-aRY" kind="unwind" unwindAction="cancelPersonEdition:" id="fOs-ol-qJL"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="done" id="2um-u5-BhV">
<connections>
<segue destination="lTz-K0-aRY" kind="unwind" identifier="" unwindAction="commitPersonEdition:" id="Y1E-dI-wcl"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="firstNameTableViewCell" destination="M9a-av-50p" id="vXh-ik-bqv"/>
<outlet property="firstNameTextField" destination="BDD-vR-uvL" id="BYU-BL-kha"/>
<outlet property="lastNameTableViewCell" destination="TEu-C2-7tX" id="wDv-if-Gkl"/>
<outlet property="lastNameTextField" destination="iqx-ux-kA0" id="wOu-gU-WlV"/>
<outlet property="cancelBarButtonItem" destination="VIN-Hi-Twt" id="dET-mF-ZXe"/>
<outlet property="commitBarButtonItem" destination="2um-u5-BhV" id="Jym-us-zdP"/>
<outlet property="nameCell" destination="2gb-gB-918" id="ch2-MB-uRm"/>
<outlet property="nameTextField" destination="m5m-Zs-j0z" id="A6a-pw-q8s"/>
<outlet property="scoreCell" destination="vp3-Ft-Gth" id="b8A-42-8Dw"/>
<outlet property="scoreTextField" destination="rZ9-Fa-cyr" id="4kw-gV-uih"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="23u-wY-35e" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="FMm-Lo-i3b" userLabel="Exit" sceneMemberID="exit"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="fNC-Ls-uRw" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="lTz-K0-aRY" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="2301" y="-630"/>
<point key="canvasLocation" x="1450" y="1435"/>
</scene>
<!--GRDB Demo-->
<scene sceneID="XjB-aQ-v94">
<objects>
<tableViewController id="9kw-c5-KTk" customClass="DemoViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="f4Y-o2-7VW">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<sections>
<tableViewSection id="dCg-qU-h2X">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="clL-nG-zPX" style="IBUITableViewCellStyleDefault" id="kJB-sX-YAb">
<rect key="frame" x="0.0" y="64" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kJB-sX-YAb" id="f5l-ob-3DG">
<frame key="frameInset" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Simple TableView" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="clL-nG-zPX">
<frame key="frameInset" minX="15" width="325" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="cyv-nk-Plb" kind="show" id="Bgq-9t-jRc"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="I78-c5-0kp" style="IBUITableViewCellStyleDefault" id="q4C-mT-5mi">
<rect key="frame" x="0.0" y="108" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q4C-mT-5mi" id="2Cu-K1-hiz">
<frame key="frameInset" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="FetchedRecordsController" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="I78-c5-0kp">
<frame key="frameInset" minX="15" width="325" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="PJp-Eq-ZjA" kind="show" id="1fk-ZR-6XN"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="9kw-c5-KTk" id="IK7-Os-Odc"/>
<outlet property="delegate" destination="9kw-c5-KTk" id="U7E-yB-s8d"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="GRDB Demo" id="z0z-02-Ucy"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OhY-4B-BcJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-190" y="1435"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="GQC-vK-8JG">
<scene sceneID="2KX-IU-Z5Q">
<objects>
<navigationController id="IJV-AU-xKl" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="y7A-ea-ZFU">
<navigationController id="ein-Sr-i8w" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="zIT-dB-Mfo">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="yMU-Wr-YuI" kind="relationship" relationship="rootViewController" id="1PW-hN-E5f"/>
<segue destination="iNr-Oe-muq" kind="relationship" relationship="rootViewController" id="e5b-3U-9Vz"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4jR-xV-SBm" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="kNr-vk-I5l" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1481" y="-630"/>
</scene>
<!--Split View Controller-->
<scene sceneID="Nki-YV-4Qg">
<objects>
<splitViewController id="H1p-Uh-vWS" sceneMemberID="viewController">
<toolbarItems/>
<connections>
<segue destination="RMx-3f-FxP" kind="relationship" relationship="masterViewController" id="BlO-5A-QYV"/>
<segue destination="vC3-pB-5Vb" kind="relationship" relationship="detailViewController" id="Tll-UG-LXB"/>
</connections>
</splitViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cZU-Oi-B1e" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-856" y="-330"/>
</scene>
<!--Master-->
<scene sceneID="smW-Zh-WAh">
<objects>
<tableViewController title="Master" clearsSelectionOnViewWillAppear="NO" id="7bK-jq-Zjz" customClass="MasterViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="r7i-6Z-zg0">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" style="IBUITableViewCellStyleDefault" id="WCw-Qf-5nD">
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Arm-wq-HPj">
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showPerson" id="vhz-QC-pld"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="7bK-jq-Zjz" id="Gho-Na-rnu"/>
<outlet property="delegate" destination="7bK-jq-Zjz" id="RA6-mI-bju"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Master" id="Zdf-7t-Un8">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="q2y-Jp-QNL">
<connections>
<segue destination="IJV-AU-xKl" kind="popoverPresentation" identifier="editNewPerson" popoverAnchorBarButtonItem="q2y-Jp-QNL" id="KcV-Yc-DEu">
<popoverArrowDirection key="popoverArrowDirection" up="YES" down="YES" left="YES" right="YES"/>
</segue>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="709" y="-630"/>
<point key="canvasLocation" x="630" y="1435"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="r7l-gg-dq7">
<scene sceneID="N1X-4j-Re4">
<objects>
<navigationController id="vC3-pB-5Vb" sceneMemberID="viewController">
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="DjV-YW-jjY">
<navigationController id="UAh-8N-CM8" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="U7d-1C-GnL">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="JEX-9P-axG" kind="relationship" relationship="rootViewController" id="GKi-kA-LjT"/>
<segue destination="9kw-c5-KTk" kind="relationship" relationship="rootViewController" id="qDW-qI-Hyg"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SLD-UC-DBI" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="sVt-e9-ghQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-45" y="129"/>
<point key="canvasLocation" x="-1006" y="1435"/>
</scene>
<!--Hall Of Fame-->
<scene sceneID="9su-ms-vdJ">
<objects>
<tableViewController id="PJp-Eq-ZjA" customClass="PersonsViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="tX0-ON-WSI">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Person" textLabel="G8y-VE-YRu" detailTextLabel="NNc-J4-xiE" style="IBUITableViewCellStyleValue1" id="bFj-Hd-fwd">
<frame key="frameInset" minY="92" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bFj-Hd-fwd" id="kDf-TZ-xhb">
<frame key="frameInset" width="342" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="G8y-VE-YRu">
<frame key="frameInset" minX="15" minY="12" width="31.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NNc-J4-xiE">
<frame key="frameInset" minX="298.5" minY="12" width="41.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="iNr-Oe-muq" kind="show" identifier="EditPerson" id="Lgu-Yd-HSy"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="PJp-Eq-ZjA" id="MkQ-WQ-sTh"/>
<outlet property="delegate" destination="PJp-Eq-ZjA" id="quj-Sp-DuL"/>
</connections>
</tableView>
<toolbarItems>
<barButtonItem title="Item" id="hMF-Rv-dAe"/>
</toolbarItems>
<navigationItem key="navigationItem" title="Hall Of Fame" id="QIv-M6-kT1">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="2bK-Fl-55Q"/>
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<segue destination="ein-Sr-i8w" kind="presentation" identifier="NewPerson" id="7PC-xN-zD4"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="af5-Qo-AkD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="630" y="2254"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="vhz-QC-pld"/>
<segue reference="7PC-xN-zD4"/>
<segue reference="czF-1h-sYn"/>
</inferredMetricsTieBreakers>
</document>
+38 -42
View File
@@ -1,60 +1,56 @@
import GRDB
import UIKit
// The columns for the GRDB Query Interface
//
// See https://github.com/groue/GRDB.swift/#the-query-interface
struct Col {
static let id = SQLColumn("id")
static let firstName = SQLColumn("firstName")
static let lastName = SQLColumn("lastName")
}
// The shared database queue, stored in a global.
// It is initialized in setupDatabase()
// The shared database queue
var dbQueue: DatabaseQueue!
func setupDatabase() {
func setupDatabase(_ application: UIApplication) throws {
// Connect to the database
//
// See https://github.com/groue/GRDB.swift/#database-queues
// See https://github.com/groue/GRDB.swift/#database-connections
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
dbQueue = try! DatabaseQueue(path: databasePath)
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! as NSString
let databasePath = documentsPath.appendingPathComponent("db.sqlite")
dbQueue = try DatabaseQueue(path: databasePath)
// SQLite does not support Unicode: let's add a custom collation which will
// allow us to sort persons by name.
//
// See https://github.com/groue/GRDB.swift/#string-comparison
// Be a nice iOS citizen, and don't consume too much memory
// See https://github.com/groue/GRDB.swift/#memory-management
let collation = DatabaseCollation("localized_case_insensitive") { (lhs, rhs) in
return (lhs as NSString).localizedCaseInsensitiveCompare(rhs)
}
dbQueue.addCollation(collation)
dbQueue.setupMemoryManagement(in: application)
// Use DatabaseMigrator to setup the database
//
// See https://github.com/groue/GRDB.swift/#migrations
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in
try db.execute(
"CREATE TABLE persons (" +
"id INTEGER PRIMARY KEY, " +
"firstName TEXT COLLATE localized_case_insensitive, " +
"lastName TEXT COLLATE localized_case_insensitive" +
")")
// Create a table
// See https://github.com/groue/GRDB.swift#create-tables
try db.create(table: "persons") { t in
// An integer primary key auto-generates unique IDs
t.column("id", .integer).primaryKey()
// Sort person names in a localized case insensitive fashion by default
// See https://github.com/groue/GRDB.swift/#unicode
t.column("name", .text).notNull().collate(.localizedCaseInsensitiveCompare)
t.column("score", .integer).notNull()
}
// Populate the persons table with random data
for _ in 0..<8 {
try Person(name: Person.randomName(), score: Person.randomScore()).insert(db)
}
}
migrator.registerMigration("addPersons") { db in
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
try Person(firstName: "Cinderella").insert(db)
}
try! migrator.migrate(dbQueue)
}
// // Migrations for future application versions will be inserted here:
// migrator.registerMigration(...) { db in
// ...
// }
try migrator.migrate(dbQueue)
}
@@ -0,0 +1,10 @@
import UIKit
class DemoViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
navigationController?.isToolbarHidden = true
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Demo", style: .plain, target: nil, action: nil)
}
}
@@ -1,27 +0,0 @@
import UIKit
class DetailViewController: UIViewController {
@IBOutlet weak var detailDescriptionLabel: UILabel!
var person: Person! {
didSet {
self.configureView()
}
}
func configureView() {
guard isViewLoaded() else {
return
}
guard person != nil else {
return
}
detailDescriptionLabel.text = person.fullName
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
configureView()
}
}
Binary file not shown.
+2 -21
View File
@@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>GRDB Demo</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -16,8 +18,6 @@
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
@@ -30,28 +30,9 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarTintParameters</key>
<dict>
<key>UINavigationBar</key>
<dict>
<key>Style</key>
<string>UIBarStyleDefault</string>
<key>Translucent</key>
<false/>
</dict>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -1,96 +0,0 @@
import UIKit
class MasterViewController: UITableViewController {
var detailViewController: DetailViewController? = nil
var persons: [Person] = []
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftBarButtonItem = self.editButtonItem()
if let split = self.splitViewController {
let controllers = split.viewControllers
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
}
}
override func viewWillAppear(animated: Bool) {
// Reload persons, and the tableView
reloadPersons()
tableView.reloadData()
self.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed
super.viewWillAppear(animated)
}
func reloadPersons() {
persons = dbQueue.inDatabase { db in
Person.order(Col.firstName, Col.lastName).fetchAll(db)
}
}
// MARK: - Segues
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPerson" {
let detailViewController = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
detailViewController.person = persons[self.tableView.indexPathForSelectedRow!.row]
detailViewController.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
detailViewController.navigationItem.leftItemsSupplementBackButton = true
}
else if segue.identifier == "editNewPerson" {
let personEditionViewController = (segue.destinationViewController as! UINavigationController).topViewController as! PersonEditionViewController
personEditionViewController.person = Person()
}
}
// Unwind action: commit person edition
@IBAction func commitPersonEdition(segue: UIStoryboardSegue) {
let personEditionViewController = segue.sourceViewController as! PersonEditionViewController
let person = personEditionViewController.person
// Ignore person with no name
guard (person.firstName ?? "").characters.count > 0 || (person.lastName ?? "").characters.count > 0 else {
return
}
// Save person
try! dbQueue.inDatabase { db in
try person.save(db)
}
// Reload persons, and insert a cell.
reloadPersons()
let index = persons.indexOf { $0.id == person.id }!
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: index, inSection: 0)], withRowAnimation: .Automatic)
}
// MARK: - Table View
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return persons.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let person = persons[indexPath.row]
cell.textLabel!.text = person.fullName
return cell
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Delete the person
let person = persons[indexPath.row]
try! dbQueue.inTransaction { db in
try person.delete(db)
return .Commit
}
persons.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
}
+32 -25
View File
@@ -1,42 +1,49 @@
import GRDB
class Person : Record {
var id: Int64!
var firstName: String?
var lastName: String?
var fullName: String {
return [firstName, lastName].flatMap { $0 }.filter { !$0.isEmpty }.joinWithSeparator(" ")
}
class Person: Record {
var id: Int64?
var name: String
var score: Int
init(firstName: String? = nil, lastName: String? = nil) {
self.firstName = firstName
self.lastName = lastName
init(name: String, score: Int) {
self.name = name
self.score = score
super.init()
}
// MARK: Record overrides
// MARK: - Record
override class func databaseTableName() -> String {
override class var databaseTableName: String {
return "persons"
}
required init(_ row: Row) {
id = row.value(named: "id")
firstName = row.value(named: "firstName")
lastName = row.value(named: "lastName")
super.init(row)
required init(row: Row) {
id = row["id"]
name = row["name"]
score = row["score"]
super.init(row: row)
}
override var persistentDictionary: [String: DatabaseValueConvertible?] {
return [
"id": id,
"firstName": firstName,
"lastName": lastName]
override func encode(to container: inout PersistenceContainer) {
container["id"] = id
container["name"] = name
container["score"] = score
}
override func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
override func didInsert(with rowID: Int64, for column: String?) {
id = rowID
}
// MARK: Random
private static let names = ["Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David", "Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette", "Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl", "Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole", "Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul", "Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain", "Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann", "Zazie", "Zoé"]
class func randomName() -> String {
return names[Int(arc4random_uniform(UInt32(names.count)))]
}
class func randomScore() -> Int {
return 10 * Int(arc4random_uniform(101))
}
}
@@ -1,61 +1,104 @@
import UIKit
class PersonEditionViewController: UITableViewController, UITextFieldDelegate {
@IBOutlet weak var firstNameTableViewCell: UITableViewCell!
@IBOutlet weak var firstNameTextField: UITextField!
@IBOutlet weak var lastNameTableViewCell: UITableViewCell!
@IBOutlet weak var lastNameTextField: UITextField!
protocol PersonEditionViewControllerDelegate: class {
func personEditionControllerDidComplete(_ controller: PersonEditionViewController)
}
class PersonEditionViewController: UITableViewController {
weak var delegate: PersonEditionViewControllerDelegate?
var person: Person! { didSet { configureView() } }
var cancelButtonHidden: Bool = false { didSet { configureView() } }
var commitButtonHidden: Bool = false { didSet { configureView() } }
@IBOutlet fileprivate weak var cancelBarButtonItem: UIBarButtonItem!
@IBOutlet fileprivate weak var commitBarButtonItem: UIBarButtonItem!
@IBOutlet fileprivate weak var nameCell: UITableViewCell!
@IBOutlet fileprivate weak var nameTextField: UITextField!
@IBOutlet fileprivate weak var scoreCell: UITableViewCell!
@IBOutlet fileprivate weak var scoreTextField: UITextField!
// The edited person
var person: Person!
func applyChanges() {
if let name = nameTextField.text, !name.isEmpty {
person.name = name
}
person.score = scoreTextField.text.flatMap { Int($0) } ?? 0
}
override func viewDidLoad() {
super.viewDidLoad()
// Initializes textFields with the person's names
firstNameTextField.text = person.firstName
lastNameTextField.text = person.lastName
configureView()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
private func configureView() {
guard isViewLoaded else { return }
// Auto focus firstName
firstNameTextField.becomeFirstResponder()
nameTextField.text = person.name
if person.score == 0 && person.id == nil {
scoreTextField.text = ""
} else {
scoreTextField.text = "\(person.score)"
}
if cancelButtonHidden {
navigationItem.leftBarButtonItem = nil
} else {
navigationItem.leftBarButtonItem = cancelBarButtonItem
}
if cancelButtonHidden {
navigationItem.rightBarButtonItem = nil
} else {
navigationItem.rightBarButtonItem = commitBarButtonItem
}
}
}
// MARK: - Navigation
extension PersonEditionViewController {
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
// Force keyboard to dismiss early
view.endEditing(true)
return true
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Tapping a cell selects its text fields.
if indexPath == tableView.indexPathForCell(firstNameTableViewCell) {
firstNameTextField.becomeFirstResponder()
} else if indexPath == tableView.indexPathForCell(lastNameTableViewCell) {
lastNameTextField.becomeFirstResponder()
override func willMove(toParentViewController parent: UIViewController?) {
super.willMove(toParentViewController: parent)
if parent == nil {
// Self is popping from its navigation controller
delegate?.personEditionControllerDidComplete(self)
}
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Tapping Return key focuses next text field.
if textField == firstNameTextField {
lastNameTextField.becomeFirstResponder()
} else {
textField.resignFirstResponder()
}
// MARK: - Form
extension PersonEditionViewController: UITextFieldDelegate {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
nameTextField.becomeFirstResponder()
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
let cell = tableView.cellForRow(at: indexPath)
if cell === nameCell {
nameTextField.becomeFirstResponder()
} else if cell === scoreCell {
scoreTextField.becomeFirstResponder()
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == nameTextField {
scoreTextField.becomeFirstResponder()
}
return false
}
func textFieldDidEndEditing(textField: UITextField) {
// Update person when text field ends editing.
if textField == firstNameTextField {
person.firstName = textField.text
} else if textField == lastNameTextField {
person.lastName = textField.text
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// About to cancel or commit: end editing.
// This dismisses the keyboard early, and apply pending changes through
// textFieldDidEndEditing(_).
view.endEditing(true)
}
}
@@ -0,0 +1,234 @@
import UIKit
import GRDB
class PersonsViewController: UITableViewController {
var personsController: FetchedRecordsController<Person>!
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItems = [
UIBarButtonItem(barButtonSystemItem: .add, target: self, action: .addPerson),
editButtonItem
]
personsController = try! FetchedRecordsController(dbQueue, request: personsSortedByScore)
personsController.trackChanges(
willChange: { [unowned self] _ in
self.tableView.beginUpdates()
},
onChange: { [unowned self] (controller, record, change) in
switch change {
case .insertion(let indexPath):
self.tableView.insertRows(at: [indexPath], with: .fade)
case .deletion(let indexPath):
self.tableView.deleteRows(at: [indexPath], with: .fade)
case .update(let indexPath, _):
if let cell = self.tableView.cellForRow(at: indexPath) {
self.configure(cell, at: indexPath)
}
case .move(let indexPath, let newIndexPath, _):
// Actually move cells around for more demo effect :-)
let cell = self.tableView.cellForRow(at: indexPath)
self.tableView.moveRow(at: indexPath, to: newIndexPath)
if let cell = cell {
self.configure(cell, at: newIndexPath)
}
// A quieter animation:
// self.tableView.deleteRows(at: [indexPath], with: .fade)
// self.tableView.insertRows(at: [newIndexPath], with: .fade)
}
},
didChange: { [unowned self] _ in
self.tableView.endUpdates()
})
try! personsController.performFetch()
configureToolbar()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isToolbarHidden = false
}
}
// MARK: - Navigation
extension PersonsViewController : PersonEditionViewControllerDelegate {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EditPerson" {
let person = personsController.record(at: tableView.indexPathForSelectedRow!)
let controller = segue.destination as! PersonEditionViewController
controller.title = person.name
controller.person = person
controller.delegate = self // we will save person when back button is tapped
controller.cancelButtonHidden = true
controller.commitButtonHidden = true
}
else if segue.identifier == "NewPerson" {
setEditing(false, animated: true)
let navigationController = segue.destination as! UINavigationController
let controller = navigationController.viewControllers.first as! PersonEditionViewController
controller.title = "New Person"
controller.person = Person(name: "", score: 0)
}
}
@IBAction func addPerson(_ sender: AnyObject?) {
performSegue(withIdentifier: "NewPerson", sender: sender)
}
@IBAction func cancelPersonEdition(_ segue: UIStoryboardSegue) {
// Person creation: cancel button was tapped
}
@IBAction func commitPersonEdition(_ segue: UIStoryboardSegue) {
// Person creation: commit button was tapped
let controller = segue.source as! PersonEditionViewController
controller.applyChanges()
let person = controller.person!
if !person.name.isEmpty {
try! dbQueue.inDatabase { db in
try person.save(db)
}
}
}
func personEditionControllerDidComplete(_ controller: PersonEditionViewController) {
// Person edition: back button was tapped
controller.applyChanges()
let person = controller.person!
if !person.name.isEmpty {
try! dbQueue.inDatabase { db in
try person.save(db)
}
}
}
}
// MARK: - UITableViewDataSource
extension PersonsViewController {
func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
let person = personsController.record(at: indexPath)
cell.textLabel?.text = person.name
cell.detailTextLabel?.text = abs(person.score) > 1 ? "\(person.score) points" : "0 point"
}
override func numberOfSections(in tableView: UITableView) -> Int {
return personsController.sections.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return personsController.sections[section].numberOfRecords
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Person", for: indexPath)
configure(cell, at: indexPath)
return cell
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
// Delete the person
let person = personsController.record(at: indexPath)
try! dbQueue.inDatabase { db in
_ = try person.delete(db)
}
}
}
// MARK: - FetchedRecordsController Demo
extension PersonsViewController {
fileprivate func configureToolbar() {
toolbarItems = [
UIBarButtonItem(title: "Name ⬆︎", style: .plain, target: self, action: .sortByName),
UIBarButtonItem(title: "Score ⬇︎", style: .plain, target: self, action: .sortByScore),
UIBarButtonItem(title: "Randomize", style: .plain, target: self, action: .randomizeScores),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "💣", style: .plain, target: self, action: .stressTest)
]
}
@IBAction func sortByName() {
setEditing(false, animated: true)
try! personsController.setRequest(personsSortedByName)
}
@IBAction func sortByScore() {
setEditing(false, animated: true)
try! personsController.setRequest(personsSortedByScore)
}
@IBAction func randomizeScores() {
setEditing(false, animated: true)
try! dbQueue.inTransaction { db in
for person in try Person.fetchAll(db) {
person.score = Person.randomScore()
try person.update(db)
}
return .commit
}
}
@IBAction func stressTest() {
setEditing(false, animated: true)
for _ in 0..<50 {
DispatchQueue.global().async {
try! dbQueue.inTransaction { db in
if try Person.fetchCount(db) == 0 {
// Insert persons
for _ in 0..<8 {
try Person(name: Person.randomName(), score: Person.randomScore()).insert(db)
}
} else {
// Insert a person
if arc4random_uniform(2) == 0 {
let person = Person(name: Person.randomName(), score: Person.randomScore())
try person.insert(db)
}
// Delete a person
if arc4random_uniform(2) == 0 {
if let person = try Person.order(sql: "RANDOM()").fetchOne(db) {
try person.delete(db)
}
}
// Update some persons
for person in try Person.fetchAll(db) {
if arc4random_uniform(2) == 0 {
person.score = Person.randomScore()
try person.update(db)
}
}
}
return .commit
}
}
}
}
}
// https://medium.com/swift-programming/swift-selector-syntax-sugar-81c8a8b10df3
private extension Selector {
static let addPerson = #selector(PersonsViewController.addPerson(_:))
static let sortByName = #selector(PersonsViewController.sortByName)
static let sortByScore = #selector(PersonsViewController.sortByScore)
static let randomizeScores = #selector(PersonsViewController.randomizeScores)
static let stressTest = #selector(PersonsViewController.stressTest)
}
private let personsSortedByName = Person.order(Column("name"))
private let personsSortedByScore = Person.order(Column("score").desc, Column("name"))
@@ -0,0 +1,114 @@
import UIKit
import GRDB
class SimplePersonsViewController: UITableViewController {
var persons: [Person]!
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItems = [
UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(SimplePersonsViewController.addPerson(_:))),
editButtonItem
]
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadPersons()
tableView.reloadData()
}
private func loadPersons() {
persons = try! dbQueue.inDatabase { db in
try Person.order(Column("score").desc, Column("name")).fetchAll(db)
}
}
}
// MARK: - Navigation
extension SimplePersonsViewController : PersonEditionViewControllerDelegate {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EditPerson" {
let person = persons[tableView.indexPathForSelectedRow!.row]
let controller = segue.destination as! PersonEditionViewController
controller.title = person.name
controller.person = person
controller.delegate = self // we will save person when back button is tapped
controller.cancelButtonHidden = true
controller.commitButtonHidden = true
}
else if segue.identifier == "NewPerson" {
setEditing(false, animated: true)
let navigationController = segue.destination as! UINavigationController
let controller = navigationController.viewControllers.first as! PersonEditionViewController
controller.title = "New Person"
controller.person = Person(name: "", score: 0)
}
}
@IBAction func addPerson(_ sender: AnyObject?) {
performSegue(withIdentifier: "NewPerson", sender: sender)
}
@IBAction func cancelPersonEdition(_ segue: UIStoryboardSegue) {
// Person creation: cancel button was tapped
}
@IBAction func commitPersonEdition(_ segue: UIStoryboardSegue) {
// Person creation: commit button was tapped
let controller = segue.source as! PersonEditionViewController
controller.applyChanges()
let person = controller.person!
if !person.name.isEmpty {
try! dbQueue.inDatabase { db in
try person.save(db)
}
}
}
func personEditionControllerDidComplete(_ controller: PersonEditionViewController) {
// Person edition: back button was tapped
controller.applyChanges()
let person = controller.person!
if !person.name.isEmpty {
try! dbQueue.inDatabase { db in
try person.save(db)
}
}
}
}
// MARK: - UITableViewDataSource
extension SimplePersonsViewController {
func configure(_ cell: UITableViewCell, at indexPath: IndexPath) {
let person = persons[indexPath.row]
cell.textLabel?.text = person.name
cell.detailTextLabel?.text = abs(person.score) > 1 ? "\(person.score) points" : "0 point"
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return persons.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Person", for: indexPath)
configure(cell, at: indexPath)
return cell
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
// Delete the person
let person = persons[indexPath.row]
try! dbQueue.inDatabase { db in
_ = try person.delete(db)
}
persons.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
}
}
-35
View File
@@ -1,35 +0,0 @@
GRDBDemoiOS
===========
This application runs an universal (iPhone + iPad) application that displays an editable list of persons.
**To manually integrate GRDB as a Framework in your iOS application:**
1. Drag the [GRDB project](../../GRDB.xcodeproj) in your own project.
2. In the **Build Phase** tab of your target, add `GRDBiOS` in the **Target Dependencies** section.
3. In the **Embedded Binaries** section of the **General** tab of your target, add GRDB.xcodeproj/Products/GRDB.framework (iOS).
4. Run.
**To see usage of GRDB, check the following files:**
- [Database.swift](GRDBDemoiOS/Database.swift)
The setupDatabase() function sets up a global dbQueue that is accessible in the whole application. It is called by the [AppDelegate](GRDBDemoiOS/AppDelegate.swift) when application starts up.
It uses [migrations](https://github.com/groue/GRDB.swift#migrations) to initialize the database, and [custom string comparison](https://github.com/groue/GRDB.swift#string-comparison) in order to let the database perform the localized sorting of persons by name.
- [MasterViewController.swift](GRDBDemoiOS/MasterViewController.swift)
MasterViewController is responsible for displaying the list of persons in a table view, deleting persons, and present a person edition form.
- [Person.swift](GRDBDemoiOS/Person.swift)
Person is a simple [Record](https://github.com/groue/GRDB.swift#records) subclass.
- [DetailViewController.swift](GRDBDemoiOS/DetailViewController.swift) and [PersonEditionViewController.swift](GRDBDemoiOS/PersonEditionViewController.swift)
Those two view controllers display and edit a Person, in total isolation from the database.
@@ -1,578 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
560A37E01C91391800949E71 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B31C91391800949E71 /* Configuration.swift */; };
560A37E11C91391800949E71 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B41C91391800949E71 /* Database.swift */; };
560A37E21C91391800949E71 /* DatabaseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B51C91391800949E71 /* DatabaseError.swift */; };
560A37E31C91391800949E71 /* DatabasePool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B61C91391800949E71 /* DatabasePool.swift */; };
560A37E41C91391800949E71 /* DatabaseQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B71C91391800949E71 /* DatabaseQueue.swift */; };
560A37E51C91391800949E71 /* DatabaseSchemaCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B81C91391800949E71 /* DatabaseSchemaCache.swift */; };
560A37E61C91391800949E71 /* DatabaseValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37B91C91391800949E71 /* DatabaseValue.swift */; };
560A37E71C91391800949E71 /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37BA1C91391800949E71 /* DatabaseValueConvertible.swift */; };
560A37E81C91391800949E71 /* Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37BB1C91391800949E71 /* Row.swift */; };
560A37E91C91391800949E71 /* SerializedDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37BC1C91391800949E71 /* SerializedDatabase.swift */; };
560A37EA1C91391800949E71 /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37BD1C91391800949E71 /* Statement.swift */; };
560A37EB1C91391800949E71 /* StatementColumnConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37BE1C91391800949E71 /* StatementColumnConvertible.swift */; };
560A37EC1C91391800949E71 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C11C91391800949E71 /* CGFloat.swift */; };
560A37ED1C91391800949E71 /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C31C91391800949E71 /* DatabaseCoder.swift */; };
560A37EE1C91391800949E71 /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C41C91391800949E71 /* DatabaseDateComponents.swift */; };
560A37EF1C91391800949E71 /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C51C91391800949E71 /* DatabaseValue+Foundation.swift */; };
560A37F01C91391800949E71 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C61C91391800949E71 /* NSData.swift */; };
560A37F11C91391800949E71 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C71C91391800949E71 /* NSDate.swift */; };
560A37F21C91391800949E71 /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C81C91391800949E71 /* NSNull.swift */; };
560A37F31C91391800949E71 /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37C91C91391800949E71 /* NSNumber.swift */; };
560A37F41C91391800949E71 /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37CA1C91391800949E71 /* NSString.swift */; };
560A37F51C91391800949E71 /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37CB1C91391800949E71 /* NSURL.swift */; };
560A37F61C91391800949E71 /* Row+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37CC1C91391800949E71 /* Row+Foundation.swift */; };
560A37F71C91391800949E71 /* StatementArguments+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37CD1C91391800949E71 /* StatementArguments+Foundation.swift */; };
560A37F81C91391800949E71 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37CF1C91391800949E71 /* RawRepresentable.swift */; };
560A37F91C91391800949E71 /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D01C91391800949E71 /* StandardLibrary.swift */; };
560A37FA1C91391800949E71 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D11C91391800949E71 /* Utils.swift */; };
560A37FB1C91391800949E71 /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D31C91391800949E71 /* FetchRequest.swift */; };
560A37FC1C91391800949E71 /* SQLCollation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D41C91391800949E71 /* SQLCollation.swift */; };
560A37FD1C91391800949E71 /* SQLFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D51C91391800949E71 /* SQLFunction.swift */; };
560A37FE1C91391800949E71 /* SQLOperator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D61C91391800949E71 /* SQLOperator.swift */; };
560A37FF1C91391800949E71 /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D71C91391800949E71 /* SQLSelectQuery.swift */; };
560A38001C91391800949E71 /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37D91C91391800949E71 /* DatabaseMigrator.swift */; };
560A38011C91391800949E71 /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37DA1C91391800949E71 /* Migration.swift */; };
560A38021C91391800949E71 /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37DC1C91391800949E71 /* Persistable.swift */; };
560A38031C91391800949E71 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37DD1C91391800949E71 /* Record.swift */; };
560A38041C91391800949E71 /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37DE1C91391800949E71 /* RowConvertible.swift */; };
560A38051C91391800949E71 /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37DF1C91391800949E71 /* TableMapping.swift */; };
562FF9951BCE8FA400759400 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9941BCE8FA400759400 /* AppDelegate.swift */; };
562FF9971BCE8FA400759400 /* PersonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9961BCE8FA400759400 /* PersonsViewController.swift */; };
562FF99A1BCE8FA400759400 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 562FF9981BCE8FA400759400 /* Main.storyboard */; };
562FF99C1BCE8FA400759400 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 562FF99B1BCE8FA400759400 /* Assets.xcassets */; };
562FF99F1BCE8FA400759400 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 562FF99D1BCE8FA400759400 /* LaunchScreen.storyboard */; };
562FF9EC1BCE903D00759400 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 562FF9EB1BCE903D00759400 /* libsqlite3.tbd */; };
562FF9EF1BCE912C00759400 /* PersonEditionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9EE1BCE912C00759400 /* PersonEditionViewController.swift */; };
562FF9F21BCE914E00759400 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9F11BCE914E00759400 /* Person.swift */; };
566A20F31C58A4B300C5A218 /* AppDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F21C58A4B300C5A218 /* AppDatabase.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
560A37B31C91391800949E71 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
560A37B41C91391800949E71 /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
560A37B51C91391800949E71 /* DatabaseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseError.swift; sourceTree = "<group>"; };
560A37B61C91391800949E71 /* DatabasePool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePool.swift; sourceTree = "<group>"; };
560A37B71C91391800949E71 /* DatabaseQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueue.swift; sourceTree = "<group>"; };
560A37B81C91391800949E71 /* DatabaseSchemaCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseSchemaCache.swift; sourceTree = "<group>"; };
560A37B91C91391800949E71 /* DatabaseValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValue.swift; sourceTree = "<group>"; };
560A37BA1C91391800949E71 /* DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertible.swift; sourceTree = "<group>"; };
560A37BB1C91391800949E71 /* Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Row.swift; sourceTree = "<group>"; };
560A37BC1C91391800949E71 /* SerializedDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SerializedDatabase.swift; sourceTree = "<group>"; };
560A37BD1C91391800949E71 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = "<group>"; };
560A37BE1C91391800949E71 /* StatementColumnConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementColumnConvertible.swift; sourceTree = "<group>"; };
560A37C11C91391800949E71 /* CGFloat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloat.swift; sourceTree = "<group>"; };
560A37C31C91391800949E71 /* DatabaseCoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoder.swift; sourceTree = "<group>"; };
560A37C41C91391800949E71 /* DatabaseDateComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateComponents.swift; sourceTree = "<group>"; };
560A37C51C91391800949E71 /* DatabaseValue+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValue+Foundation.swift"; sourceTree = "<group>"; };
560A37C61C91391800949E71 /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = "<group>"; };
560A37C71C91391800949E71 /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = "<group>"; };
560A37C81C91391800949E71 /* NSNull.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNull.swift; sourceTree = "<group>"; };
560A37C91C91391800949E71 /* NSNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNumber.swift; sourceTree = "<group>"; };
560A37CA1C91391800949E71 /* NSString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSString.swift; sourceTree = "<group>"; };
560A37CB1C91391800949E71 /* NSURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURL.swift; sourceTree = "<group>"; };
560A37CC1C91391800949E71 /* Row+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+Foundation.swift"; sourceTree = "<group>"; };
560A37CD1C91391800949E71 /* StatementArguments+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatementArguments+Foundation.swift"; sourceTree = "<group>"; };
560A37CF1C91391800949E71 /* RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RawRepresentable.swift; sourceTree = "<group>"; };
560A37D01C91391800949E71 /* StandardLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibrary.swift; sourceTree = "<group>"; };
560A37D11C91391800949E71 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
560A37D31C91391800949E71 /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
560A37D41C91391800949E71 /* SQLCollation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollation.swift; sourceTree = "<group>"; };
560A37D51C91391800949E71 /* SQLFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLFunction.swift; sourceTree = "<group>"; };
560A37D61C91391800949E71 /* SQLOperator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLOperator.swift; sourceTree = "<group>"; };
560A37D71C91391800949E71 /* SQLSelectQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectQuery.swift; sourceTree = "<group>"; };
560A37D91C91391800949E71 /* DatabaseMigrator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseMigrator.swift; sourceTree = "<group>"; };
560A37DA1C91391800949E71 /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
560A37DC1C91391800949E71 /* Persistable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistable.swift; sourceTree = "<group>"; };
560A37DD1C91391800949E71 /* Record.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Record.swift; sourceTree = "<group>"; };
560A37DE1C91391800949E71 /* RowConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertible.swift; sourceTree = "<group>"; };
560A37DF1C91391800949E71 /* TableMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableMapping.swift; sourceTree = "<group>"; };
562FF9911BCE8FA400759400 /* GRDBDemoiOS7.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBDemoiOS7.app; sourceTree = BUILT_PRODUCTS_DIR; };
562FF9941BCE8FA400759400 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
562FF9961BCE8FA400759400 /* PersonsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonsViewController.swift; sourceTree = "<group>"; };
562FF9991BCE8FA400759400 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
562FF99B1BCE8FA400759400 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
562FF99E1BCE8FA400759400 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
562FF9A01BCE8FA400759400 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
562FF9EB1BCE903D00759400 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
562FF9EE1BCE912C00759400 /* PersonEditionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonEditionViewController.swift; sourceTree = "<group>"; };
562FF9F11BCE914E00759400 /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = "<group>"; };
562FF9F41BCE930C00759400 /* GRDBDemoiOS7-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GRDBDemoiOS7-Bridging-Header.h"; sourceTree = "<group>"; };
566A20F21C58A4B300C5A218 /* AppDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDatabase.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
562FF98E1BCE8FA400759400 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
562FF9EC1BCE903D00759400 /* libsqlite3.tbd in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
560A37B21C91391800949E71 /* Core */ = {
isa = PBXGroup;
children = (
560A37B31C91391800949E71 /* Configuration.swift */,
560A37B41C91391800949E71 /* Database.swift */,
560A37B51C91391800949E71 /* DatabaseError.swift */,
560A37B61C91391800949E71 /* DatabasePool.swift */,
560A37B71C91391800949E71 /* DatabaseQueue.swift */,
560A37B81C91391800949E71 /* DatabaseSchemaCache.swift */,
560A37B91C91391800949E71 /* DatabaseValue.swift */,
560A37BA1C91391800949E71 /* DatabaseValueConvertible.swift */,
560A37BB1C91391800949E71 /* Row.swift */,
560A37BC1C91391800949E71 /* SerializedDatabase.swift */,
560A37BD1C91391800949E71 /* Statement.swift */,
560A37BE1C91391800949E71 /* StatementColumnConvertible.swift */,
560A37BF1C91391800949E71 /* Support */,
560A37D11C91391800949E71 /* Utils.swift */,
);
path = Core;
sourceTree = "<group>";
};
560A37BF1C91391800949E71 /* Support */ = {
isa = PBXGroup;
children = (
560A37C01C91391800949E71 /* CoreGraphics */,
560A37C21C91391800949E71 /* Foundation */,
560A37CE1C91391800949E71 /* StandardLibrary */,
);
path = Support;
sourceTree = "<group>";
};
560A37C01C91391800949E71 /* CoreGraphics */ = {
isa = PBXGroup;
children = (
560A37C11C91391800949E71 /* CGFloat.swift */,
);
path = CoreGraphics;
sourceTree = "<group>";
};
560A37C21C91391800949E71 /* Foundation */ = {
isa = PBXGroup;
children = (
560A37C31C91391800949E71 /* DatabaseCoder.swift */,
560A37C41C91391800949E71 /* DatabaseDateComponents.swift */,
560A37C51C91391800949E71 /* DatabaseValue+Foundation.swift */,
560A37C61C91391800949E71 /* NSData.swift */,
560A37C71C91391800949E71 /* NSDate.swift */,
560A37C81C91391800949E71 /* NSNull.swift */,
560A37C91C91391800949E71 /* NSNumber.swift */,
560A37CA1C91391800949E71 /* NSString.swift */,
560A37CB1C91391800949E71 /* NSURL.swift */,
560A37CC1C91391800949E71 /* Row+Foundation.swift */,
560A37CD1C91391800949E71 /* StatementArguments+Foundation.swift */,
);
path = Foundation;
sourceTree = "<group>";
};
560A37CE1C91391800949E71 /* StandardLibrary */ = {
isa = PBXGroup;
children = (
560A37CF1C91391800949E71 /* RawRepresentable.swift */,
560A37D01C91391800949E71 /* StandardLibrary.swift */,
);
path = StandardLibrary;
sourceTree = "<group>";
};
560A37D21C91391800949E71 /* FetchRequest */ = {
isa = PBXGroup;
children = (
560A37D31C91391800949E71 /* FetchRequest.swift */,
560A37D41C91391800949E71 /* SQLCollation.swift */,
560A37D51C91391800949E71 /* SQLFunction.swift */,
560A37D61C91391800949E71 /* SQLOperator.swift */,
560A37D71C91391800949E71 /* SQLSelectQuery.swift */,
);
path = FetchRequest;
sourceTree = "<group>";
};
560A37D81C91391800949E71 /* Migrations */ = {
isa = PBXGroup;
children = (
560A37D91C91391800949E71 /* DatabaseMigrator.swift */,
560A37DA1C91391800949E71 /* Migration.swift */,
);
path = Migrations;
sourceTree = "<group>";
};
560A37DB1C91391800949E71 /* Record */ = {
isa = PBXGroup;
children = (
560A37DC1C91391800949E71 /* Persistable.swift */,
560A37DD1C91391800949E71 /* Record.swift */,
560A37DE1C91391800949E71 /* RowConvertible.swift */,
560A37DF1C91391800949E71 /* TableMapping.swift */,
);
path = Record;
sourceTree = "<group>";
};
562FF9881BCE8FA400759400 = {
isa = PBXGroup;
children = (
562FF9931BCE8FA400759400 /* GRDBDemoiOS7 */,
562FF9921BCE8FA400759400 /* Products */,
);
sourceTree = "<group>";
};
562FF9921BCE8FA400759400 /* Products */ = {
isa = PBXGroup;
children = (
562FF9911BCE8FA400759400 /* GRDBDemoiOS7.app */,
);
name = Products;
sourceTree = "<group>";
};
562FF9931BCE8FA400759400 /* GRDBDemoiOS7 */ = {
isa = PBXGroup;
children = (
562FF9941BCE8FA400759400 /* AppDelegate.swift */,
566A20F21C58A4B300C5A218 /* AppDatabase.swift */,
562FF9F01BCE913900759400 /* Controllers */,
562FF9F31BCE915B00759400 /* Models */,
562FF9A61BCE8FB000759400 /* Resources */,
562FF9ED1BCE904D00759400 /* Libraries */,
562FF9A71BCE8FB600759400 /* Supporting Files */,
);
path = GRDBDemoiOS7;
sourceTree = "<group>";
};
562FF9A61BCE8FB000759400 /* Resources */ = {
isa = PBXGroup;
children = (
562FF9981BCE8FA400759400 /* Main.storyboard */,
562FF99B1BCE8FA400759400 /* Assets.xcassets */,
562FF99D1BCE8FA400759400 /* LaunchScreen.storyboard */,
);
name = Resources;
sourceTree = "<group>";
};
562FF9A71BCE8FB600759400 /* Supporting Files */ = {
isa = PBXGroup;
children = (
562FF9A01BCE8FA400759400 /* Info.plist */,
562FF9F41BCE930C00759400 /* GRDBDemoiOS7-Bridging-Header.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
562FF9ED1BCE904D00759400 /* Libraries */ = {
isa = PBXGroup;
children = (
562FF9EB1BCE903D00759400 /* libsqlite3.tbd */,
566A20F41C58A54F00C5A218 /* GRDB */,
);
name = Libraries;
sourceTree = "<group>";
};
562FF9F01BCE913900759400 /* Controllers */ = {
isa = PBXGroup;
children = (
562FF9EE1BCE912C00759400 /* PersonEditionViewController.swift */,
562FF9961BCE8FA400759400 /* PersonsViewController.swift */,
);
name = Controllers;
sourceTree = "<group>";
};
562FF9F31BCE915B00759400 /* Models */ = {
isa = PBXGroup;
children = (
562FF9F11BCE914E00759400 /* Person.swift */,
);
name = Models;
sourceTree = "<group>";
};
566A20F41C58A54F00C5A218 /* GRDB */ = {
isa = PBXGroup;
children = (
560A37B21C91391800949E71 /* Core */,
560A37D21C91391800949E71 /* FetchRequest */,
560A37D81C91391800949E71 /* Migrations */,
560A37DB1C91391800949E71 /* Record */,
);
name = GRDB;
path = ../../../GRDB;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
562FF9901BCE8FA400759400 /* GRDBDemoiOS7 */ = {
isa = PBXNativeTarget;
buildConfigurationList = 562FF9A31BCE8FA400759400 /* Build configuration list for PBXNativeTarget "GRDBDemoiOS7" */;
buildPhases = (
562FF98D1BCE8FA400759400 /* Sources */,
562FF98E1BCE8FA400759400 /* Frameworks */,
562FF98F1BCE8FA400759400 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = GRDBDemoiOS7;
productName = GRDBDemoiOS7;
productReference = 562FF9911BCE8FA400759400 /* GRDBDemoiOS7.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
562FF9891BCE8FA400759400 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Gwendal Roué";
TargetAttributes = {
562FF9901BCE8FA400759400 = {
CreatedOnToolsVersion = 7.0;
};
};
};
buildConfigurationList = 562FF98C1BCE8FA400759400 /* Build configuration list for PBXProject "GRDBDemoiOS7" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 562FF9881BCE8FA400759400;
productRefGroup = 562FF9921BCE8FA400759400 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
562FF9901BCE8FA400759400 /* GRDBDemoiOS7 */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
562FF98F1BCE8FA400759400 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
562FF99F1BCE8FA400759400 /* LaunchScreen.storyboard in Resources */,
562FF99C1BCE8FA400759400 /* Assets.xcassets in Resources */,
562FF99A1BCE8FA400759400 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
562FF98D1BCE8FA400759400 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
560A37FB1C91391800949E71 /* FetchRequest.swift in Sources */,
560A37EC1C91391800949E71 /* CGFloat.swift in Sources */,
560A38011C91391800949E71 /* Migration.swift in Sources */,
560A37EB1C91391800949E71 /* StatementColumnConvertible.swift in Sources */,
560A37EF1C91391800949E71 /* DatabaseValue+Foundation.swift in Sources */,
560A37E01C91391800949E71 /* Configuration.swift in Sources */,
560A37E91C91391800949E71 /* SerializedDatabase.swift in Sources */,
562FF9EF1BCE912C00759400 /* PersonEditionViewController.swift in Sources */,
560A38051C91391800949E71 /* TableMapping.swift in Sources */,
560A37E71C91391800949E71 /* DatabaseValueConvertible.swift in Sources */,
560A37E31C91391800949E71 /* DatabasePool.swift in Sources */,
562FF9971BCE8FA400759400 /* PersonsViewController.swift in Sources */,
560A37E51C91391800949E71 /* DatabaseSchemaCache.swift in Sources */,
560A37E41C91391800949E71 /* DatabaseQueue.swift in Sources */,
560A37F11C91391800949E71 /* NSDate.swift in Sources */,
562FF9F21BCE914E00759400 /* Person.swift in Sources */,
560A37F01C91391800949E71 /* NSData.swift in Sources */,
562FF9951BCE8FA400759400 /* AppDelegate.swift in Sources */,
560A37FC1C91391800949E71 /* SQLCollation.swift in Sources */,
560A37F71C91391800949E71 /* StatementArguments+Foundation.swift in Sources */,
560A37EE1C91391800949E71 /* DatabaseDateComponents.swift in Sources */,
560A37ED1C91391800949E71 /* DatabaseCoder.swift in Sources */,
560A37E61C91391800949E71 /* DatabaseValue.swift in Sources */,
560A37F31C91391800949E71 /* NSNumber.swift in Sources */,
560A37FF1C91391800949E71 /* SQLSelectQuery.swift in Sources */,
560A37F41C91391800949E71 /* NSString.swift in Sources */,
560A37E21C91391800949E71 /* DatabaseError.swift in Sources */,
560A38041C91391800949E71 /* RowConvertible.swift in Sources */,
560A37F91C91391800949E71 /* StandardLibrary.swift in Sources */,
560A37FA1C91391800949E71 /* Utils.swift in Sources */,
560A37F61C91391800949E71 /* Row+Foundation.swift in Sources */,
560A37FD1C91391800949E71 /* SQLFunction.swift in Sources */,
560A37FE1C91391800949E71 /* SQLOperator.swift in Sources */,
560A37F21C91391800949E71 /* NSNull.swift in Sources */,
560A37E11C91391800949E71 /* Database.swift in Sources */,
560A37E81C91391800949E71 /* Row.swift in Sources */,
560A38021C91391800949E71 /* Persistable.swift in Sources */,
560A37F51C91391800949E71 /* NSURL.swift in Sources */,
560A37F81C91391800949E71 /* RawRepresentable.swift in Sources */,
560A38001C91391800949E71 /* DatabaseMigrator.swift in Sources */,
566A20F31C58A4B300C5A218 /* AppDatabase.swift in Sources */,
560A37EA1C91391800949E71 /* Statement.swift in Sources */,
560A38031C91391800949E71 /* Record.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
562FF9981BCE8FA400759400 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
562FF9991BCE8FA400759400 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
562FF99D1BCE8FA400759400 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
562FF99E1BCE8FA400759400 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
562FF9A11BCE8FA400759400 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
562FF9A21BCE8FA400759400 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
562FF9A41BCE8FA400759400 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = GRDBDemoiOS7/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS7;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "GRDBDemoiOS7/GRDBDemoiOS7-Bridging-Header.h";
};
name = Debug;
};
562FF9A51BCE8FA400759400 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = GRDBDemoiOS7/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoiOS7;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "GRDBDemoiOS7/GRDBDemoiOS7-Bridging-Header.h";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
562FF98C1BCE8FA400759400 /* Build configuration list for PBXProject "GRDBDemoiOS7" */ = {
isa = XCConfigurationList;
buildConfigurations = (
562FF9A11BCE8FA400759400 /* Debug */,
562FF9A21BCE8FA400759400 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
562FF9A31BCE8FA400759400 /* Build configuration list for PBXNativeTarget "GRDBDemoiOS7" */ = {
isa = XCConfigurationList;
buildConfigurations = (
562FF9A41BCE8FA400759400 /* Debug */,
562FF9A51BCE8FA400759400 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 562FF9891BCE8FA400759400 /* Project object */;
}
@@ -1,64 +0,0 @@
import Foundation
// The columns for the GRDB Query Interface
//
// See https://github.com/groue/GRDB.swift/#the-query-interface
struct Col {
static let id = SQLColumn("id")
static let firstName = SQLColumn("firstName")
static let lastName = SQLColumn("lastName")
}
// The shared database queue, stored in a global.
// It is initialized in setupDatabase()
var dbQueue: DatabaseQueue!
func setupDatabase() {
// Connect to the database
//
// See https://github.com/groue/GRDB.swift/#database-queues
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
dbQueue = try! DatabaseQueue(path: databasePath)
// SQLite does not support Unicode: let's add a custom collation which will
// allow us to sort persons by name.
//
// See https://github.com/groue/GRDB.swift/#string-comparison
let collation = DatabaseCollation("localized_case_insensitive") { (lhs, rhs) in
return (lhs as NSString).localizedCaseInsensitiveCompare(rhs)
}
dbQueue.inDatabase { db in
db.addCollation(collation)
}
// Use DatabaseMigrator to setup the database
//
// See https://github.com/groue/GRDB.swift/#migrations
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in
try db.execute(
"CREATE TABLE persons (" +
"id INTEGER PRIMARY KEY, " +
"firstName TEXT COLLATE localized_case_insensitive, " +
"lastName TEXT COLLATE localized_case_insensitive" +
")")
}
migrator.registerMigration("addPersons") { db in
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
try Person(firstName: "Cinderella").insert(db)
}
try! migrator.migrate(dbQueue)
}
@@ -1,13 +0,0 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
setupDatabase()
return true
}
}
@@ -1,190 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Xbj-yc-Aiu">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<scenes>
<!--Persons View Controller-->
<scene sceneID="1fE-hv-cjH">
<objects>
<tableViewController id="ynz-7l-fNg" customClass="PersonsViewController" customModule="GRDBDemoiOS7" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="wb6-9X-0tl">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="0eG-T5-kyh" style="IBUITableViewCellStyleDefault" id="eJm-gh-sbD">
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="eJm-gh-sbD" id="njP-8B-rhM">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="0eG-T5-kyh">
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="ynz-7l-fNg" id="5FA-Zc-cZO"/>
<outlet property="delegate" destination="ynz-7l-fNg" id="B8Y-qi-fJZ"/>
</connections>
</tableView>
<toolbarItems/>
<navigationItem key="navigationItem" id="gMJ-R9-ZaQ">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="XY0-Dc-M7c">
<connections>
<segue destination="oMH-Sb-bab" kind="presentation" identifier="editNewPerson" id="i19-Bf-uNJ"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="0kz-GI-OO0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1195" y="377"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="cvq-JR-nHN">
<objects>
<navigationController id="Xbj-yc-Aiu" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Hgn-6S-1iz">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="ynz-7l-fNg" kind="relationship" relationship="rootViewController" id="C4a-4A-4Md"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OyF-YK-p9J" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="375" y="377"/>
</scene>
<!--Person Edition View Controller-->
<scene sceneID="nA8-Ek-eRe">
<objects>
<tableViewController id="8yj-TG-7Iv" customClass="PersonEditionViewController" customModule="GRDBDemoiOS7" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="jhE-wh-IDm">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections>
<tableViewSection id="9vV-wM-aZ9">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="oKc-Vh-GAg">
<rect key="frame" x="0.0" y="99" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="oKc-Vh-GAg" id="EWB-Ks-FwX">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eF9-yN-ByV">
<rect key="frame" x="106" y="11" width="479" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no"/>
<connections>
<outlet property="delegate" destination="8yj-TG-7Iv" id="tG8-8g-5h8"/>
</connections>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="First Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xbk-eb-6vS">
<rect key="frame" x="15" y="11" width="83" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.1137254902" green="0.47843137250000001" blue="0.98039215690000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="eF9-yN-ByV" secondAttribute="trailing" constant="15" id="5YN-K6-y1e"/>
<constraint firstItem="xbk-eb-6vS" firstAttribute="leading" secondItem="EWB-Ks-FwX" secondAttribute="leading" constant="15" id="6ZF-52-FFn"/>
<constraint firstItem="xbk-eb-6vS" firstAttribute="centerY" secondItem="EWB-Ks-FwX" secondAttribute="centerY" id="9zo-vh-Z4q"/>
<constraint firstItem="eF9-yN-ByV" firstAttribute="leading" secondItem="xbk-eb-6vS" secondAttribute="trailing" constant="8" symbolic="YES" id="aKR-sh-Dh7"/>
<constraint firstItem="eF9-yN-ByV" firstAttribute="centerY" secondItem="EWB-Ks-FwX" secondAttribute="centerY" id="kqk-6N-RLq"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="jUE-io-HLU">
<rect key="frame" x="0.0" y="143" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jUE-io-HLU" id="utc-hw-ReT">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="D1U-mQ-lvp">
<rect key="frame" x="105" y="11" width="480" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no"/>
<connections>
<outlet property="delegate" destination="8yj-TG-7Iv" id="2pv-xY-VtW"/>
</connections>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="Last Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oYd-Lu-Kgd">
<rect key="frame" x="15" y="11" width="82" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.1137254902" green="0.47843137250000001" blue="0.98039215690000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="D1U-mQ-lvp" firstAttribute="leading" secondItem="oYd-Lu-Kgd" secondAttribute="trailing" constant="8" symbolic="YES" id="FHD-Pe-EkI"/>
<constraint firstItem="oYd-Lu-Kgd" firstAttribute="centerY" secondItem="utc-hw-ReT" secondAttribute="centerY" id="Kdt-DU-1us"/>
<constraint firstItem="D1U-mQ-lvp" firstAttribute="centerY" secondItem="utc-hw-ReT" secondAttribute="centerY" id="RVU-rE-8Aq"/>
<constraint firstItem="oYd-Lu-Kgd" firstAttribute="leading" secondItem="utc-hw-ReT" secondAttribute="leading" constant="15" id="Wlm-uX-s7l"/>
<constraint firstAttribute="trailing" secondItem="D1U-mQ-lvp" secondAttribute="trailing" constant="15" id="fs6-Mj-Cug"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="8yj-TG-7Iv" id="DrV-HH-zW8"/>
<outlet property="delegate" destination="8yj-TG-7Iv" id="5Ta-JL-Sse"/>
</connections>
</tableView>
<toolbarItems/>
<navigationItem key="navigationItem" id="0rI-r6-PKi">
<barButtonItem key="rightBarButtonItem" style="done" systemItem="done" id="jGa-U1-8mj">
<connections>
<segue destination="eQQ-Mr-J7f" kind="unwind" identifier="commit" unwindAction="commitPersonEdition:" id="LQt-5H-hX8"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="firstNameTableViewCell" destination="oKc-Vh-GAg" id="GgP-dg-jJI"/>
<outlet property="firstNameTextField" destination="eF9-yN-ByV" id="CwB-oL-I3U"/>
<outlet property="lastNameTableViewCell" destination="jUE-io-HLU" id="8SU-t1-EJR"/>
<outlet property="lastNameTextField" destination="D1U-mQ-lvp" id="4b9-am-ANQ"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="sm8-PY-oAW" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="eQQ-Mr-J7f" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="2843" y="377"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="n5c-pj-sKx">
<objects>
<navigationController id="oMH-Sb-bab" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="d5l-tl-lRt">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="8yj-TG-7Iv" kind="relationship" relationship="rootViewController" id="rAN-NO-1Mw"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="UxC-4D-edS" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2023" y="377"/>
</scene>
</scenes>
</document>
@@ -1,14 +0,0 @@
//
// GRDBDemoiOS7-Bridging-Header.h
// GRDBDemoiOS7
//
// Created by Gwendal Roué on 14/10/2015.
// Copyright © 2015 Gwendal Roué. All rights reserved.
//
#ifndef GRDBDemoiOS7_Bridging_Header_h
#define GRDBDemoiOS7_Bridging_Header_h
#import "sqlite3.h"
#endif /* GRDBDemoiOS7_Bridging_Header_h */
@@ -1,40 +0,0 @@
class Person : Record {
var id: Int64!
var firstName: String?
var lastName: String?
var fullName: String {
return [firstName, lastName].flatMap { $0 }.filter { !$0.isEmpty }.joinWithSeparator(" ")
}
init(firstName: String? = nil, lastName: String? = nil) {
self.firstName = firstName
self.lastName = lastName
super.init()
}
// MARK: - Record
override class func databaseTableName() -> String {
return "persons"
}
required init(_ row: Row) {
id = row.value(named: "id")
firstName = row.value(named: "firstName")
lastName = row.value(named: "lastName")
super.init(row)
}
override var persistentDictionary: [String: DatabaseValueConvertible?] {
return [
"id": id,
"firstName": firstName,
"lastName": lastName]
}
override func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
id = rowID
}
}
@@ -1,61 +0,0 @@
import UIKit
class PersonEditionViewController: UITableViewController, UITextFieldDelegate {
@IBOutlet weak var firstNameTableViewCell: UITableViewCell!
@IBOutlet weak var firstNameTextField: UITextField!
@IBOutlet weak var lastNameTableViewCell: UITableViewCell!
@IBOutlet weak var lastNameTextField: UITextField!
// The edited person
var person: Person!
override func viewDidLoad() {
super.viewDidLoad()
// Initializes textFields with the person's names
firstNameTextField.text = person.firstName
lastNameTextField.text = person.lastName
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Auto focus firstName
firstNameTextField.becomeFirstResponder()
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Tapping a cell selects its text fields.
if indexPath == tableView.indexPathForCell(firstNameTableViewCell) {
firstNameTextField.becomeFirstResponder()
} else if indexPath == tableView.indexPathForCell(lastNameTableViewCell) {
lastNameTextField.becomeFirstResponder()
}
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Tapping Return key focuses next text field.
if textField == firstNameTextField {
lastNameTextField.becomeFirstResponder()
} else {
textField.resignFirstResponder()
}
return false
}
func textFieldDidEndEditing(textField: UITextField) {
// Update person when text field ends editing.
if textField == firstNameTextField {
person.firstName = textField.text
} else if textField == lastNameTextField {
person.lastName = textField.text
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// About to cancel or commit: end editing.
// This dismisses the keyboard early, and apply pending changes through
// textFieldDidEndEditing(_).
view.endEditing(true)
}
}
@@ -1,85 +0,0 @@
import UIKit
class PersonsViewController: UITableViewController {
var persons: [Person] = []
override func viewWillAppear(animated: Bool) {
// Reload persons, and the tableView
reloadPersons()
tableView.reloadData()
self.navigationItem.leftBarButtonItem = self.editButtonItem()
super.viewWillAppear(animated)
}
func reloadPersons() {
persons = dbQueue.inDatabase { db in
Person.order(Col.firstName, Col.lastName).fetchAll(db)
}
}
// MARK: - Segues
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "editNewPerson" {
let personEditionViewController = (segue.destinationViewController as! UINavigationController).topViewController as! PersonEditionViewController
personEditionViewController.person = Person()
}
}
// Unwind action: commit person edition
@IBAction func commitPersonEdition(segue: UIStoryboardSegue) {
let personEditionViewController = segue.sourceViewController as! PersonEditionViewController
let person = personEditionViewController.person
// Ignore person with no name
guard (person.firstName ?? "").characters.count > 0 || (person.lastName ?? "").characters.count > 0 else {
return
}
// Save person
try! dbQueue.inDatabase { db in
try person.save(db)
}
// Reload persons, and insert a cell.
reloadPersons()
let index = persons.indexOf { $0.id == person.id }!
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: index, inSection: 0)], withRowAnimation: .Automatic)
}
// MARK: - Table View
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return persons.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let person = persons[indexPath.row]
cell.textLabel!.text = person.fullName
cell.selectionStyle = .None
return cell
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Delete the person
let person = persons[indexPath.row]
try! dbQueue.inTransaction { db in
try person.delete(db)
return .Commit
}
persons.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
}
-18
View File
@@ -1,18 +0,0 @@
GRDBDemoiOS7
============
This application runs an application that displays an editable list of persons and targets iOS7.
**To integrate GRDB in your iOS7 application:**
1. Drag all Swift files contained in the [GRDB folder](../../GRDB/) in your project.
2. In the **Build Phase** tab of your target, add `libsqlite3.tbd` in the **Link Binary With Libraries** section.
3. [Add a Bridging header to your project](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) in which you add:
```objc
#import "sqlite3.h"
```
4. Run
+132
View File
@@ -0,0 +1,132 @@
Custom SQLite Builds
====================
By default, GRDB uses the version of SQLite that ships with the target operating system.
**You can build GRDB with a custom build of [SQLite 3.20.0](https://www.sqlite.org/changes.html).**
A custom SQLite build can activate extra SQLite features, and extra GRDB features as well, such as support for the [FTS5 full-text search engine](../../../#full-text-search), and [SQLite Pre-Update Hooks](../../../#support-for-sqlite-pre-update-hooks).
GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfalling/SQLiteLib), which uses the same SQLite configuration as the one used by Apple in its operating systems, and lets you add extra compilation options that leverage the features you need.
**To install GRDB with a custom SQLite build:**
1. Clone the GRDB git repository, checkout the latest tagged version, and download SQLite sources:
```sh
cd [GRDB directory]
git checkout v2.0
git submodule update --init SQLiteCustom/src
````
2. Choose your [extra compilation options](https://www.sqlite.org/compile.html). For example, `SQLITE_ENABLE_FTS5` and `SQLITE_ENABLE_PREUPDATE_HOOK`.
3. Create a folder named `GRDBCustomSQLite` somewhere in your project directory.
4. Create four files in the `GRDBCustomSQLite` folder:
- `SQLiteLib-USER.xcconfig`: this file sets the extra SQLite compilation flags.
```xcconfig
// As many -D options as there are custom SQLite compilation options
// Note: there is no space between -D and the option name.
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_PREUPDATE_HOOK
```
- `GRDBCustomSQLite-USER.xcconfig`: this file lets GRDB know about extra compilation flags, and enables extra GRDB APIs.
```xcconfig
// As many -D options as there are custom SQLite compilation options
// Note: there is one space between -D and the option name.
CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_FTS5 -D SQLITE_ENABLE_PREUPDATE_HOOK
```
- `GRDBCustomSQLite-USER.h`: this file lets your application know about extra compilation flags.
```c
// As many #define as there are custom SQLite compilation options
#define SQLITE_ENABLE_FTS5
#define SQLITE_ENABLE_PREUPDATE_HOOK
```
- `GRDBCustomSQLite-INSTALL.sh`: this file installs the three other files.
```sh
# License: MIT License
# https://github.com/swiftlyfalling/SQLiteLib/blob/master/LICENSE
#
#######################################################
# PROJECT PATHS
# !! MODIFY THESE TO MATCH YOUR PROJECT HIERARCHY !!
#######################################################
# The path to the folder containing GRDB.xcodeproj:
GRDB_SOURCE_PATH="${PROJECT_DIR}/GRDB"
# The path to your custom "SQLiteLib-USER.xcconfig":
SQLITELIB_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/SQLiteLib-USER.xcconfig"
# The path to your custom "GRDBCustomSQLite-USER.xcconfig":
CUSTOMSQLITE_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.xcconfig"
# The path to your custom "GRDBCustomSQLite-USER.h":
CUSTOMSQLITE_H_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.h"
#######################################################
#
#######################################################
if [ ! -d "$GRDB_SOURCE_PATH" ];
then
echo "error: Path to GRDB source (GRDB_SOURCE_PATH) missing/incorrect: $GRDB_SOURCE_PATH"
exit 1
fi
SyncFileChanges () {
SOURCE=$1
DESTINATIONPATH=$2
DESTINATIONFILENAME=$3
DESTINATION="${DESTINATIONPATH}/${DESTINATIONFILENAME}"
if [ ! -f "$SOURCE" ];
then
echo "error: Source file missing: $SOURCE"
exit 1
fi
rsync -a "$SOURCE" "$DESTINATION"
}
SyncFileChanges $SQLITELIB_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom/src" "SQLiteLib-USER.xcconfig"
SyncFileChanges $CUSTOMSQLITE_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.xcconfig"
SyncFileChanges $CUSTOMSQLITE_H_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.h"
echo "Finished syncing"
```
Modify the top of `GRDBCustomSQLite-INSTALL.sh` file so that it contains correct paths.
5. Embed the `GRDB.xcodeproj` project in your own project.
6. Add the `GRDBCustomSQLiteOSX` or `GRDBCustomSQLiteiOS` target in the **Target Dependencies** section of the **Build Phases** tab of your **application target**.
7. Add the `GRDBCustomSQLite.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your **application target**.
8. Add a Run Script phase for your target in the **Pre-actions** section of the **Build** tab of your **application scheme**:
```sh
source "${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-INSTALL.sh"
```
The path should be the path to your `GRDBCustomSQLite-INSTALL.sh` file.
9. Check the "Shared" checkbox of your application scheme (this lets you commit the pre-action in your Version Control System).
Now you can use GRDB with your custom SQLite build:
```swift
import GRDBCustomSQLite
let dbQueue = try DatabaseQueue(...)
```
+591
View File
@@ -0,0 +1,591 @@
GRDB Extension Guide
====================
**Some parts of GRDB are extensible, so that you can make it better fit your needs.**
This guide is a step-by-step tour of GRDB extensibility, around a few topics:
- **[Add a value type](#add-a-value-type)**
You'll learn how to turn UIColor into a value type that you can store, fetch, and use in your records:
```swift
let rows = try Row.fetchCursor(db, "SELECT name, color FROM clothes")
while let row = try rows.next() {
let name: String = row["name"]
let color: UIColor = row["color"] // <-- New! UIColor as value
}
```
- **[Add an SQLite function or operator](#add-an-sqlite-function-or-operator)**
You'll learn how to add support for the [STRFTIME](https://www.sqlite.org/lang_datefunc.html) function, and the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator:
```swift
Books.select(strftime("%Y", Column("publishedDate"))) // <-- New! strftime function
Books.filter(Column("body").glob("*Moby-Dick*")) // <-- New! glob method
```
- **[Add a new kind of SQLite expression](#add-a-new-kind-of-sqlite-expression)**
You'll learn how to add support for [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr):
```swift
let jsonString = Column("jsonString")
let request = Books.select(cast(jsonString, as: .blob)) // <-- New! cast function
let rows = try Row.fetchCursor(db, request)
while let row = try rows.next() {
let data = row.dataNoCopy(atIndex: 0)
}
```
- **Extend the query interface requests**
You may need to extend the [query interface requests](../../../#requests) so that their SELECT queries could embed recursive clauses, table joins, etc.
Pull requests are welcome. Open issues if you have questions.
Meanwhile, you can build your own [custom requests](../../../#custom-requests).
- **[Add a custom FTS5 full-text tokenizer](FTS5Tokenizers.md)**
Custom tokenizers can leverage extra full-text features such as synonyms or stop words.
- **Support a new kind of SQL query**
For example, you may need to generate SQL triggers, or create specific kinds of virtual tables.
Pull requests are welcome. Open issues if you have questions.
## Add a Value Type
**All value types adopt the [DatabaseValueConvertible protocol](../../../#custom-value-types).**
```swift
protocol DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
var databaseValue: DatabaseValue { get }
/// Returns a value initialized from databaseValue, if possible.
static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self?
}
```
The `databaseValue` property returns [DatabaseValue](../../../#databasevalue), a type that wraps the five values supported by SQLite: NULL, Int64, Double, String and Data. Since DatabaseValue has no public initializer, use `DatabaseValue.null`, or another type that already adopts the protocol: `1.databaseValue`, `"foo".databaseValue`, etc. Conversion to DatabaseValue *must not* fail.
The `fromDatabaseValue()` factory method returns an instance of your custom type if the databaseValue contains a suitable value. If the databaseValue does not contain a suitable value, such as "foo" for Date, `fromDatabaseValue` *must* return nil (GRDB will interpret this nil result as a conversion error, and react accordingly).
**What does the DatabaseValueConvertible protocol bring to a type like UIColor?**
Well, you will be able to use UIColor like all other [value types](../../../#values) (Bool, Int, String, Date, Swift enums, etc.):
- Use UIColor as [statement arguments](../../../#executing-updates):
```swift
try db.execute(
"INSERT INTO clothes (name, color) VALUES (?, ?)",
arguments: ["Shirt", UIColor.red])
```
- UIColor can be [extracted from rows](../../../#column-values):
```swift
let rows = try Row.fetchCursor(db, "SELECT * FROM clothes")
while let row = try rows.next() {
let name: String = row["name"]
let color: UIColor = row["color"]
}
```
- UIColor can be [directly fetched](../../../#value-queries):
```swift
let colors = try UIColor.fetchAll(db, "SELECT DISTINCT color FROM clothes") // [UIColor]
```
- Use UIColor in [Records](../../../#records):
```swift
class ClothingItem : Record {
var name: String
var color: UIColor
required init(row: Row) {
name = row["name"]
color = row["color"]
super.init(row: row)
}
override func encode(to container: inout PersistenceContainer) {
container["name"] = name
container["color"] = color
}
}
```
- Use UIColor in the [query interface](../../../#the-query-interface):
```swift
let redClothes = try ClothingItem.filter(colorColumn == UIColor.red).fetchAll(db)
```
**Let's have UIColor adopt DatabaseValueConvertible**
In order to preserve as most information as possible, we'll archive UIColor as a data blob using the NSCoding protocol. But YMMV.
```swift
extension UIColor : DatabaseValueConvertible {
/// Encode UIColor as a data blob
var databaseValue: DatabaseValue {
// Use NSKeyedArchiver to build Data
let data = NSKeyedArchiver.archivedData(withRootObject: self)
// Data is already DatabaseValueConvertible
return data.databaseValue
}
/// Returns a UIColor if databaseValue contains suitable data, and
/// nil otherwise.
static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
// Only Data blobs can contain a UIColor
guard let data = Data.fromDatabaseValue(databaseValue) else {
return nil
}
// We're looking for an archived object
guard let color = NSKeyedUnarchiver.unarchiveObject(with: data) else {
return nil
}
// The cast function will return nil if the unarchived object doesn't
// have the correct type
return cast(color) // Converts Any to Self?
}
}
```
Use the `cast` utility function when you want *non-final classes* to implement DatabaseValueConvertible. It avoids compiler errors that are not easy to deal with. Note that final classes and value types won't need it.
```swift
// Workaround Swift inconvenience around factories methods of non-final classes
func cast<T, U>(_ value: T) -> U? {
return value as? U
}
```
## Add an SQLite Function or Operator
**When an SQLite [function](https://www.sqlite.org/lang_corefunc.html) or [operator](https://www.sqlite.org/lang_expr.html) is missing from GRDB**, this usually means that there hasn't been a [feature request](http://github.com/groue/GRDB.swift/issues) yet.
But you don't have to wait: you can extend GRDB and the query interface to add support for the missing syntax element (and eventually submit a pull request later).
Let's remind our goal: we'll add the [STRFTIME](https://www.sqlite.org/lang_datefunc.html) function, and the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator.
Their SQL usage is the following:
```sql
-- Publication years of books
SELECT STRFTIME('%Y', publishedOn) FROM books;
-- Books that talk about Moby Dick
SELECT * FROM books WHERE body GLOB '*Moby-Dick*';
```
Translated in the query interface, this gives:
```swift
Books.select(strftime("%Y", Column("publishedDate")))
Books.filter(Column("body").glob("*Moby-Dick*"))
```
`strftime` is a top-level Swift function because this is how GRDB usually imports SQLite functions which do not have matching standard Swift counterpart, like AVG, LEGNTH, SUM. It helps the Swift code looking like SQL when it is relevant.
In the same fashion, we expose the GLOB SQL operator as the `glob` Swift method, just because `value.glob(pattern)` reads like `value GLOB pattern`.
Whenever you import a SQL feature to Swift, you'll have to decide: should you preserve the SQL look and feel, or adopt a well-established swiftism? It's really up to you.
### STRFTIME
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
The [STRFTIME](https://www.sqlite.org/lang_datefunc.html) SQL function accepts many arguments. We'll simplify it to `strftime(format, date)`, so that we can write:
```sql
// Publication years of books
// SELECT STRFTIME('%Y', publishedOn) FROM books
Books.select(strftime("%Y", Column("publishedDate")))
```
The signature of the Swift `strftime` function is:
```swift
func strftime(_ format: String, _ date: SQLSpecificExpressible) -> SQLExpression
```
SQLSpecificExpressible and SQLExpression are types of the [query interface](../../../#the-query-interface) that you do not usually see. We have moved down one floor, closer to the SQL guts of GRDB. We'll see more new types and protocols below.
The return value is SQLExpression. All GRDB functions and operators that build [query interface expressions](../../../#expressions) return values of this type. It represents actual [SQLite expressions](https://www.sqlite.org/lang_expr.html).
SQLExpression is a protocol, so that you can build your own [custom expressions](#add-a-new-kind-of-sqlite-expression). But GRDB ships with a variety of [built-in expressions](#built-in-expressions) that are ready-made, and here we'll use SQLExpressionFunction that is dedicated to function calls:
```swift
struct SQLExpressionFunction : SQLExpression {
/// Creates an SQL function call
///
/// // ABS(-1)
/// SQLExpressionFunction(.abs, arguments: -1)
init(_ functionName: SQLFunctionName, arguments: SQLExpressible...)
}
```
So here is the code that defines our `strftime` function:
```swift
// Add a SQLFunctionName just like we add NSNotification.Name since
// the release of Swift 3.
extension SQLFunctionName {
/// The `STRFTIME` SQL function
static let strftime = SQLFunctionName("STRFTIME")
}
/// Returns an expression that evaluates the `STRFTIME` SQL function.
///
/// // STRFTIME('%Y', date)
/// strftime("%Y", Column("date"))
func strftime(_ format: String, _ date: SQLSpecificExpressible) -> SQLExpression {
return SQLExpressionFunction(.strftime, arguments: format, date)
}
```
The `strftime` function is now complete, ready to be used. We haven't yet described the SQLSpecificExpressible type of the `date` argument:
SQLSpecificExpressible is the protocol for all types that can be turned into a SQL expression, but types like Int, Date, or UIColor that exist outside of GRDB and the query interface. Having `strftime` accept a SQLSpecificExpressible date prevents it from polluting the global space. It is *specific* to GRDB:
```swift
strftime("%Y", Date()) // Compiler error
strftime("%Y", Column("date")) // SQLExpression: STRFTIME('%Y', date)
```
You may want to compare it to another protocol, SQLExpressible, which will be described [below](#add-a-new-kind-of-sqlite-expression), when we add support for CAST SQL expressions.
> :point_up: **Note**: whenever you extend GRDB with a Swift function, method, or operator, you should generally make sure that its signature contains at least one GRDB-specific type. In the `strftime` function, it is the SQLSpecificExpressible protocol.
### GLOB
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
For the [GLOB](https://www.sqlite.org/lang_expr.html#like) operator, we want to define the glob Swift method:
```swift
// Books that talk about Moby Dick
// SELECT * FROM books WHERE body GLOB '*Moby-Dick*'
Books.filter(Column("body").glob("*Moby-Dick*"))
```
This time we can't use the SQLExpressionFunction type, because it can't generate the SQL for a binary operator. Instead, we'll use another [built-in expression](#built-in-expressions), SQLExpressionBinary:
```swift
struct SQLExpressionBinary : SQLExpression {
/// Creates an expression made of two expressions joined with a binary operator.
///
/// // length * width
/// SQLExpressionBinary(.multiply, Column("length"), Column("width"))
init(_ op: SQLBinaryOperator, _ lhs: SQLExpressible, _ rhs: SQLExpressible)
}
```
Now we have to find the signature of our Swift method. The GLOB operator accepts any value on both sides. However, what kind of Swift code should we accept?
```swift
// 1) body GLOB '*Moby-Dick*' -- Yes, of course
Column("body").glob("*Moby-Dick*")
// 2) body GLOB pattern -- Sure, why not?
Column("body").glob(Column("pattern"))
// 3) 'Some Swift String' GLOB pattern - Not sure, but OK
"Some Swift String".glob(Column("pattern"))
// 4) 'Some Swift String' GLOB 'Another Swift String' -- NO
"Some Swift String".glob("Another Swift String")
```
We don't want the form 4, because this is an unacceptable pollution of the Swift global namespace. A good GRDB extension limits its scope to database-related code.
We thus have two overloaded definitions of the `glob` method:
```swift
extension SQLSpecificExpressible {
func glob(_ pattern: SQLExpressible) -> SQLExpression
}
extension SQLExpressible {
func glob(_ pattern: SQLSpecificExpressible) -> SQLExpression
}
```
SQLExpressible is the protocol for all types that can be turned into a SQL expression. This includes all expressions, and all [value types](../../../#values) (including String).
SQLSpecificExpressible is a sub protocol of SQLExpressible protocol, restricted to all types that can be turned into a SQL expression, but types like Int, Date, or String that exist outside of GRDB and the query interface.
By extending both, we can define the GLOB operators for any pair that contains at least one type that is specific to GRDB - and leave the global Swift space clean.
The final implementation follows:
```swift
// Add a SQLBinaryOperator just like we add NSNotification.Name since
// the release of Swift 3.
extension SQLBinaryOperator {
/// The `GLOB` binary operator
static let glob = SQLBinaryOperator("GLOB")
}
extension SQLSpecificExpressible {
/// Returns an SQL `GLOB` expression.
///
/// // body GLOB '*Moby-Dick*'
/// Column("body").glob("*Moby-Dick*")
func glob(_ pattern: SQLExpressible) -> SQLExpression {
return SQLExpressionBinary(.glob, self, pattern)
}
}
extension SQLExpressible {
/// Returns an SQL `GLOB` expression.
///
/// // 'Some Swift String' GLOB pattern
/// "Some Swift String".glob(Column("pattern"))
func glob(_ pattern: SQLSpecificExpressible) -> SQLExpression {
return SQLExpressionBinary(.glob, self, pattern)
}
}
```
### Built-in Expressions
When you extend GRDB with a new function, method, or operator that generates an [SQL expression](https://www.sqlite.org/lang_expr.html), you have to return a value the adopts the SQLExpression protocol.
We have already seen in our [previous](#strftime) [examples](#glob) two concrete types that generate SQL function calls and binary operators: SQLExpressionFunction and SQLExpressionBinary.
This section of the documentation lists all built-in expressions. Adding a custom SQLExpression type will be documented [below](#add-a-new-kind-of-sqlite-expression).
#### Column and DatabaseValue
The [Column](../../../#the-query-interface) type from the query interface, and [DatabaseValue](../../../#databasevalue), the type that wraps the five values supported by SQLite (NULL, Int64, Double, String and Data) are expressions. They are rather trivial, and it is unlikely that you use them in your GRDB extensions.
#### SQLExpressionLiteral
Use SQLExpressionLiteral when you need to go fast:
```swift
struct SQLExpressionLiteral : SQLExpression {
/// Creates an SQL literal expression.
///
/// SQLExpressionLiteral("1 + 2")
/// SQLExpressionLiteral("? + ?", arguments: [1, 2])
init(_ sql: String, arguments: StatementArguments? = nil)
}
```
For an example of use, see the [Add a new kind of SQLite expression](#add-a-new-kind-of-sqlite-expression) chapter.
#### SQLExpressionUnary
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
SQLExpressionUnary builds an expression by prefixing another expression with an unary operator:
```swift
struct SQLExpressionUnary : SQLExpression {
/// Creates an expression made of an unary operator and
/// an operand expression.
///
/// // NOT favorite
/// SQLExpressionUnary(.not, Column("favorite"))
init(_ op: SQLUnaryOperator, _ value: SQLExpressible)
}
```
You add missing SQLite unary operators by extending SQLUnaryOperator:
```swift
extension SQLUnaryOperator {
/// The `+` unary operator
static let plus = SQLUnaryOperator("+", needsRightSpace: false)
}
```
#### SQLExpressionBinary
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
SQLExpressionBinary builds an expression by joining two expressions with a binary operator:
```swift
struct SQLExpressionBinary : SQLExpression {
/// Creates an expression made of two expressions joined with a binary operator.
///
/// // length * width
/// SQLExpressionBinary(.multiply, Column("length"), Column("width"))
init(_ op: SQLBinaryOperator, _ lhs: SQLExpressible, _ rhs: SQLExpressible)
}
```
You add missing SQLite binary operators by extending SQLBinaryOperator:
```swift
extension SQLBinaryOperator {
/// The `GLOB` binary operator
static let glob = SQLBinaryOperator("GLOB")
}
```
#### SQLExpressionFunction
[**:fire: EXPERIMENTAL**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
SQLExpressionFunction builds an SQL function call:
```swift
struct SQLExpressionFunction : SQLExpression {
/// Creates an SQL function call
///
/// // ABS(-1)
/// SQLExpressionFunction(.abs, arguments: -1)
init(_ functionName: SQLFunctionName, arguments: SQLExpressible...)
}
```
You add missing SQLite function names by extending SQLFunctionName:
```swift
extension SQLFunctionName {
/// The `STRFTIME` SQL function
static let strftime = SQLFunctionName("STRFTIME")
}
```
#### The IN Operator
Build a `value IN (...)` expression from any sequence of [values](../../../#values):
```swift
// SQLExpression: id IN (1, 2, 3)
[1,2,3].contains(Column("id"))
// SQLExpression: id NOT IN (1, 2, 3)
![1,2,3].contains(Column("id"))
```
#### The BETWEEN Operator
Build a `value BETWEEN min AND max` expression from Swift ranges:
```swift
// SQLExpression: id BETWEEN 1 AND 10
1...10.contains(Column("id")
```
#### The COUNT Function
Build a `COUNT(...)` expression from the [count](http://groue.github.io/GRDB.swift/docs/2.0/Functions.html) and [count(distinct:)](http://groue.github.io/GRDB.swift/docs/2.0/Functions.html) functions:
```swift
// SQLExpression: COUNT(email)
count(Column("email"))
// SQLExpression: COUNT(DISTINCT email)
count(distinct: Column("email"))
```
#### The COLLATE Operator
Build a `expression COLLATE collation` expression with the `collating` method:
```swift
// SQLExpression: name = 'Arthur' COLLATE NOCASE
Column("name").collating(.nocase) == "Arthur"
```
## Add a New Kind of SQLite Expression
GRDB does not have built-in support for the full range of the SQLite [expression grammar](https://www.sqlite.org/lang_expr.html).
For example, [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr) are not ready-made. They can be useful, though: a CAST expression can efficiently convert json strings to UTF-8 data blobs for you:
```sql
SELECT CAST(jsonString AS BLOB) FROM books
```
We'll add below a Swift `cast` function:
```swift
let request = Books.select(cast(Column("jsonString"), as: .blob))
let jsonDatas = try Data.fetchAll(db, request) // [Data]
```
`cast` is a top-level Swift function because this is how GRDB usually imports SQLite features which do not have matching standard Swift counterpart. It helps the Swift code looking like SQL when it is relevant. But YMMV.
The signature of the `cast` function is:
```swift
func cast(_ value: SQLExpressible, as type: Database.ColumnType) -> SQLExpression
```
Database.ColumnType is a String-based enumeration of all database column types (.integer, .text, .blob, etc.) You have already used if you have [created tables](../../../#create-tables) using the query interface.
The return type SQLExpression is the type returned by all GRDB functions and operators that build [query interface expressions](../../../#expressions).
SQLExpression is a protocol. But GRDB ships with a variety of [built-in expressions](#built-in-expressions) that are ready-made, so that you generally don't have to write your custom expression type. Here we need something new. So we'll use the most versatile of all, SQLExpressionLiteral:
```swift
struct SQLExpressionLiteral : SQLExpression {
/// Creates an SQL literal expression.
///
/// SQLExpressionLiteral("1 + 2")
/// SQLExpressionLiteral("? + ?", arguments: [1, 2])
init(_ sql: String, arguments: StatementArguments? = nil)
}
```
Here is the code that defines our `cast` function:
```swift
func cast(_ value: SQLExpressible, as type: Database.ColumnType) -> SQLExpression {
// Turn the value into a literal expression
let literal: SQLExpressionLiteral = value.sqlExpression.literal
// Build our "CAST(value AS type)" sql snippet
let sql = "CAST(\(literal.sql) AS \(type.rawValue))"
// And return a new literal expression, preserving input arguments
return SQLExpressionLiteral(sql, arguments: literal.arguments)
}
```
We haven't yet described the SQLExpressible type of the `value` argument:
SQLExpressible is the protocol for all types that can be turned into a SQL expression. This includes all [value types](../../../#values) (Bool, Int, String, Date, Swift enums, etc.):
```swift
cast("foo", as: .blob) // SQLExpression: CAST('foo' AS BLOB)
cast(Column("name"), as: .blob) // SQLExpression: CAST(name AS BLOB)
```
You may want to compare it to another protocol, SQLSpecificExpressible, which has been described [above](#strftime), when we were adding support for the STRFTIME SQL function.
> :point_up: **Note**: whenever you extend GRDB with a Swift function, method, or operator, you should generally make sure that its signature contains at least one GRDB-specific type. In the `cast` function, it is Database.ColumnType.
**If SQLExpressionLiteral reveals too limited for your purpose**, you may have to implement a new type that adopts the [SQLExpression](http://groue.github.io/GRDB.swift/docs/2.0/Protocols/SQLExpression.html) protocol.
+389
View File
@@ -0,0 +1,389 @@
FTS5 Tokenizers
===============
**[FTS5](https://www.sqlite.org/fts5.html) is an extensible full-text search engine.**
GRDB lets you define your own custom FST5 tokenizers, and extend SQLite built-in tokenizers. Possible use cases are:
- Have "fi" match the ligature "&#xfb01;" (U+FB01)
- Have "first" match "1st"
- Have "Encyclopaedia" match "Encyclopædia"
- Have "Mueller" match "Müller", and "Grossmann" match "Großmann"
- Have "romaji" match "ローマ字", and "pinyin" match "拼音"
- Prevent "the" and other stop words from matching any document
**Table of Contents**
- [Tokenizers and Full-Text Search](#tokenizers-and-full-text-search)
- [The Tokenizer Protocols](#the-tokenizer-protocols)
- [Using a Custom Tokenizer](#using-a-custom-tokenizer)
- [FTS5Tokenizer](#fts5tokenizer)
- [FTS5CustomTokenizer](#fts5customtokenizer)
- [FTS5WrapperTokenizer](#fts5wrappertokenizer)
- [Choosing the Wrapped Tokenizer](#choosing-the-wrapped-tokenizer)
- [Example: Synonyms](#example-synonyms)
- [Example: Latin Script](#example-latin-script)
## Tokenizers and Full-Text Search
**A Tokenizer splits text into tokens**. For example, a tokenizer can split "SQLite is a database engine" into the five tokens "SQLite", "is", "a", "database", and "engine".
FTS5 use tokenizers to tokenize both indexed documents and search patterns. **A match between a document and a search pattern happens when both produce *identical* tokens.**
All SQLite [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers) tokenize both "SQLite" and "sqlite" into the common lowercase token "sqlite". This is why they are case-insensitive. Generally speaking, different tokenizers achieve different matching by applying different transformations to the input text.
- The [ascii](https://www.sqlite.org/fts5.html#ascii_tokenizer) tokenizer turns all ASCII characters to lowercase. "SQLite is a database engine" gives "sqlite", "is", "a", "database", and "engine". The query "SQLITE DATABASE" will match, because its tokens "sqlite" and "database" are found in the document.
- The [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer) tokenizer remove diacritics from latin characters. Unlike the ascii tokenizer, it will match "Jérôme" with "Jerome", as both produce the same "jerome" token.
- The [porter](https://www.sqlite.org/fts5.html#porter_tokenizer) tokenizer turns English words into their root: "database engine" gives the "databas" and "engin" tokens. The query "database engines" will match, because it produces the same tokens.
However, built-in tokenizers don't match "first" with "1st", because they produce the different "first" and "1st" tokens.
Nor do they match "Grossmann" with "Großmann", because they produce the different "grossmann" and "großmann" tokens.
Custom tokenizers help dealing with these situations. We'll see how to match "Grossmann" and "Großmann" by tokenizing them into "grossmann" (see [latin script](#example-latin-script)). We'll also see how to have "first" and "1st" emit *synonym tokens*, so that they can match too (see [synonyms](#example-synonyms)).
## The Tokenizer Protocols
GRDB lets you use and define FTS5 tokenizers through three protocols:
- [FTS5Tokenizer](#fts5tokenizer): the protocol for all FTS5 tokenizers, including the [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers) ascii, unicode61, and porter.
- [FTS5CustomTokenizer](#fts5customtokenizer): the low-level protocol that lets custom tokenizers use the raw [FTS5 C API](https://www.sqlite.org/fts5.html#custom_tokenizers).
- [FTS5WrapperTokenizer](#fts5wrappertokenizer): the high-level protocol for custom tokenizers that post-processes the tokens produced by another FTS5Tokenizer.
## Using a Custom Tokenizer
Once you have a custom tokenizer type that adopts [FTS5CustomTokenizer](#fts5customtokenizer) or [FTS5WrapperTokenizer](#fts5wrappertokenizer), it can fuel the FTS5 engine.
**Register the custom tokenizer into the database:**
```swift
class MyTokenizer : FTS5CustomTokenizer { ... }
dbQueue.add(tokenizer: MyTokenizer.self) // or dbPool.add
```
**Create [full-text tables](../../../#create-fts5-virtual-tables) that use the custom tokenizer:**
```swift
try db.create(virtualTable: "documents", using: FTS5()) { t in
t.tokenizer = MyTokenizer.tokenizerDescriptor()
t.column("content")
}
```
The full-text table can be fed and queried in [a regular way](../../../#full-text-search):
```swift
try db.execute("INSERT INTO documents VALUES (?)", arguments: ["..."])
try Document(content: "...").insert(db)
let pattern = FTS5Pattern(matchingAnyTokenIn:"...")
let documents = try Document.matching(pattern).fetchAll(db)
```
## FTS5Tokenizer
**FST5Tokenizer** is the protocol for all FTS5 tokenizers.
It only requires a tokenization method that matches the low-level `xTokenize` C function documented at https://www.sqlite.org/fts5.html#custom_tokenizers. We'll discuss it more when describing custom tokenizers.
```swift
typealias FTS5TokenCallback = @convention(c) (
_ context: UnsafeMutableRawPointer?,
_ flags: Int32,
_ pToken: UnsafePointer<Int8>?,
_ nToken: Int32,
_ iStart: Int32,
_ iEnd: Int32) -> Int32
protocol FTS5Tokenizer : class {
func tokenize(
context: UnsafeMutableRawPointer?,
tokenization: FTS5Tokenization,
pText: UnsafePointer<Int8>?,
nText: Int32,
tokenCallback: FTS5TokenCallback?) -> Int32
}
```
You can instantiate tokenizers, including [built-in tokenizers](https://www.sqlite.org/fts5.html#tokenizers), with the `Database.makeTokenizer()` method:
```swift
let unicode61 = try db.makeTokenizer(.unicode61()) // FTS5Tokenizer
```
## FTS5CustomTokenizer
**FTS5CustomTokenizer** is the low-level protocol for your custom tokenizers.
```swift
protocol FTS5CustomTokenizer : FTS5Tokenizer {
static var name: String { get }
init(db: Database, arguments: [String]) throws
}
```
Custom tokenizers have a name, like built-in tokenizers have a name. Don't use "ascii", "porter", or "unicode61" since they are already taken!
```swift
final class MyTokenizer : FTS5CustomTokenizer {
static let name = "custom"
}
```
SQLite instantiates tokenizers when it needs tokens. The arguments parameter of the `init(db:arguments:)` initializer is an array of strings, which your custom tokenizer can use for its own purposes. In the example below, the arguments will be `["arg1", "arg2"]`.
```swift
// CREATE VIRTUAL TABLE documents USING fts5(
// tokenize='custom arg1 arg2',
// authors, title, body
// )
try db.create(virtualTable: "documents", using: FTS5()) { t in
t.tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ["arg1", "arg2"])
t.column("authors")
t.column("title")
t.column("body")
}
```
FTS5CustomTokenizer inherits from [FTS5Tokenizer](#fts5tokenizer), and performs tokenization with its `tokenize(context:tokenization:pText:nText:tokenCallback:)` method. This low-level method matches the `xTokenize` C function documented at https://www.sqlite.org/fts5.html#custom_tokenizers.
This method arguments are:
- `context`: An opaque pointer that is the first argument to the `tokenCallback` function
- `tokenization`: The reason why FTS5 is requesting tokenization.
- `pText`: The tokenized text bytes. May or may not be nul-terminated.
- `nText`: The number of bytes in the tokenized text.
- `tokenCallback`: The function to call for each found token. It matches the `xToken` callback at https://www.sqlite.org/fts5.html#custom_tokenizers:
- `context`: An opaque pointer
- `flags`: Flags that tell FTS5 how to register the token
- `pToken`: The token bytes. May or may not be nul-terminated.
- `nToken`: The number of bytes in the token
- `iStart`: Byte offset of token within input text
- `iEnd`: Byte offset of end of token within input text
Since tokenization is hard, and pointers to byte buffers uneasy to deal with, you may enjoy the [FTS5WrapperTokenizer](#fts5wrappertokenizer) protocol.
## FTS5WrapperTokenizer
**FTS5WrapperTokenizer** is the high-level protocol for your custom tokenizers. It provides a default implementation for the low-level `tokenize(context:tokenization:pText:nText:tokenCallback:)` method, so that the adopting type does not have to deal with raw byte buffers of the raw [FTS5 C API](https://www.sqlite.org/fts5.html#custom_tokenizers).
A FTS5WrapperTokenizer lets the hard tokenization job to another tokenizer, the "wrapped tokenizer", and post-processes the tokens produced by this wrapped tokenizer.
```swift
protocol FTS5WrapperTokenizer : FTS5CustomTokenizer {
var wrappedTokenizer: FTS5Tokenizer { get }
func accept(
token: String,
flags: FTS5TokenFlags,
for tokenization: FTS5Tokenization,
tokenCallback: FTS5WrapperTokenCallback) throws
}
```
As all custom tokenizers, wrapper tokenizers must have a name:
```swift
final class MyTokenizer : FTS5WrapperTokenizer {
static let name = "custom"
}
```
The `wrappedTokenizer` property is the mandatory wrapped tokenizer. You instantiate it once, in the initializer:
```swift
final class MyTokenizer : FTS5WrapperTokenizer {
let wrappedTokenizer: FTS5Tokenizer
init(db: Database, arguments: [String]) throws {
// Wrap the unicode61 tokenizer
wrappedTokenizer = try db.makeTokenizer(.unicode61())
}
}
```
Wrapper tokenizers have to implement the `accept(token:flags:for:tokenCallback:)` method.
For example, a tokenizer that simply passes tokens through gives:
```swift
final class MyTokenizer : FTS5WrapperTokenizer {
func accept(
token: String,
flags: FTS5TokenFlags,
for tokenization: FTS5Tokenization,
tokenCallback: FTS5WrapperTokenCallback) throws
{
// pass through
try tokenCallback(token, flags)
}
}
```
The token argument is a token produced by the wrapped tokenizer, ready to be ignored, modified, or multiplied into several [synonyms](#example-synonyms).
The tokenization parameter tells the reason why tokens are produced, if FTS5 is tokenizing a document, or a search pattern. Some tokenizers may produce different tokens depending on this parameter.
Finally, the tokenCallback is a function you call to output a custom token.
There are a two rules to observe when implementing the accept method:
1. Errors thrown by the tokenCallback function must not be caught (they notify that FTS5 requires the tokenization process to stop immediately).
2. The flags parameter should be given unmodified to the tokenCallback function along with the custom token, unless you union it with the `.colocated` flag when the tokenizer produces [synonyms](#example-synonyms).
### Choosing the Wrapped Tokenizer
The wrapped tokenizer can be hard-coded, or chosen at runtime.
For example, your custom tokenizer can wrap [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer), unless arguments say otherwise (in a fashion similar to the [porter](https://www.sqlite.org/fts5.html#porter_tokenizer) tokenizer):
```swift
final class MyTokenizer : FTS5WrapperTokenizer {
static let name = "custom"
let wrappedTokenizer: FTS5Tokenizer
init(db: Database, arguments: [String]) throws {
if arguments.isEmpty {
wrappedTokenizer = try db.makeTokenizer(.unicode61())
} else {
let descriptor = FTS5TokenizerDescriptor(components: arguments)
wrappedTokenizer = try db.makeTokenizer(descriptor)
}
}
}
```
Arguments are provided when the virtual table is created:
```swift
// CREATE VIRTUAL TABLE documents USING fts5(
// tokenize='custom',
// content
// )
try db.create(virtualTable: "documents", using: FTS5()) { t in
// Wraps the default unicode61
t.tokenizer = MyTokenizer.tokenizerDescriptor()
t.column("content")
}
// CREATE VIRTUAL TABLE documents USING fts5(
// tokenize='custom ascii'
// content
// )
try db.create(virtualTable: "documents", using: FTS5()) { t in
// Wraps ascii
let ascii = FTS5TokenizerDescriptor.ascii()
t.tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ascii.components)
t.column("content")
}
```
## Example: Synonyms
**FTS5 lets tokenizers produce synonyms**, so that, for example, "first" can match "1st".
The topic of synonyms is documented at https://www.sqlite.org/fts5.html#synonym_support, which describes several methods. You should carefully read this documentation, and pick the method you prefer.
In the example below, we'll pick method (3), and implement a tokenizer that adds multiple synonyms for a single term to the FTS index. Using this method, when tokenizing document text, the tokenizer provides multiple synonyms for each token. So that when a document such as "I won first place" is tokenized, entries are added to the FTS index for "i", "won", "first", "1st" and "place".
We'll also take care of the SQLite advice:
> When using methods (2) or (3), it is important that the tokenizer only provide synonyms when tokenizing document text or query text, not both. Doing so will not cause any errors, but is inefficient.
```swift
final class SynonymsTokenizer : FTS5WrapperTokenizer {
static let name = "synonyms"
let wrappedTokenizer: FTS5Tokenizer
let synonyms: [Set<String>] = [["first", "1st"]]
init(db: Database, arguments: [String]) throws {
wrappedTokenizer = try db.makeTokenizer(.unicode61())
}
func synonyms(for token: String) -> Set<String>? {
return synonyms.first { $0.contains(token) }
}
func accept(token: String, flags: FTS5TokenFlags, for tokenization: FTS5Tokenization, tokenCallback: FTS5WrapperTokenCallback) throws {
if tokenization.contains(.query) {
// Don't look for synonyms when tokenizing queries
try tokenCallback(token, flags)
return
}
guard let synonyms = synonyms(for: token) else {
// Token has no synonym
try tokenCallback(token, flags)
return
}
for (index, synonym) in synonyms.enumerated() {
// Notify each synonym, and set the colocated flag for all but the first
let synonymFlags = (index == 0) ? flags : flags.union(.colocated)
try tokenCallback(synonym, synonymFlags)
}
}
}
```
## Example: Latin Script
Languages that use the [latin script](https://en.wikipedia.org/wiki/Latin_script) offer a rich set of typographical, historical, and local features such as diacritics, ligatures, and dotless I: Großmann, fidélité (with the ligature "fi" U+FB01), Diyarbakır.
Full-text search in such a corpus often needs input tolerance, so that "encyclopaedia" can match "Encyclopædia", "Grossmann", "Großmann", and "Jerome", "Jérôme".
German has something specific in that both "Mueller" and "Muller" should match "Müller", when "Bauer" should not match "Baur" (only "ü" accepts both "u" and "ue"). A pull request that adds a chapter about German will be welcome.
A custom FTS5 tokenizer lets you provide fuzzy latin matching: after "Grossmann", "Großmann", and "GROSSMANN" have all been turned into "grossmann", they will all match together.
We'll wrap the built-in [unicode61](https://www.sqlite.org/fts5.html#unicode61_tokenizer) tokenizer (the one that knows how to split text on spaces and punctuations), and transform its tokens into their bare lowercase ascii form.
The tokenizer wrapping is provided by the [FTS5WrapperTokenizer](#fts5wrappertokenizer) protocol. The string transformation is provided by the [String.applyingTransform](https://developer.apple.com/reference/swift/string/1643133-applyingtransform) method:
```swift
final class LatinAsciiTokenizer : FTS5WrapperTokenizer {
static let name = "latinascii"
let wrappedTokenizer: FTS5Tokenizer
init(db: Database, arguments: [String]) throws {
wrappedTokenizer = try db.makeTokenizer(.unicode61())
}
func accept(token: String, flags: FTS5TokenFlags, for tokenization: FTS5Tokenization, tokenCallback: FTS5WrapperTokenCallback) throws {
if let token = token.applyingTransform(StringTransform("Latin-ASCII; Lower"), reverse: false) {
try tokenCallback(token, flags)
}
}
}
```
> :point_up: **Note**: String.applyingTransform is not available before iOS 9.0 and macOS 10.11. Use the Core Foundation function [CFStringTransform](https://developer.apple.com/reference/corefoundation/1542411-cfstringtransform) instead.
Remember to register LatinAsciiTokenizer before using it:
```swift
dbQueue.add(tokenizer: LatinAsciiTokenizer.self) // or dbPool.add
dbQueue.inDatabase { db in
try db.create(virtualTable: "documents", using: FTS5()) { t in
t.tokenizer = LatinAsciiTokenizer.tokenizerDescriptor()
t.column("authors")
t.column("title")
t.column("body")
}
}
```
+1
View File
@@ -0,0 +1 @@
The main documentation is available in [README.md](../../../#documentation).
+32
View File
@@ -0,0 +1,32 @@
Release Process
===============
**This is internal documentation.**
To release a new GRDB version:
- Tests
- `make test`
- Build and run GRDBDemoiOS in Release configuration on a device
- Archive GRDBDemoiOS
- Check for performance regression with GRDBOSXPerformanceTests
- On https://github.com/groue/sqlcipher.git upgrade, update SQLCipher version in README.md
- On https://github.com/swiftlyfalling/SQLiteLib upgrade, update SQLite version in README.md and Documentation/CustomSQLiteBuilds.md
- Update GRDB version number and release date in:
- Makefile
- CHANGELOG.md
- Documentation/CustomSQLiteBuilds.md
- Documentation/ExtendingGRDB.md
- GRDB.swift.podspec
- GRDBCipher.podspec
- README.md
- 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 Swift3 branch
- `pod trunk push --allow-warnings GRDB.swift.podspec`
- `pod trunk push --allow-warnings GRDBCipher.podspec`
- `make doc`, and update index.html in the `gh-pages` branch
- Update http://github.com/groue/GRDBDemo
- Update http://github.com/groue/WWDCCompanion
+7 -4
View File
@@ -1,16 +1,19 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
s.version = '0.48.0'
s.version = '2.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A versatile SQLite toolkit for Swift, with WAL mode support.'
s.summary = 'A Swift application toolkit for SQLite databases.'
s.homepage = 'https://github.com/groue/GRDB.swift'
s.author = { 'Gwendal Roué' => 'gr@pierlis.com' }
s.source = { :git => 'https://github.com/groue/GRDB.swift.git', :tag => "v#{s.version}" }
s.source_files = 'GRDB/**/*.{h,m,swift}'
s.module_name = 'GRDB'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
s.requires_arc = true
s.watchos.deployment_target = '2.0'
s.source_files = 'GRDB/**/*.swift', 'Support/*.h'
s.module_map = 'Support/module.modulemap'
s.framework = 'Foundation'
s.library = 'sqlite3'
Regular → Executable
+5408 -579
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "560FC5191CB003810014AA8E"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipherOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "560FC55D1CB00B880014AA8E"
BuildableName = "GRDBCipherOSXTests.xctest"
BlueprintName = "GRDBCipherOSXTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "567156191CB16729007DC145"
BuildableName = "GRDBCipherOSXEncryptedTests.xctest"
BlueprintName = "GRDBCipherOSXEncryptedTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "560FC5191CB003810014AA8E"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipherOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "560FC5191CB003810014AA8E"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipherOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "560FC5191CB003810014AA8E"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipherOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipheriOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFCA2B1CB1AA9900F48B96"
BuildableName = "GRDBCipheriOSTests.xctest"
BlueprintName = "GRDBCipheriOSTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFCA841CB1ABC800F48B96"
BuildableName = "GRDBCipheriOSEncryptedTests.xctest"
BlueprintName = "GRDBCipheriOSEncryptedTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipheriOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipheriOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56AFC9EE1CB1A8BB00F48B96"
BuildableName = "GRDBCipher.framework"
BlueprintName = "GRDBCipheriOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA809A1CFB2F6F003DC1BA"
BuildableName = "GRDBCustomSQLiteOSXTests.xctest"
BlueprintName = "GRDBCustomSQLiteOSXTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA80591CFB2BB2003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteOSX"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteiOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA80401CFB2AD7003DC1BA"
BuildableName = "GRDBCustomSQLiteiOSTests.xctest"
BlueprintName = "GRDBCustomSQLiteiOSTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteiOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteiOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA7FFD1CFB25E4003DC1BA"
BuildableName = "GRDBCustomSQLite.framework"
BlueprintName = "GRDBCustomSQLiteiOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -29,7 +29,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
BuildableName = "GRDBTests.xctest"
BuildableName = "GRDBOSXTests.xctest"
BlueprintName = "GRDBOSXTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
@@ -48,19 +48,31 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
BuildableName = "GRDBTests.xctest"
BuildableName = "GRDBOSXTests.xctest"
BlueprintName = "GRDBOSXTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "FMDBPerformanceTests">
Identifier = "FetchedRecordsControllerTests/testEmptyFetchedRecordsAfterPerformFetch()">
</Test>
<Test
Identifier = "GRDBPerformanceTests">
Identifier = "FetchedRecordsControllerTests/testNoFetchedRecordsBeforeFetch()">
</Test>
<Test
Identifier = "StephenCelisSQLitePerformanceTests">
Identifier = "FetchedRecordsControllerTests/testNotEmptyFetchedRecordsAfterPerformFetch()">
</Test>
<Test
Identifier = "FetchedRecordsControllerTests/testNotificationsOnInsertion()">
</Test>
<Test
Identifier = "FetchedRecordsControllerTests/testRecordDeleted()">
</Test>
<Test
Identifier = "FetchedRecordsControllerTests/testRecordInserted()">
</Test>
<Test
Identifier = "FetchedRecordsControllerTests/testRecordUpdated()">
</Test>
</SkippedTests>
</TestableReference>
@@ -1,24 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56553BDA1C3E906C00522B5C"
BuildableName = "GRDBOSXCrashTests.xctest"
BlueprintName = "GRDBOSXCrashTests"
BlueprintIdentifier = "56439B2D1F4CA1DC0066043F"
BuildableName = "GRDBOSXPerformanceComparisonTests.xctest"
BlueprintName = "GRDBOSXPerformanceComparisonTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
@@ -30,6 +31,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -10,6 +10,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -30,6 +31,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5654909F1D5A4798005622CB"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBWatchOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5654909F1D5A4798005622CB"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBWatchOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5654909F1D5A4798005622CB"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBWatchOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,14 +26,15 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56E5D7D21B4D3FEE00430942"
BuildableName = "GRDBTests.xctest"
BuildableName = "GRDBiOSTests.xctest"
BlueprintName = "GRDBiOSTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
+5 -8
View File
@@ -4,6 +4,9 @@
<Group
location = "group:Playgrounds"
name = "Playgrounds">
<FileRef
location = "group:Tour.playground">
</FileRef>
<FileRef
location = "group:JSONSynchronization.playground">
</FileRef>
@@ -14,22 +17,16 @@
location = "group:TransactionObserver.playground">
</FileRef>
<FileRef
location = "group:DatabaseTimestamp.playground">
</FileRef>
<FileRef
location = "group:UserDefaults.playground">
location = "group:MyPlayground.playground">
</FileRef>
</Group>
<FileRef
location = "group:GRDB.xcodeproj">
</FileRef>
<FileRef
location = "group:Tests/GRDBProfiling/GRDBProfiling.xcodeproj">
location = "group:Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj">
</FileRef>
<FileRef
location = "group:DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj">
</FileRef>
<FileRef
location = "group:DemoApps/GRDBDemoiOS7/GRDBDemoiOS7.xcodeproj">
</FileRef>
</Workspace>
+47 -21
View File
@@ -1,54 +1,80 @@
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// Configure a DatabaseQueue
/// Configuration for a DatabaseQueue or DatabasePool.
public struct Configuration {
// MARK: - Misc options
/// If true, foreign key constraints are checked.
///
/// Default: true
public var foreignKeysEnabled: Bool = true
/// If true, database modifications are disallowed.
///
/// Default: false
public var readonly: Bool = false
/// A function that is called on every statement executed by the database.
///
/// Default: nil
public var trace: TraceFunction?
// MARK: - Encryption
#if SQLITE_HAS_CODEC
/// The passphrase for encrypted database.
///
/// Default: nil
public var passphrase: String?
#endif
// MARK: - Transactions
/// The default kind of transaction.
public var defaultTransactionKind: TransactionKind = .Immediate
///
/// Default: deferred
public var defaultTransactionKind: Database.TransactionKind = .deferred
// MARK: - Concurrency
public var busyMode: BusyMode = .ImmediateError
var threadingMode: ThreadingMode = .Default
/// The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy
///
/// Default: immediateError
public var busyMode: Database.BusyMode = .immediateError
/// The maximum number of concurrent readers (applies to database
/// pools only).
///
/// Default: 5
public var maximumReaderCount: Int = 5
// MARK: - Factory Configuration
/// Returns a factory configuration:
///
/// - foreignKeysEnabled: true
/// - readonly: false
/// - trace: nil
/// - defaultTransactionKind: .Immediate
/// - transactionObserver: nil
/// - busyMode: .ImmediateError
/// Creates a factory configuration
public init() { }
// MARK: - SQLite flags
// MARK: - Not Public
var sqliteOpenFlags: Int32 {
return threadingMode.sqliteOpenFlags | (readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE))
var threadingMode: Database.ThreadingMode = .`default`
var SQLiteConnectionDidOpen: (() -> ())?
var SQLiteConnectionWillClose: ((SQLiteConnection) -> ())?
var SQLiteConnectionDidClose: (() -> ())?
var SQLiteOpenFlags: Int32 {
let readWriteFlags = readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
return threadingMode.SQLiteOpenFlags | readWriteFlags
}
}
/// A tracing function that takes an SQL string.
public typealias TraceFunction = (String) -> Void
/// A tracing function that logs SQL statements with NSLog
public func LogSQL(sql: String) {
NSLog("SQLite: %@", sql)
}
+344
View File
@@ -0,0 +1,344 @@
extension Array {
/// Creates an array containing the elements of a cursor.
///
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
/// let strings = try Array(cursor) // ["foo", "bar"]
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
self.init()
while let element = try cursor.next() {
append(element)
}
}
}
extension Set {
/// Creates a set containing the elements of a cursor.
///
/// let cursor = try String.fetchCursor(db, "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)
}
}
}
/// A type that supplies the values of some external resource, one at a time.
///
/// ## Overview
///
/// The most common way to iterate over the elements of a cursor is to use a
/// `while` loop:
///
/// let cursor = ...
/// while let element = try cursor.next() {
/// ...
/// }
///
/// ## Relationship with standard Sequence and IteratorProtocol
///
/// Cursors share traits with lazy sequences and iterators from the Swift
/// standard library. Differences are:
///
/// - Cursor types are classes, and have a lifetime.
/// - Cursor iteration may throw errors.
/// - A cursor can not be repeated.
///
/// The protocol comes with default implementations for many operations similar
/// to those defined by Swift's LazySequenceProtocol:
///
/// - `func contains(Self.Element)`
/// - `func contains(where: (Self.Element) throws -> Bool)`
/// - `func enumerated()`
/// - `func filter((Self.Element) throws -> Bool)`
/// - `func first(where: (Self.Element) throws -> Bool)`
/// - `func flatMap<ElementOfResult>((Self.Element) throws -> ElementOfResult?)`
/// - `func flatMap<SegmentOfResult>((Self.Element) throws -> SegmentOfResult)`
/// - `func forEach((Self.Element) throws -> Void)`
/// - `func joined()`
/// - `func map<T>((Self.Element) throws -> T)`
/// - `func reduce<Result>(Result, (Result, Self.Element) throws -> Result)`
public protocol Cursor : class {
/// The type of element traversed by the cursor.
associatedtype Element
/// Advances to the next element and returns it, or nil if no next element
/// exists. Once nil has been returned, all subsequent calls return nil.
func next() throws -> Element?
}
/// A type-erased cursor of Element.
///
/// This cursor forwards its next() method to an arbitrary underlying cursor
/// having the same Element type, hiding the specifics of the underlying
/// cursor.
public class AnyCursor<Element> : Cursor {
/// Creates a cursor that wraps a base cursor but whose type depends only on
/// the base cursor’s element type
public init<C: Cursor>(_ base: C) where C.Element == Element {
element = base.next
}
/// Creates a cursor that wraps the given closure in its next() method
public init(_ body: @escaping () throws -> Element?) {
element = body
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() throws -> Element? {
return try element()
}
private let element: () throws -> Element?
}
extension Cursor {
/// Returns a Boolean value indicating whether the cursor contains an
/// element that satisfies the given predicate.
///
/// - parameter predicate: A closure that takes an element of the cursor as
/// its argument and returns a Boolean value that indicates whether the
/// passed element represents a match.
/// - returns: true if the cursor contains an element that satisfies
/// predicate; otherwise, false.
public func contains(where predicate: (Element) throws -> Bool) throws -> Bool {
while let element = try next() {
if try predicate(element) {
return true
}
}
return false
}
/// Returns a cursor of pairs (n, x), where n represents a consecutive
/// integer starting at zero, and x represents an element of the cursor.
///
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
/// let c = cursor.enumerated()
/// while let (n, x) = c.next() {
/// print("\(n): \(x)")
/// }
/// // Prints: "0: foo"
/// // Prints: "1: bar"
public func enumerated() -> EnumeratedCursor<Self> {
return EnumeratedCursor(self)
}
/// Returns the elements of the cursor that satisfy the given predicate.
public func filter(_ isIncluded: @escaping (Element) throws -> Bool) -> FilterCursor<Self> {
return FilterCursor(self, isIncluded)
}
/// Returns the first element of the cursor that satisfies the given
/// predicate or nil if no such element is found.
public func first(where predicate: (Element) throws -> Bool) throws -> Element? {
while let element = try next() {
if try predicate(element) {
return element
}
}
return nil
}
/// Returns a cursor over the concatenated non-nil results of mapping
/// transform over this cursor.
public func flatMap<ElementOfResult>(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor<FilterCursor<MapCursor<Self, ElementOfResult?>>, ElementOfResult> {
return map(transform).filter { $0 != nil }.map { $0! }
}
/// Returns a cursor over the concatenated results of mapping transform
/// over self.
public func flatMap<SegmentOfResult: Sequence>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, IteratorCursor<SegmentOfResult.Iterator>>> {
return flatMap { try IteratorCursor(transform($0)) }
}
/// Returns a cursor over the concatenated results of mapping transform
/// over self.
public func flatMap<SegmentOfResult: Cursor>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, SegmentOfResult>> {
return map(transform).joined()
}
/// Calls the given closure on each element in the cursor.
public func forEach(_ body: (Element) throws -> Void) throws {
while let element = try next() {
try body(element)
}
}
/// Returns a cursor over the results of the transform function applied to
/// this cursor's elements.
public func map<T>(_ transform: @escaping (Element) throws -> T) -> MapCursor<Self, T> {
return MapCursor(self, transform)
}
/// Returns the result of calling the given combining closure with each
/// element of this sequence and an accumulating value.
public func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) throws -> Result) throws -> Result {
var result = initialResult
while let element = try next() {
result = try nextPartialResult(result, element)
}
return result
}
}
extension Cursor where Element: Equatable {
/// Returns a Boolean value indicating whether the cursor contains the
/// given element.
public func contains(_ element: Element) throws -> Bool {
while let e = try next() {
if e == element {
return true
}
}
return false
}
}
extension Cursor where Element: Cursor {
/// Returns the elements of this cursor of cursors, concatenated.
public func joined() -> FlattenCursor<Self> {
return FlattenCursor(self)
}
}
extension Cursor where Element: Sequence {
/// Returns the elements of this cursor of sequences, concatenated.
public func joined() -> FlattenCursor<MapCursor<Self, IteratorCursor<Self.Element.Iterator>>> {
return flatMap { $0 }
}
}
/// An enumeration of the elements of a cursor.
///
/// To create an instance of `EnumeratedCursor`, call the `enumerated()` method
/// on a cursor:
///
/// let cursor = try String.fetchCursor(db, "SELECT 'foo' UNION ALL SELECT 'bar'")
/// let c = cursor.enumerated()
/// while let (n, x) = c.next() {
/// print("\(n): \(x)")
/// }
/// // Prints: "0: foo"
/// // Prints: "1: bar"
public final class EnumeratedCursor<Base: Cursor> : Cursor {
init(_ base: Base) {
self.index = 0
self.base = base
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() throws -> (Int, Base.Element)? {
guard let element = try base.next() else { return nil }
defer { index += 1 }
return (index, element)
}
private var index: Int
private var base: Base
}
/// A cursor whose elements consist of the elements of some base cursor that
/// also satisfy a given predicate.
public final class FilterCursor<Base: Cursor> : Cursor {
init(_ base: Base, _ isIncluded: @escaping (Base.Element) throws -> Bool) {
self.base = base
self.isIncluded = isIncluded
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() throws -> Base.Element? {
while let element = try base.next() {
if try isIncluded(element) {
return element
}
}
return nil
}
private let base: Base
private let isIncluded: (Base.Element) throws -> Bool
}
/// A cursor consisting of all the elements contained in each segment contained
/// in some Base cursor.
///
/// See Cursor.joined(), Cursor.flatMap(_:), Sequence.flatMap(_:)
public final class FlattenCursor<Base: Cursor> : Cursor where Base.Element: Cursor {
init(_ base: Base) {
self.base = base
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() throws -> Base.Element.Element? {
while true {
if let element = try inner?.next() {
return element
}
guard let inner = try base.next() else {
return nil
}
self.inner = inner
}
}
private var inner: Base.Element?
private let base: Base
}
/// A Cursor whose elements consist of those in a Base Cursor passed through a
/// transform function returning Element.
///
/// See Cursor.map(_:)
public final class MapCursor<Base: Cursor, Element> : Cursor {
init(_ base: Base, _ transform: @escaping (Base.Element) throws -> Element) {
self.base = base
self.transform = transform
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() throws -> Element? {
guard let element = try base.next() else { return nil }
return try transform(element)
}
private let base: Base
private let transform: (Base.Element) throws -> Element
}
/// A Cursor whose elements are those of a sequence iterator.
public final class IteratorCursor<Base: IteratorProtocol> : Cursor {
/// Creates a cursor from a sequence iterator.
public init(_ base: Base) {
self.base = base
}
/// Creates a cursor from a sequence.
public init<S: Sequence>(_ s: S) where S.Iterator == Base {
self.base = s.makeIterator()
}
/// Advances to the next element and returns it, or nil if no next
/// element exists.
public func next() -> Base.Element? {
return base.next()
}
private var base: Base
}
extension Sequence {
/// Returns a cursor over the concatenated results of mapping transform
/// over self.
public func flatMap<SegmentOfResult: Cursor>(_ transform: @escaping (Iterator.Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<IteratorCursor<Self.Iterator>, SegmentOfResult>> {
return IteratorCursor(self).flatMap(transform)
}
}
+2227 -621
View File
File diff suppressed because it is too large. Load diff
+221 -8
View File
@@ -1,8 +1,195 @@
/// DatabaseError wraps an SQLite error.
public struct DatabaseError : ErrorType {
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible {
public let rawValue: Int32
/// The SQLite error code (see https://www.sqlite.org/c3ref/c_abort.html).
public let code: Int32
public init(rawValue: Int32) {
self.rawValue = rawValue
}
/// A result code limited to the least significant 8 bits of the receiver.
/// See https://www.sqlite.org/rescode.html for more information.
///
/// let resultCode = .SQLITE_CONSTRAINT_FOREIGNKEY
/// resultCode.primaryResultCode == .SQLITE_CONSTRAINT // true
public var primaryResultCode: ResultCode {
return ResultCode(rawValue: rawValue & 0xFF)
}
var isPrimary: Bool {
return self == primaryResultCode
}
public var description: String {
// sqlite3_errstr was added in SQLite 3.7.15 http://www.sqlite.org/changes.html#version_3_7_15
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
#if GRDBCUSTOMSQLITE || GRDBCIPHER
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
#else
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, iOSApplicationExtension 8.2, *) {
return "\(rawValue) (\(String(cString: sqlite3_errstr(rawValue))))"
} else {
return "\(rawValue)"
}
#endif
}
public static func == (_ lhs: ResultCode, _ rhs: ResultCode) -> Bool {
return lhs.rawValue == rhs.rawValue
}
/// Returns true if the code on the left matches the code on the right.
///
/// Primary result codes match themselves and their extended result codes,
/// while extended result codes match only themselves:
///
/// switch error.extendedResultCode {
/// case .SQLITE_CONSTRAINT_FOREIGNKEY: // foreign key constraint error
/// case .SQLITE_CONSTRAINT: // any other constraint error
/// default: // any other database error
/// }
public static func ~= (pattern: ResultCode, code: ResultCode) -> Bool {
if pattern.isPrimary {
return pattern == code.primaryResultCode
} else {
return pattern == code
}
}
// Primary Result codes
// https://www.sqlite.org/rescode.html#primary_result_code_list
public static let SQLITE_OK = ResultCode(rawValue: 0) // Successful result
public static let SQLITE_ERROR = ResultCode(rawValue: 1) // SQL error or missing database
public static let SQLITE_INTERNAL = ResultCode(rawValue: 2) // Internal logic error in SQLite
public static let SQLITE_PERM = ResultCode(rawValue: 3) // Access permission denied
public static let SQLITE_ABORT = ResultCode(rawValue: 4) // Callback routine requested an abort
public static let SQLITE_BUSY = ResultCode(rawValue: 5) // The database file is locked
public static let SQLITE_LOCKED = ResultCode(rawValue: 6) // A table in the database is locked
public static let SQLITE_NOMEM = ResultCode(rawValue: 7) // A malloc() failed
public static let SQLITE_READONLY = ResultCode(rawValue: 8) // Attempt to write a readonly database
public static let SQLITE_INTERRUPT = ResultCode(rawValue: 9) // Operation terminated by sqlite3_interrupt()
public static let SQLITE_IOERR = ResultCode(rawValue: 10) // Some kind of disk I/O error occurred
public static let SQLITE_CORRUPT = ResultCode(rawValue: 11) // The database disk image is malformed
public static let SQLITE_NOTFOUND = ResultCode(rawValue: 12) // Unknown opcode in sqlite3_file_control()
public static let SQLITE_FULL = ResultCode(rawValue: 13) // Insertion failed because database is full
public static let SQLITE_CANTOPEN = ResultCode(rawValue: 14) // Unable to open the database file
public static let SQLITE_PROTOCOL = ResultCode(rawValue: 15) // Database lock protocol error
public static let SQLITE_EMPTY = ResultCode(rawValue: 16) // Database is empty
public static let SQLITE_SCHEMA = ResultCode(rawValue: 17) // The database schema changed
public static let SQLITE_TOOBIG = ResultCode(rawValue: 18) // String or BLOB exceeds size limit
public static let SQLITE_CONSTRAINT = ResultCode(rawValue: 19) // Abort due to constraint violation
public static let SQLITE_MISMATCH = ResultCode(rawValue: 20) // Data type mismatch
public static let SQLITE_MISUSE = ResultCode(rawValue: 21) // Library used incorrectly
public static let SQLITE_NOLFS = ResultCode(rawValue: 22) // Uses OS features not supported on host
public static let SQLITE_AUTH = ResultCode(rawValue: 23) // Authorization denied
public static let SQLITE_FORMAT = ResultCode(rawValue: 24) // Auxiliary database format error
public static let SQLITE_RANGE = ResultCode(rawValue: 25) // 2nd parameter to sqlite3_bind out of range
public static let SQLITE_NOTADB = ResultCode(rawValue: 26) // File opened that is not a database file
public static let SQLITE_NOTICE = ResultCode(rawValue: 27) // Notifications from sqlite3_log()
public static let SQLITE_WARNING = ResultCode(rawValue: 28) // Warnings from sqlite3_log()
public static let SQLITE_ROW = ResultCode(rawValue: 100) // sqlite3_step() has another row ready
public static let SQLITE_DONE = ResultCode(rawValue: 101) // sqlite3_step() has finished executing
// Extended Result Code
// https://www.sqlite.org/rescode.html#extended_result_code_list
public static let SQLITE_IOERR_READ = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (1<<8)))
public static let SQLITE_IOERR_SHORT_READ = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (2<<8)))
public static let SQLITE_IOERR_WRITE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (3<<8)))
public static let SQLITE_IOERR_FSYNC = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (4<<8)))
public static let SQLITE_IOERR_DIR_FSYNC = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (5<<8)))
public static let SQLITE_IOERR_TRUNCATE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (6<<8)))
public static let SQLITE_IOERR_FSTAT = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (7<<8)))
public static let SQLITE_IOERR_UNLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (8<<8)))
public static let SQLITE_IOERR_RDLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (9<<8)))
public static let SQLITE_IOERR_DELETE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (10<<8)))
public static let SQLITE_IOERR_BLOCKED = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (11<<8)))
public static let SQLITE_IOERR_NOMEM = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (12<<8)))
public static let SQLITE_IOERR_ACCESS = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (13<<8)))
public static let SQLITE_IOERR_CHECKRESERVEDLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (14<<8)))
public static let SQLITE_IOERR_LOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (15<<8)))
public static let SQLITE_IOERR_CLOSE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (16<<8)))
public static let SQLITE_IOERR_DIR_CLOSE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (17<<8)))
public static let SQLITE_IOERR_SHMOPEN = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (18<<8)))
public static let SQLITE_IOERR_SHMSIZE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (19<<8)))
public static let SQLITE_IOERR_SHMLOCK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (20<<8)))
public static let SQLITE_IOERR_SHMMAP = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (21<<8)))
public static let SQLITE_IOERR_SEEK = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (22<<8)))
public static let SQLITE_IOERR_DELETE_NOENT = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (23<<8)))
public static let SQLITE_IOERR_MMAP = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (24<<8)))
public static let SQLITE_IOERR_GETTEMPPATH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (25<<8)))
public static let SQLITE_IOERR_CONVPATH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (26<<8)))
public static let SQLITE_IOERR_VNODE = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (27<<8)))
public static let SQLITE_IOERR_AUTH = ResultCode(rawValue: (SQLITE_IOERR.rawValue | (28<<8)))
public static let SQLITE_LOCKED_SHAREDCACHE = ResultCode(rawValue: (SQLITE_LOCKED.rawValue | (1<<8)))
public static let SQLITE_BUSY_RECOVERY = ResultCode(rawValue: (SQLITE_BUSY.rawValue | (1<<8)))
public static let SQLITE_BUSY_SNAPSHOT = ResultCode(rawValue: (SQLITE_BUSY.rawValue | (2<<8)))
public static let SQLITE_CANTOPEN_NOTEMPDIR = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (1<<8)))
public static let SQLITE_CANTOPEN_ISDIR = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (2<<8)))
public static let SQLITE_CANTOPEN_FULLPATH = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (3<<8)))
public static let SQLITE_CANTOPEN_CONVPATH = ResultCode(rawValue: (SQLITE_CANTOPEN.rawValue | (4<<8)))
public static let SQLITE_CORRUPT_VTAB = ResultCode(rawValue: (SQLITE_CORRUPT.rawValue | (1<<8)))
public static let SQLITE_READONLY_RECOVERY = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (1<<8)))
public static let SQLITE_READONLY_CANTLOCK = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (2<<8)))
public static let SQLITE_READONLY_ROLLBACK = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (3<<8)))
public static let SQLITE_READONLY_DBMOVED = ResultCode(rawValue: (SQLITE_READONLY.rawValue | (4<<8)))
public static let SQLITE_ABORT_ROLLBACK = ResultCode(rawValue: (SQLITE_ABORT.rawValue | (2<<8)))
public static let SQLITE_CONSTRAINT_CHECK = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (1<<8)))
public static let SQLITE_CONSTRAINT_COMMITHOOK = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (2<<8)))
public static let SQLITE_CONSTRAINT_FOREIGNKEY = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (3<<8)))
public static let SQLITE_CONSTRAINT_FUNCTION = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (4<<8)))
public static let SQLITE_CONSTRAINT_NOTNULL = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (5<<8)))
public static let SQLITE_CONSTRAINT_PRIMARYKEY = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (6<<8)))
public static let SQLITE_CONSTRAINT_TRIGGER = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (7<<8)))
public static let SQLITE_CONSTRAINT_UNIQUE = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (8<<8)))
public static let SQLITE_CONSTRAINT_VTAB = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (9<<8)))
public static let SQLITE_CONSTRAINT_ROWID = ResultCode(rawValue: (SQLITE_CONSTRAINT.rawValue | (10<<8)))
public static let SQLITE_NOTICE_RECOVER_WAL = ResultCode(rawValue: (SQLITE_NOTICE.rawValue | (1<<8)))
public static let SQLITE_NOTICE_RECOVER_ROLLBACK = ResultCode(rawValue: (SQLITE_NOTICE.rawValue | (2<<8)))
public static let SQLITE_WARNING_AUTOINDEX = ResultCode(rawValue: (SQLITE_WARNING.rawValue | (1<<8)))
public static let SQLITE_AUTH_USER = ResultCode(rawValue: (SQLITE_AUTH.rawValue | (1<<8)))
public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8)))
}
/// DatabaseError wraps an SQLite error.
public struct DatabaseError : Error {
/// The SQLite error code (see
/// https://www.sqlite.org/rescode.html#primary_result_code_list).
///
/// do {
/// ...
/// } catch let error as DatabaseError where error.resultCode == .SQL_CONSTRAINT {
/// // A constraint error
/// }
///
/// 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.
///
/// See also `extendedResultCode`.
public var resultCode: ResultCode {
return extendedResultCode.primaryResultCode
}
/// The SQLite extended error code (see
/// https://www.sqlite.org/rescode.html#extended_result_code_list).
///
/// do {
/// ...
/// } catch let error as DatabaseError where error.extendedResultCode == .SQLITE_CONSTRAINT_FOREIGNKEY {
/// // A foreign key constraint error
/// }
///
/// See also `resultCode`.
public let extendedResultCode: ResultCode
/// The SQLite error message.
public let message: String?
@@ -10,13 +197,21 @@ public struct DatabaseError : ErrorType {
/// The SQL query that yielded the error (if relevant).
public let sql: String?
public init(code: Int32 = SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
self.code = code
/// Creates a Database Error
public init(resultCode: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
self.extendedResultCode = resultCode
self.message = message
self.sql = sql
self.arguments = arguments
}
/// Creates a Database Error with a raw Int32 result code.
///
/// This initializer is not public because library user is not supposed to
/// be exposed to raw result codes.
init(resultCode: Int32, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) {
self.init(resultCode: ResultCode(rawValue: resultCode), message: message, sql: sql, arguments: arguments)
}
// MARK: Not public
@@ -28,11 +223,11 @@ public struct DatabaseError : ErrorType {
extension DatabaseError: CustomStringConvertible {
/// A textual representation of `self`.
public var description: String {
var description = "SQLite error \(code)"
var description = "SQLite error \(resultCode.rawValue)"
if let sql = sql {
description += " with statement `\(sql)`"
}
if let arguments = arguments where !arguments.isEmpty {
if let arguments = arguments, !arguments.isEmpty {
description += " arguments \(arguments)"
}
if let message = message {
@@ -41,3 +236,21 @@ extension DatabaseError: CustomStringConvertible {
return description
}
}
extension DatabaseError : CustomNSError {
/// NSError bridging: the domain of the error.
public static var errorDomain: String {
return "GRDB.DatabaseError"
}
/// NSError bridging: the error code within the given domain.
public var errorCode: Int {
return Int(extendedResultCode.rawValue)
}
/// NSError bridging: the user-info dictionary.
public var errorUserInfo: [String : Any] {
return [NSLocalizedDescriptionKey: description]
}
}
+371
View File
@@ -0,0 +1,371 @@
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// An SQL function or aggregate.
public final class DatabaseFunction {
public let name: String
let argumentCount: Int32?
let pure: Bool
private let kind: Kind
private var nArg: Int32 { return argumentCount ?? -1 }
private var eTextRep: Int32 { return (SQLITE_UTF8 | (pure ? SQLITE_DETERMINISTIC : 0)) }
/// Returns an SQL function.
///
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
/// return nil
/// }
/// return int + 1
/// }
/// db.add(function: fn)
/// try Int.fetchOne(db, "SELECT succ(1)")! // 2
///
/// - parameters:
/// - name: The function name.
/// - argumentCount: The number of arguments of the function. If
/// omitted, or nil, the function accepts any number of arguments.
/// - pure: Whether the function is "pure", which means that its results
/// only depends on its inputs. When a function is pure, SQLite has
/// the opportunity to perform additional optimizations. Default value
/// is false.
/// - function: A function that takes an array of DatabaseValue
/// arguments, and returns an optional DatabaseValueConvertible such
/// as Int, String, NSDate, etc. The array is guaranteed to have
/// exactly *argumentCount* elements, provided *argumentCount* is
/// not nil.
public init(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, function: @escaping ([DatabaseValue]) throws -> DatabaseValueConvertible?) {
self.name = name
self.argumentCount = argumentCount
self.pure = pure
self.kind = .function{ (argc, argv) in
let arguments = (0..<Int(argc)).map { index in
DatabaseValue(sqliteValue: argv.unsafelyUnwrapped[index]!)
}
return try function(arguments)
}
}
/// Returns an SQL aggregate function.
///
/// struct MySum : DatabaseAggregate {
/// var sum: Int = 0
///
/// mutating func step(_ dbValues: [DatabaseValue]) {
/// if let int = Int.fromDatabaseValue(dbValues[0]) {
/// sum += int
/// }
/// }
///
/// func finalize() -> DatabaseValueConvertible? {
/// return sum
/// }
/// }
///
/// let dbQueue = DatabaseQueue()
/// let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
/// dbQueue.add(function: fn)
/// try dbQueue.inDatabase { db in
/// try db.execute("CREATE TABLE test(i)")
/// try db.execute("INSERT INTO test(i) VALUES (1)")
/// try db.execute("INSERT INTO test(i) VALUES (2)")
/// try Int.fetchOne(db, "SELECT mysum(i) FROM test")! // 3
/// }
///
/// - parameters:
/// - name: The function name.
/// - argumentCount: The number of arguments of the aggregate. If
/// omitted, or nil, the aggregate accepts any number of arguments.
/// - pure: Whether the aggregate is "pure", which means that its
/// results only depends on its inputs. When an aggregate is pure,
/// SQLite has the opportunity to perform additional optimizations.
/// Default value is false.
/// - aggregate: A type that implements the DatabaseAggregate protocol.
/// For each step of the aggregation, its `step` method is called with
/// an array of DatabaseValue arguments. The array is guaranteed to
/// have exactly *argumentCount* elements, provided *argumentCount* is
/// not nil.
public init<Aggregate: DatabaseAggregate>(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, aggregate: Aggregate.Type) {
self.name = name
self.argumentCount = argumentCount
self.pure = pure
self.kind = .aggregate { return Aggregate() }
}
/// Calls sqlite3_create_function_v2
/// See https://sqlite.org/c3ref/create_function.html
func install(in db: Database) {
// Retain the function definition
let definition = kind.definition
let definitionP = Unmanaged.passRetained(definition).toOpaque()
let code = sqlite3_create_function_v2(
db.sqliteConnection,
name,
nArg,
eTextRep,
definitionP,
kind.xFunc,
kind.xStep,
kind.xFinal,
{ definitionP in
// Release the function definition
Unmanaged<AnyObject>.fromOpaque(definitionP!).release()
})
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
}
}
/// Calls sqlite3_create_function_v2
/// See https://sqlite.org/c3ref/create_function.html
func uninstall(in db: Database) {
let code = sqlite3_create_function_v2(
db.sqliteConnection,
name,
nArg,
eTextRep,
nil, nil, nil, nil, nil)
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
fatalError(DatabaseError(resultCode: code, message: db.lastErrorMessage).description)
}
}
/// 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
private class FunctionDefinition {
let compute: (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?
init(compute: @escaping (Int32, UnsafeMutablePointer<OpaquePointer?>?) throws -> DatabaseValueConvertible?) {
self.compute = compute
}
}
/// The way to start an aggregate.
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
private class AggregateDefinition {
let makeAggregate: () -> DatabaseAggregate
init(makeAggregate: @escaping () -> DatabaseAggregate) {
self.makeAggregate = makeAggregate
}
}
/// The current state of an aggregate, storable in SQLite
private class AggregateContext {
var aggregate: DatabaseAggregate
var hasErrored = false
init(aggregate: DatabaseAggregate) {
self.aggregate = aggregate
}
}
/// A function kind: an "SQL function" or an "aggregate".
/// 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?)
/// An aggregate: SELECT f(foo) FROM bar GROUP BY baz
case aggregate(() -> DatabaseAggregate)
/// Feeds the `pApp` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
var definition: AnyObject {
switch self {
case .function(let compute):
return FunctionDefinition(compute: compute)
case .aggregate(let makeAggregate):
return AggregateDefinition(makeAggregate: makeAggregate)
}
}
/// Feeds the `xFunc` parameter of sqlite3_create_function_v2
/// 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
let definition = Unmanaged<FunctionDefinition>.fromOpaque(sqlite3_user_data(sqliteContext)).takeUnretainedValue()
do {
try DatabaseFunction.report(
result: definition.compute(argc, argv),
in: sqliteContext)
} catch {
DatabaseFunction.report(error: error, in: sqliteContext)
}
}
}
/// Feeds the `xStep` parameter of sqlite3_create_function_v2
/// 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
let aggregateContextU = DatabaseFunction.unmanagedAggregateContext(sqliteContext)
let aggregateContext = aggregateContextU.takeUnretainedValue()
assert(!aggregateContext.hasErrored)
do {
let arguments = (0..<Int(argc)).map { index in
DatabaseValue(sqliteValue: argv.unsafelyUnwrapped[index]!)
}
try aggregateContext.aggregate.step(arguments)
} catch {
aggregateContext.hasErrored = true
DatabaseFunction.report(error: error, in: sqliteContext)
}
}
}
/// Feeds the `xFinal` parameter of sqlite3_create_function_v2
/// http://sqlite.org/capi3ref.html#sqlite3_create_function
var xFinal: (@convention(c) (OpaquePointer?) -> Void)? {
guard case .aggregate = self else { return nil }
return { (sqliteContext) in
let aggregateContextU = DatabaseFunction.unmanagedAggregateContext(sqliteContext)
let aggregateContext = aggregateContextU.takeUnretainedValue()
aggregateContextU.release()
guard !aggregateContext.hasErrored else {
return
}
do {
try DatabaseFunction.report(
result: aggregateContext.aggregate.finalize(),
in: sqliteContext)
} catch {
DatabaseFunction.report(error: error, in: sqliteContext)
}
}
}
}
/// Helper function that extracts the current state of an aggregate from an
/// sqlite function execution context.
///
/// The result must be released when the aggregate concludes.
///
/// See https://sqlite.org/c3ref/context.html
/// See https://sqlite.org/c3ref/aggregate_context.html
private static func unmanagedAggregateContext(_ sqliteContext: OpaquePointer?) -> Unmanaged<AggregateContext> {
// The current aggregate buffer
let stride = MemoryLayout<Unmanaged<AggregateContext>>.stride
let aggregateContextBufferP = UnsafeMutableRawBufferPointer(start: sqlite3_aggregate_context(sqliteContext, Int32(stride))!, count: stride)
if aggregateContextBufferP.contains(where: { $0 != 0 }) {
// Buffer contains non-null pointer: load aggregate context
let aggregateContextP = aggregateContextBufferP.baseAddress!.assumingMemoryBound(to: Unmanaged<AggregateContext>.self)
return aggregateContextP.pointee
} else {
// Buffer contains null pointer: create aggregate context...
let aggregate = Unmanaged<AggregateDefinition>.fromOpaque(sqlite3_user_data(sqliteContext))
.takeUnretainedValue()
.makeAggregate()
let aggregateContext = AggregateContext(aggregate: aggregate)
// retain and store in SQLite's buffer
let aggregateContextU = Unmanaged.passRetained(aggregateContext)
var aggregateContextP = aggregateContextU.toOpaque()
withUnsafeBytes(of: &aggregateContextP) {
aggregateContextBufferP.copyBytes(from: $0)
}
return aggregateContextU
}
}
private static func report(result: DatabaseValueConvertible?, in sqliteContext: OpaquePointer?) {
switch result?.databaseValue.storage ?? .null {
case .null:
sqlite3_result_null(sqliteContext)
case .int64(let int64):
sqlite3_result_int64(sqliteContext, int64)
case .double(let double):
sqlite3_result_double(sqliteContext, double)
case .string(let string):
sqlite3_result_text(sqliteContext, string, -1, SQLITE_TRANSIENT)
case .blob(let data):
data.withUnsafeBytes { bytes in
sqlite3_result_blob(sqliteContext, bytes, Int32(data.count), SQLITE_TRANSIENT)
}
}
}
private static func report(error: Error, in sqliteContext: OpaquePointer?) {
if let error = error as? DatabaseError {
if let message = error.message {
sqlite3_result_error(sqliteContext, message, -1)
}
sqlite3_result_error_code(sqliteContext, error.extendedResultCode.rawValue)
} else {
sqlite3_result_error(sqliteContext, "\(error)", -1)
}
}
}
extension DatabaseFunction : Hashable {
/// The hash value
public var hashValue: Int {
return name.hashValue ^ nArg.hashValue
}
/// Two functions are equal if they share the same name and arity.
public static func == (lhs: DatabaseFunction, rhs: DatabaseFunction) -> Bool {
return lhs.name == rhs.name && lhs.nArg == rhs.nArg
}
}
/// The protocol for custom SQLite aggregates.
///
/// For example:
///
/// struct MySum : DatabaseAggregate {
/// var sum: Int = 0
///
/// mutating func step(_ dbValues: [DatabaseValue]) {
/// if let int = Int.fromDatabaseValue(dbValues[0]) {
/// sum += int
/// }
/// }
///
/// func finalize() -> DatabaseValueConvertible? {
/// return sum
/// }
/// }
///
/// let dbQueue = DatabaseQueue()
/// let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
/// dbQueue.add(function: fn)
/// try dbQueue.inDatabase { db in
/// try db.execute("CREATE TABLE test(i)")
/// try db.execute("INSERT INTO test(i) VALUES (1)")
/// try db.execute("INSERT INTO test(i) VALUES (2)")
/// try Int.fetchOne(db, "SELECT mysum(i) FROM test")! // 3
/// }
public protocol DatabaseAggregate {
/// Creates an aggregate.
init()
/// This method is called at each step of the aggregation.
///
/// The dbValues argument contains as many values as given to the SQL
/// aggregate function.
///
/// -- One value
/// SELECT maxLength(name) FROM players
///
/// -- Two values
/// SELECT maxFullNameLength(firstName, lastName) FROM players
///
/// This method is never called after the finalize() method has been called.
mutating func step(_ dbValues: [DatabaseValue]) throws
/// Returns the final result
func finalize() throws -> DatabaseValueConvertible?
}
+506 -206
View File
@@ -1,3 +1,13 @@
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
#if os(iOS)
import UIKit
#endif
/// A DatabasePool grants concurrent accesses to an SQLite database.
public final class DatabasePool {
@@ -14,125 +24,80 @@ public final class DatabasePool {
/// - configuration: A configuration.
/// - maximumReaderCount: The maximum number of readers. Default is 5.
/// - throws: A DatabaseError whenever an SQLite error occurs.
public convenience init(path: String, configuration: Configuration = Configuration(), maximumReaderCount: Int = 5) throws {
precondition(maximumReaderCount > 1, "maximumReaderCount must be at least 1")
public init(path: String, configuration: Configuration = Configuration()) throws {
GRDBPrecondition(configuration.maximumReaderCount > 0, "configuration.maximumReaderCount must be at least 1")
// Shared database schema cache
let databaseSchemaCache = SharedDatabaseSchemaCache()
// Writer and readers share the same database schema cache
let sharedSchemaCache = SharedDatabaseSchemaCache()
// Writer
var writerConfig = configuration
writerConfig.readonly = false
let writer = try SerializedDatabase(
writer = try SerializedDatabase(
path: path,
configuration: writerConfig,
schemaCache: databaseSchemaCache)
configuration: configuration,
schemaCache: sharedSchemaCache)
// Activate WAL Mode
let mode = writer.inDatabase { db in
String.fetchOne(db, "PRAGMA journal_mode=WAL")
}
guard mode == "wal" else {
throw DatabaseError(message: "could not activate WAL Mode at path: \(path)")
// Activate WAL Mode unless readonly
if !configuration.readonly {
try writer.sync { db in
let journalMode = try String.fetchOne(db, "PRAGMA journal_mode = WAL")
guard journalMode == "wal" else {
throw DatabaseError(message: "could not activate WAL Mode at path: \(path)")
}
// https://www.sqlite.org/pragma.html#pragma_synchronous
// > Many applications choose NORMAL when in WAL mode
try db.execute("PRAGMA synchronous = NORMAL")
if !FileManager.default.fileExists(atPath: path + "-wal") {
// Create the -wal file if it does not exist yet. This
// avoids an SQLITE_CANTOPEN (14) error whenever a user
// opens a pool to an existing non-WAL database, and
// attempts to read from it.
// See https://github.com/groue/GRDB.swift/issues/102
try db.execute("CREATE TABLE grdb_issue_102 (id INTEGER PRIMARY KEY); DROP TABLE grdb_issue_102;")
}
}
}
// Readers
var readerConfig = configuration
readerConfig = configuration
readerConfig.readonly = true
readerConfig.defaultTransactionKind = .Deferred
self.init(path: path, readerConfiguration: readerConfig, maximumReaderCount: maximumReaderCount, databaseSchemaCache: databaseSchemaCache, writer: writer)
}
// MARK: - Database access
/// Synchronously executes a read-only block in the database, and returns
/// its result.
///
/// let persons = dbPool.read { db in
/// Person.fetch(...)
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func read<T>(block: (db: Database) throws -> T) rethrows -> T {
// Wrap the read in a DEFERRED transaction.
//
// This prevents the writer to sneak in between two selects:
//
// Thread 1 Thread 2
// BEGIN DEFERRED TRANSACTION
// SELECT COUNT(*) FROM items -> 0
// INSERT INTO items...
// SELECT COUNT(*) FROM items -> 0 (invisible insert)
// COMMIT
//
// Without the transaction, we would get:
//
// Thread 1 Thread 2
// SELECT COUNT(*) FROM items -> 0
// INSERT INTO items...
// SELECT COUNT(*) FROM items -> 1 (visible insert)
//
// See DatabasePoolTests.testReaderIsolation().
return try readerPool.get { reader in
try reader.inDatabase { db in
var result: T? = nil
try db.inTransaction(.Deferred) {
result = try block(db: db)
return .Commit
readerConfig.defaultTransactionKind = .deferred // Make it the default for readers. Other transaction kinds are forbidden by SQLite in read-only connections.
readerPool = Pool(maximumCount: configuration.maximumReaderCount, makeElement: { [unowned self] in
let reader = try SerializedDatabase(
path: path,
configuration: self.readerConfig,
schemaCache: sharedSchemaCache)
reader.sync { db in
for function in self.functions {
db.add(function: function)
}
for collation in self.collations {
db.add(collation: collation)
}
return result!
}
}
return reader
})
}
/// Synchronously executes an update block in the database, and returns
/// its result.
///
/// dbPool.write { db in
/// db.execute(...)
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func write(block: (db: Database) throws -> Void) rethrows {
try writer.inDatabase(block)
#if os(iOS)
deinit {
// Undo job done in setupMemoryManagement()
//
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
// Explicit unregistration is required before iOS 9 and OS X 10.11.
NotificationCenter.default.removeObserver(self)
}
#endif
/// Synchronously executes a block in the database, wrapped inside a
/// transaction.
///
/// If the block throws an error, the transaction is rollbacked and the
/// error is rethrown.
///
/// try dbPool.writeInTransaction { db in
/// db.execute(...)
/// return .Commit
/// }
///
/// This method is *not* reentrant.
///
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .Immediate. See https://www.sqlite.org/lang_transaction.html
/// for more information.
/// - block: A block that executes SQL statements and return either
/// .Commit or .Rollback.
/// - throws: The error thrown by the block.
public func writeInTransaction(kind: TransactionKind? = nil, _ block: (db: Database) throws -> TransactionCompletion) rethrows {
try writer.inDatabase { db in
try db.inTransaction(kind) {
try block(db: db)
}
}
// MARK: - Configuration
/// The path to the database.
public var path: String {
return writer.path
}
@@ -145,13 +110,14 @@ public final class DatabasePool {
/// more information.
///
/// - parameter kind: The checkpoint mode (default passive)
public func checkpoint(kind: CheckpointMode = .Passive) throws {
try writer.inDatabase { db in
public func checkpoint(_ kind: Database.CheckpointMode = .passive) throws {
try write { db in
// TODO: read https://www.sqlite.org/c3ref/wal_checkpoint_v2.html and
// check whether we need a busy handler on writer and/or readers.
// check whether we need a busy handler on writer and/or readers
// when kind is not .Passive.
let code = sqlite3_wal_checkpoint_v2(db.sqliteConnection, nil, kind.rawValue, nil, nil)
guard code == SQLITE_OK else {
throw DatabaseError(code: code, message: db.lastErrorMessage, sql: nil)
throw DatabaseError(resultCode: code, message: db.lastErrorMessage, sql: nil)
}
}
}
@@ -162,154 +128,488 @@ public final class DatabasePool {
/// Free as much memory as possible.
///
/// This method blocks the current thread until all database accesses are completed.
/// (TODO: test this assertion, and also that all readers connections are closed).
///
/// See also setupMemoryManagement(application:)
public func releaseMemory() {
writer.inDatabase { db in
db.releaseMemory()
}
// TODO: test that this method blocks the current thread until all database accesses are completed.
write { $0.releaseMemory() }
readerPool.forEach { reader in
reader.inDatabase { db in
db.releaseMemory()
}
reader.sync { $0.releaseMemory() }
}
readerPool.clear()
}
#if os(iOS)
/// Listens to UIApplicationDidEnterBackgroundNotification and
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
/// as much memory as possible.
///
/// - param application: The UIApplication that will start a background
/// task to let the database pool release its memory when the application
/// enters background.
public func setupMemoryManagement(in application: UIApplication) {
self.application = application
let center = NotificationCenter.default
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
}
private var application: UIApplication!
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
guard let application = application else {
return
}
var task: UIBackgroundTaskIdentifier! = nil
task = application.beginBackgroundTask(expirationHandler: nil)
if task == UIBackgroundTaskInvalid {
// Perform releaseMemory() synchronously.
releaseMemory()
} else {
// Perform releaseMemory() asynchronously.
DispatchQueue.global().async {
self.releaseMemory()
application.endBackgroundTask(task)
}
}
}
@objc private func applicationDidReceiveMemoryWarning(_ notification: NSNotification) {
DispatchQueue.global().async {
self.releaseMemory()
}
}
#endif
// MARK: - Not public
private let writer: SerializedDatabase
private let readerPool: Pool<SerializedDatabase>
private var readerConfig: Configuration
private var readerPool: Pool<SerializedDatabase>! = nil // var and nil-initialized so that we can use `self` when creating readerPool in DatabasePool.init()
private var functions = Set<DatabaseFunction>()
private var collations = Set<DatabaseCollation>()
private init(path: String, readerConfiguration: Configuration = Configuration(), maximumReaderCount: Int, databaseSchemaCache: DatabaseSchemaCacheType, writer: SerializedDatabase) {
self.writer = writer
self.readerPool = Pool<SerializedDatabase>(maximumCount: maximumReaderCount)
readerPool.makeElement = { [unowned self] in
let serializedDatabase = try! SerializedDatabase(
path: path,
configuration: readerConfiguration,
schemaCache: databaseSchemaCache)
serializedDatabase.inDatabase { db in
for function in self.functions {
db.addFunction(function)
}
for collation in self.collations {
db.addCollation(collation)
}
}
return serializedDatabase
}
}
}
// The available [checkppint modes](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html).
public enum CheckpointMode: Int32 {
case Passive = 0 // SQLITE_CHECKPOINT_PASSIVE
case Full = 1 // SQLITE_CHECKPOINT_FULL
case Restart = 2 // SQLITE_CHECKPOINT_RESTART
case Truncate = 3 // SQLITE_CHECKPOINT_TRUNCATE
}
// =========================================================================
// MARK: - Functions
// MARK: - Encryption
extension DatabasePool {
#if SQLITE_HAS_CODEC
extension DatabasePool {
/// Changes the passphrase of an encrypted database
public func change(passphrase: String) throws {
try readerPool.clear(andThen: {
try write { try $0.change(passphrase: passphrase) }
readerConfig.passphrase = passphrase
})
}
}
#endif
// =========================================================================
// MARK: - DatabaseReader
extension DatabasePool : DatabaseReader {
// MARK: - Read 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
/// // `wines` table is modified between the two requests:
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// try dbPool.read { db in
/// // Now this value may be different:
/// let count = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// 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 {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
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) {
result = try block(db)
return .commit
}
return result!
}
}
}
/// 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, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// Cursor iteration is safe, though:
///
/// try dbPool.unsafeRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, "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 {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
return try readerPool.get { reader in
try reader.sync(block)
}
}
/// 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, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// Cursor iteration is safe, though:
///
/// try dbPool.unsafeReentrantRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// This method is reentrant. It should be avoided 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 {
if let reader = currentReader {
return try reader.reentrantSync(block)
} else {
return try readerPool.get { reader in
try reader.sync(block)
}
}
}
/// Returns a reader that can be used from the current dispatch queue,
/// if any.
private var currentReader: SerializedDatabase? {
var readers: [SerializedDatabase] = []
readerPool.forEach { reader in
// We can't check for reader.onValidQueue here because
// Pool.forEach() runs its closure argument in some arbitrary
// dispatch queue. We thus extract the reader so that we can query
// it below.
readers.append(reader)
}
// Now the readers array contains some readers. The pool readers may
// already be different, because some other thread may have started
// a new read, for example.
//
// This doesn't matter: the reader we are looking for is already on
// its own dispatch queue. If it exists, is still in use, thus still
// in the pool, and thus still relevant for our check:
return readers.first { $0.onValidQueue }
}
// MARK: - Functions
/// Add or redefine an SQL function.
///
/// let fn = DatabaseFunction("succ", argumentCount: 1) { databaseValues in
/// let dbv = databaseValues.first!
/// guard let int = dbv.value() as Int? else {
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
/// return nil
/// }
/// return int + 1
/// }
/// dbPool.addFunction(fn)
/// dbPool.read { db in
/// Int.fetchOne(db, "SELECT succ(1)") // 2
/// dbPool.add(function: fn)
/// try dbPool.read { db in
/// try Int.fetchOne(db, "SELECT succ(1)") // 2
/// }
public func addFunction(function: DatabaseFunction) {
functions.remove(function)
functions.insert(function)
writer.inDatabase { db in
db.addFunction(function)
}
public func add(function: DatabaseFunction) {
functions.update(with: function)
write { $0.add(function: function) }
readerPool.forEach { reader in
reader.inDatabase { db in
db.addFunction(function)
}
reader.sync { $0.add(function: function) }
}
}
/// Remove an SQL function.
public func removeFunction(function: DatabaseFunction) {
public func remove(function: DatabaseFunction) {
functions.remove(function)
writer.inDatabase { db in
db.removeFunction(function)
}
write { $0.remove(function: function) }
readerPool.forEach { reader in
reader.inDatabase { db in
db.removeFunction(function)
}
reader.sync { $0.remove(function: function) }
}
}
}
// =========================================================================
// MARK: - Collations
extension DatabasePool {
// MARK: - Collations
/// Add or redefine a collation.
///
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
/// return (string1 as NSString).localizedStandardCompare(string2)
/// }
/// dbPool.addCollation(collation)
/// dbPool.write { db in
/// dbPool.add(collation: collation)
/// try dbPool.write { db in
/// try db.execute("CREATE TABLE files (name TEXT COLLATE LOCALIZED_STANDARD")
/// }
public func addCollation(collation: DatabaseCollation) {
collations.remove(collation)
collations.insert(collation)
writer.inDatabase { db in
db.addCollation(collation)
}
public func add(collation: DatabaseCollation) {
collations.update(with: collation)
write { $0.add(collation: collation) }
readerPool.forEach { reader in
reader.inDatabase { db in
db.addCollation(collation)
}
reader.sync { $0.add(collation: collation) }
}
}
/// Remove a collation.
public func removeCollation(collation: DatabaseCollation) {
public func remove(collation: DatabaseCollation) {
collations.remove(collation)
writer.inDatabase { db in
db.removeCollation(collation)
}
write { $0.remove(collation: collation) }
readerPool.forEach { reader in
reader.inDatabase { db in
db.removeCollation(collation)
}
reader.sync { $0.remove(collation: collation) }
}
}
}
// =========================================================================
// MARK: - DatabaseWriter
extension DatabasePool : DatabaseWriter {
// MARK: - Writing in Database
/// Synchronously executes an update block in a protected dispatch queue,
/// and returns its result.
///
/// Eventual concurrent database updates are postponed until the block
/// has executed.
///
/// try dbPool.write { db in
/// try db.execute(...)
/// }
///
/// To maintain database integrity, and preserve eventual concurrent reads
/// from seeing an inconsistent database state, prefer the
/// writeInTransaction method.
///
/// This method is *not* reentrant.
///
/// - parameters block: A block that executes SQL statements and return
/// either .commit or .rollback.
/// - throws: The error thrown by the block.
public func write<T>(_ block: (Database) throws -> T) rethrows -> T {
return try writer.sync(block)
}
/// Synchronously executes a block in a protected dispatch queue, wrapped
/// inside a transaction.
///
/// Eventual concurrent database updates are postponed until the block
/// has executed.
///
/// If the block throws an error, the transaction is rollbacked and the
/// error is rethrown. If the block returns .rollback, the transaction is
/// also rollbacked, but no error is thrown.
///
/// try dbPool.writeInTransaction { db in
/// db.execute(...)
/// return .commit
/// }
///
/// Eventual concurrent readers do not see partial changes:
///
/// dbPool.writeInTransaction { db in
/// // Eventually preserve a zero balance
/// try db.execute(db, "INSERT INTO credits ...", arguments: [amount])
/// try db.execute(db, "INSERT INTO debits ...", arguments: [amount])
/// }
///
/// dbPool.read { db in
/// // Here the balance is guaranteed to be zero
/// }
///
/// This method is *not* reentrant.
///
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .immediate. See https://www.sqlite.org/lang_transaction.html
/// for more information.
/// - block: A block that executes SQL statements and return either
/// .commit or .rollback.
/// - throws: The error thrown by the block, or any error establishing the
/// transaction.
public func writeInTransaction(_ kind: Database.TransactionKind? = nil, _ block: (Database) throws -> Database.TransactionCompletion) throws {
try write { db in
try db.inTransaction(kind) {
try block(db)
}
}
}
/// Synchronously executes an update block in a protected dispatch queue,
/// and returns its result.
///
/// Eventual concurrent database updates are postponed until the block
/// has executed.
///
/// try dbPool.unsafeReentrantWrite { db in
/// try db.execute(...)
/// }
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
public func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T {
return try writer.reentrantSync(block)
}
// MARK: - Reading from Database
/// Asynchronously executes a read-only block in a protected dispatch queue,
/// wrapped in a deferred transaction.
///
/// This method must be called from the writing dispatch queue.
///
/// 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.
///
/// try dbPool.write { db in
/// try db.execute("DELETE FROM players")
/// try dbPool.readFromCurrentState { db in
/// // Guaranteed to be zero
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM players")!
/// }
/// try db.execute("INSERT INTO players ...")
/// }
///
/// This method blocks the current thread until the isolation guarantee has
/// been established, and before the block argument has run.
///
/// - 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 readFromCurrentState(_ block: @escaping (Database) -> Void) throws {
// https://www.sqlite.org/isolation.html
//
// > In WAL mode, SQLite exhibits "snapshot isolation". When a read
// > transaction starts, that reader continues to see an unchanging
// > "snapshot" of the database file as it existed at the moment in time
// > when the read transaction started. Any write transactions that
// > commit while the read transaction is active are still invisible to
// > the read transaction, because the reader is seeing a snapshot of
// > database file from a prior moment in time.
//
// That's exactly what we need. But what does "when read transaction
// starts" mean?
//
// http://www.sqlite.org/lang_transaction.html
//
// > Deferred [transaction] means that no locks are acquired on the
// > database until the database is first accessed. [...] Locks are not
// > acquired until the first read or write operation. [...] Because the
// > acquisition of locks is deferred until they are needed, it is
// > possible that another thread or process could create a separate
// > transaction and write to the database after the BEGIN on the
// > current thread has executed.
//
// Now that's precise enough: SQLite defers "snapshot isolation" until
// the first SELECT:
//
// Reader Writer
// BEGIN DEFERRED TRANSACTION
// UPDATE ... (1)
// Here the change (1) is visible
// SELECT ...
// UPDATE ... (2)
// Here the change (2) is not visible
//
// The readFromCurrentState method says that no change should be visible
// at all. We thus have to perform a select that establishes the
// snapshot isolation before we release the writer queue:
//
// Reader Writer
// BEGIN DEFERRED TRANSACTION
// SELECT anything
// UPDATE ...
// Here the change is not visible by GRDB user
// This method must be called from the writing dispatch queue:
writer.preconditionValidQueue()
// The semaphore that blocks the writing dispatch queue until snapshot
// isolation has been established:
let semaphore = DispatchSemaphore(value: 0)
var readError: Error? = nil
try readerPool.get { reader in
reader.async { db in
do {
try db.beginTransaction(.deferred)
assert(db.isInsideTransaction)
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").cursor().next()
} catch {
readError = error
semaphore.signal() // Release the writer queue and rethrow error
return
}
semaphore.signal() // We can release the writer queue now that we are isolated for good
block(db)
_ = try? db.commit() // Ignore commit error
}
}
_ = semaphore.wait(timeout: .distantFuture)
if let readError = readError {
// TODO: write a test for this
throw readError
}
}
}
+268 -86
View File
@@ -1,16 +1,12 @@
import Foundation
#if os(iOS)
import UIKit
#endif
/// A DatabaseQueue serializes access to an SQLite database.
public final class DatabaseQueue {
// MARK: - Configuration
/// The database configuration
public var configuration: Configuration {
return serializedDatabase.configuration
}
// MARK: - Initializers
/// Opens the SQLite database at path *path*.
@@ -23,11 +19,11 @@ public final class DatabaseQueue {
/// - path: The path to the database file.
/// - configuration: A configuration.
/// - throws: A DatabaseError whenever an SQLite error occurs.
public convenience init(path: String, configuration: Configuration = Configuration()) throws {
try self.init(serializedDatabase: SerializedDatabase(
public init(path: String, configuration: Configuration = Configuration()) throws {
serializedDatabase = try SerializedDatabase(
path: path,
configuration: configuration,
schemaCache: DatabaseSchemaCache()))
schemaCache: SimpleDatabaseSchemaCache())
}
/// Opens an in-memory SQLite database.
@@ -37,36 +33,65 @@ public final class DatabaseQueue {
/// Database memory is released when the database queue gets deallocated.
///
/// - parameter configuration: A configuration.
public convenience init(configuration: Configuration = Configuration()) {
try! self.init(path: ":memory:", configuration: configuration)
public init(configuration: Configuration = Configuration()) {
// Assume SQLite always succeeds creating an in-memory database
serializedDatabase = try! SerializedDatabase(
path: ":memory:",
configuration: configuration,
schemaCache: SimpleDatabaseSchemaCache())
}
#if os(iOS)
deinit {
// Undo job done in setupMemoryManagement()
//
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
// Explicit unregistration is required before iOS 9 and OS X 10.11.
NotificationCenter.default.removeObserver(self)
}
#endif
// MARK: - Configuration
/// The database configuration
public var configuration: Configuration {
return serializedDatabase.configuration
}
/// The path to the database file; it is ":memory:" for in-memory databases.
public var path: String {
return serializedDatabase.path
}
// MARK: - Database access
/// Synchronously executes a block in the database, and returns its result.
/// Synchronously executes a block in a protected dispatch queue, and
/// returns its result.
///
/// let persons = dbQueue.inDatabase { db in
/// Person.fetchAll(...)
/// let players = try dbQueue.inDatabase { db in
/// try Player.fetchAll(...)
/// }
///
/// This method is *not* reentrant.
///
/// - parameter block: A block that accesses the database.
/// - throws: The error thrown by the block.
public func inDatabase<T>(block: (db: Database) throws -> T) rethrows -> T {
return try serializedDatabase.inDatabase(block)
public func inDatabase<T>(_ block: (Database) throws -> T) rethrows -> T {
return try serializedDatabase.sync(block)
}
/// Synchronously executes a block in the database, wrapped inside a
/// transaction.
/// Synchronously executes a block in a protected dispatch queue, wrapped
/// inside a transaction.
///
/// If the block throws an error, the transaction is rollbacked and the
/// error is rethrown.
/// error is rethrown. If the block returns .rollback, the transaction is
/// also rollbacked, but no error is thrown.
///
/// try dbQueue.inTransaction { db in
/// db.execute(...)
/// return .Commit
/// return .commit
/// }
///
/// This method is *not* reentrant.
@@ -74,15 +99,15 @@ public final class DatabaseQueue {
/// - parameters:
/// - kind: The transaction type (default nil). If nil, the transaction
/// type is configuration.defaultTransactionKind, which itself
/// defaults to .Immediate. See https://www.sqlite.org/lang_transaction.html
/// defaults to .immediate. See https://www.sqlite.org/lang_transaction.html
/// for more information.
/// - block: A block that executes SQL statements and return either
/// .Commit or .Rollback.
/// .commit or .rollback.
/// - throws: The error thrown by the block.
public func inTransaction(kind: TransactionKind? = nil, _ block: (db: Database) throws -> TransactionCompletion) throws {
try serializedDatabase.inDatabase { db in
public func inTransaction(_ kind: Database.TransactionKind? = nil, _ block: (Database) throws -> Database.TransactionCompletion) throws {
try inDatabase { db in
try db.inTransaction(kind) {
try block(db: db)
try block(db)
}
}
}
@@ -93,100 +118,257 @@ public final class DatabaseQueue {
/// Free as much memory as possible.
///
/// This method blocks the current thread until all database accesses are completed.
///
/// See also setupMemoryManagement(application:)
public func releaseMemory() {
serializedDatabase.inDatabase { db in
db.releaseMemory()
inDatabase { $0.releaseMemory() }
}
#if os(iOS)
/// Listens to UIApplicationDidEnterBackgroundNotification and
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
/// as much memory as possible.
///
/// - param application: The UIApplication that will start a background
/// task to let the database queue release its memory when the application
/// enters background.
public func setupMemoryManagement(in application: UIApplication) {
self.application = application
let center = NotificationCenter.default
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
}
private var application: UIApplication?
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
guard let application = application else {
return
}
var task: UIBackgroundTaskIdentifier! = nil
task = application.beginBackgroundTask(expirationHandler: nil)
if task == UIBackgroundTaskInvalid {
// Perform releaseMemory() synchronously.
releaseMemory()
} else {
// Perform releaseMemory() asynchronously.
DispatchQueue.global().async {
self.releaseMemory()
application.endBackgroundTask(task)
}
}
}
@objc private func applicationDidReceiveMemoryWarning(_ notification: NSNotification) {
DispatchQueue.global().async {
self.releaseMemory()
}
}
#endif
// MARK: - Not public
/// The serialized database
// https://www.sqlite.org/isolation.html
//
// > Within a single database connection X, a SELECT statement always
// > sees all changes to the database that are completed prior to the
// > start of the SELECT statement, whether committed or uncommitted.
// > And the SELECT statement obviously does not see any changes that
// > occur after the SELECT statement completes. But what about changes
// > that occur while the SELECT statement is running? What if a SELECT
// > statement is started and the sqlite3_step() interface steps through
// > roughly half of its output, then some UPDATE statements are run by
// > the application that modify the table that the SELECT statement is
// > reading, then more calls to sqlite3_step() are made to finish out
// > the SELECT statement? Will the later steps of the SELECT statement
// > see the changes made by the UPDATE or not? The answer is that this
// > behavior is undefined.
//
// This is why we use a serialized database:
private var serializedDatabase: SerializedDatabase
init(serializedDatabase: SerializedDatabase) {
// IMPLEMENTATION NOTE
//
// https://www.sqlite.org/isolation.html
//
// > Within a single database connection X, a SELECT statement always
// > sees all changes to the database that are completed prior to the
// > start of the SELECT statement, whether committed or uncommitted.
// > And the SELECT statement obviously does not see any changes that
// > occur after the SELECT statement completes. But what about changes
// > that occur while the SELECT statement is running? What if a SELECT
// > statement is started and the sqlite3_step() interface steps through
// > roughly half of its output, then some UPDATE statements are run by
// > the application that modify the table that the SELECT statement is
// > reading, then more calls to sqlite3_step() are made to finish out
// > the SELECT statement? Will the later steps of the SELECT statement
// > see the changes made by the UPDATE or not? The answer is that this
// > behavior is undefined.
//
// This is why we use a serialized database:
self.serializedDatabase = serializedDatabase
}
}
// =========================================================================
// MARK: - Functions
// MARK: - Encryption
extension DatabaseQueue {
#if SQLITE_HAS_CODEC
extension DatabaseQueue {
/// Changes the passphrase of an encrypted database
public func change(passphrase: String) throws {
try inDatabase { try $0.change(passphrase: passphrase) }
}
}
#endif
// =========================================================================
// MARK: - DatabaseReader
extension DatabaseQueue : DatabaseReader {
// MARK: - DatabaseReader Protocol Adoption
/// 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(...)
/// }
///
/// This method is *not* reentrant.
///
/// Starting iOS 8.2, OSX 10.10, and with custom SQLite builds and
/// SQLCipher, attempts to write in the database throw a DatabaseError whose
/// resultCode is `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 {
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
#if GRDBCUSTOMSQLITE || GRDBCIPHER
return try inDatabase { try readOnly($0, block) }
#else
if #available(iOS 8.2, OSX 10.10, *) {
return try inDatabase { try readOnly($0, block) }
} else {
return try inDatabase(block)
}
#endif
}
/// Alias for `inDatabase`. See `DatabaseReader.unsafeRead`.
public func unsafeRead<T>(_ block: (Database) throws -> T) rethrows -> T {
return try inDatabase(block)
}
/// Synchronously executes a block in a protected dispatch queue, and
/// returns its result.
///
/// try dbQueue.unsafeReentrantRead { db in
/// try db.execute(...)
/// }
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
return try serializedDatabase.reentrantSync(block)
}
// MARK: - Functions
/// Add or redefine an SQL function.
///
/// let fn = DatabaseFunction("succ", argumentCount: 1) { databaseValues in
/// let dbv = databaseValues.first!
/// guard let int = dbv.value() as Int? else {
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
/// return nil
/// }
/// return int + 1
/// }
/// dbQueue.addFunction(fn)
/// dbQueue.inDatabase { db in
/// Int.fetchOne(db, "SELECT succ(1)") // 2
/// dbQueue.add(function: fn)
/// try dbQueue.inDatabase { db in
/// try Int.fetchOne(db, "SELECT succ(1)") // 2
/// }
public func addFunction(function: DatabaseFunction) {
serializedDatabase.inDatabase { db in
db.addFunction(function)
}
public func add(function: DatabaseFunction) {
inDatabase { $0.add(function: function) }
}
/// Remove an SQL function.
public func removeFunction(function: DatabaseFunction) {
serializedDatabase.inDatabase { db in
db.removeFunction(function)
}
public func remove(function: DatabaseFunction) {
inDatabase { $0.remove(function: function) }
}
}
// =========================================================================
// MARK: - Collations
extension DatabaseQueue {
// MARK: - Collations
/// Add or redefine a collation.
///
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
/// return (string1 as NSString).localizedStandardCompare(string2)
/// }
/// dbQueue.addCollation(collation)
/// dbQueue.add(collation: collation)
/// try dbQueue.inDatabase { db in
/// try db.execute("CREATE TABLE files (name TEXT COLLATE LOCALIZED_STANDARD")
/// }
public func addCollation(collation: DatabaseCollation) {
serializedDatabase.inDatabase { db in
db.addCollation(collation)
}
public func add(collation: DatabaseCollation) {
inDatabase { $0.add(collation: collation) }
}
/// Remove a collation.
public func removeCollation(collation: DatabaseCollation) {
serializedDatabase.inDatabase { db in
db.removeCollation(collation)
}
public func remove(collation: DatabaseCollation) {
inDatabase { $0.remove(collation: collation) }
}
}
// =========================================================================
// MARK: - DatabaseWriter
extension DatabaseQueue : DatabaseWriter {
// MARK: - DatabaseWriter Protocol Adoption
/// Alias for `inDatabase`. See `DatabaseWriter.write`.
public func write<T>(_ block: (Database) throws -> T) rethrows -> T {
return try inDatabase(block)
}
/// Synchronously executes *block*.
///
/// Starting iOS 8.2, OSX 10.10, and with custom SQLite builds and
/// SQLCipher, attempts to write in the database throw a DatabaseError whose
/// resultCode is `SQLITE_READONLY`.
///
/// This method must be called from the protected database dispatch queue.
/// See `DatabaseWriter.readFromCurrentState`.
public func readFromCurrentState(_ block: @escaping (Database) -> Void) {
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
#if GRDBCUSTOMSQLITE || GRDBCIPHER
serializedDatabase.execute { readOnly($0, block) }
#else
if #available(iOS 8.2, OSX 10.10, *) {
serializedDatabase.execute { readOnly($0, block) }
} else {
serializedDatabase.execute(block)
}
#endif
}
/// Synchronously executes a block in a protected dispatch queue, and
/// returns its result.
///
/// try dbQueue.unsafeReentrantWrite { db in
/// try db.execute(...)
/// }
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
public func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T {
return try serializedDatabase.reentrantSync(block)
}
}
// Wraps the block between two `PRAGMA query_only` statements.
//
// This method is unsafe because the two calls to `PRAGMA query_only` are
// not guaranteed to be serialized (some other thread could mess with this).
private func readOnly<T>(_ db: Database, _ block: (Database) throws -> T) rethrows -> T {
if db.configuration.readonly {
return try block(db)
} else {
try! db.execute("PRAGMA query_only = 1") // Assume can't fail
let result = try block(db)
try! db.execute("PRAGMA query_only = 0") // Assume can't fail
return result
}
}
+251
View File
@@ -0,0 +1,251 @@
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// The protocol for all types that can fetch values from a database.
///
/// It is adopted by DatabaseQueue and DatabasePool.
///
/// The protocol comes with isolation guarantees that describe the behavior of
/// adopting types in a multithreaded application.
///
/// Types that adopt the protocol can provide in practice stronger guarantees.
/// For example, DatabaseQueue provides a stronger isolation level
/// than DatabasePool.
///
/// **Warning**: Isolation guarantees stand as long as there is no external
/// connection to the database. Should you have to cope with external
/// connections, protect yourself with transactions, and be ready to setup a
/// [busy handler](https://www.sqlite.org/c3ref/busy_handler.html).
public protocol DatabaseReader : class {
// MARK: - Read From Database
/// Synchronously executes a read-only block that takes a database
/// connection, and returns its result.
///
/// Guarantee 1: the block argument is isolated. Eventual concurrent
/// database updates are not visible inside the block:
///
/// try reader.read { db in
/// // Those two values are guaranteed to be equal, even if the
/// // `wines` table is modified between the two requests:
/// let count1 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// try reader.read { db in
/// // Now this value may be different:
/// let count = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// Guarantee 2: Starting iOS 8.2, OSX 10.10, and with custom SQLite builds
/// and SQLCipher, attempts to write in the database throw a DatabaseError
/// whose resultCode is `SQLITE_READONLY`.
///
/// - 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.
func read<T>(_ block: (Database) throws -> T) throws -> T
/// Synchronously executes a read-only block that takes a database
/// connection, and returns its result.
///
/// The two guarantees of the safe `read` method are lifted:
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
///
/// try reader.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, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// Cursor iterations are isolated, though:
///
/// try reader.unsafeRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, "SELECT ...")
/// while let row = try rows.next() { ... }
/// }
///
/// The block argument 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
/// happen while establishing the read access to the database.
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T
/// Synchronously executes a block that takes a database connection, and
/// returns its result.
///
/// The two guarantees of the safe `read` method are lifted:
///
/// The block argument is not isolated: eventual concurrent database updates
/// are visible inside the block:
///
/// try reader.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, "SELECT COUNT(*) FROM wines")!
/// let count2 = try Int.fetchOne(db, "SELECT COUNT(*) FROM wines")!
/// }
///
/// Cursor iterations are isolated, though:
///
/// try reader.unsafeReentrantRead { db in
/// // No concurrent update can mess with this iteration:
/// let rows = try Row.fetchCursor(db, "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.
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T
// MARK: - Functions
/// Add or redefine an SQL function.
///
/// let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
/// guard let int = Int.fromDatabaseValue(dbValues[0]) else {
/// return nil
/// }
/// return int + 1
/// }
/// reader.add(function: fn)
/// try reader.read { db in
/// try Int.fetchOne(db, "SELECT succ(1)")! // 2
/// }
func add(function: DatabaseFunction)
/// Remove an SQL function.
func remove(function: DatabaseFunction)
// MARK: - Collations
/// Add or redefine a collation.
///
/// let collation = DatabaseCollation("localized_standard") { (string1, string2) in
/// return (string1 as NSString).localizedStandardCompare(string2)
/// }
/// reader.add(collation: collation)
/// try reader.execute("SELECT * FROM files ORDER BY name COLLATE localized_standard")
func add(collation: DatabaseCollation)
/// Remove a collation.
func remove(collation: DatabaseCollation)
}
extension DatabaseReader {
// MARK: - Backup
/// Copies the database contents into another database.
///
/// The `backup` method blocks the current thread until the destination
/// database contains the same contents as the source database.
///
/// When the source is a DatabasePool, concurrent writes can happen during
/// the backup. Those writes may, or may not, be reflected in the backup,
/// but they won't trigger any error.
public func backup(to writer: DatabaseWriter) throws {
try backup(to: writer, afterBackupInit: nil, afterBackupStep: nil)
}
func backup(to writer: DatabaseWriter, afterBackupInit: (() -> ())?, afterBackupStep: (() -> ())?) throws {
try read { dbFrom in
try writer.write { dbDest in
guard let backup = sqlite3_backup_init(dbDest.sqliteConnection, "main", dbFrom.sqliteConnection, "main") else {
throw DatabaseError(resultCode: dbDest.lastErrorCode, message: dbDest.lastErrorMessage)
}
guard Int(bitPattern: backup) != Int(SQLITE_ERROR) else {
throw DatabaseError(resultCode: .SQLITE_ERROR)
}
afterBackupInit?()
do {
backupLoop: while true {
switch sqlite3_backup_step(backup, -1) {
case SQLITE_DONE:
afterBackupStep?()
break backupLoop
case SQLITE_OK:
afterBackupStep?()
case let code:
throw DatabaseError(resultCode: code, message: dbDest.lastErrorMessage)
}
}
} catch {
sqlite3_backup_finish(backup)
throw error
}
switch sqlite3_backup_finish(backup) {
case SQLITE_OK:
break
case let code:
throw DatabaseError(resultCode: code, message: dbDest.lastErrorMessage)
}
dbDest.clearSchemaCache()
}
}
}
}
/// A type-erased DatabaseReader
///
/// Instances of AnyDatabaseReader forward their methods to an arbitrary
/// underlying database reader.
public final class AnyDatabaseReader : DatabaseReader {
private let base: DatabaseReader
/// Creates a database reader that wraps a base database reader.
public init(_ base: DatabaseReader) {
self.base = base
}
public func read<T>(_ block: (Database) throws -> T) throws -> T {
return try base.read(block)
}
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
return try base.unsafeRead(block)
}
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
return try base.unsafeReentrantRead(block)
}
public func add(function: DatabaseFunction) {
base.add(function: function)
}
public func remove(function: DatabaseFunction) {
base.remove(function: function)
}
public func add(collation: DatabaseCollation) {
base.add(collation: collation)
}
public func remove(collation: DatabaseCollation) {
base.remove(collation: collation)
}
}
+74 -39
View File
@@ -1,74 +1,109 @@
/// An thread-unsafe database schema cache
class DatabaseSchemaCache: DatabaseSchemaCacheType {
private var primaryKeys: [String: PrimaryKey] = [:]
private var updateStatements: [String: UpdateStatement] = [:]
private var selectStatements: [String: SelectStatement] = [:]
/// The protocol for schema cache.
///
/// This protocol must not contain values that are valid for a single connection
/// only, because several connections can share the same schema cache.
///
/// Statements can't be cached here, for example.
protocol DatabaseSchemaCache {
mutating func clear()
func primaryKey(_ table: String) -> PrimaryKeyInfo?
mutating func set(primaryKey: PrimaryKeyInfo, forTable table: String)
func columns(in table: String) -> [ColumnInfo]?
mutating func set(columns: [ColumnInfo], forTable table: String)
func indexes(on table: String) -> [IndexInfo]?
mutating func set(indexes: [IndexInfo], forTable table: String)
func foreignKeys(on table: String) -> [ForeignKeyInfo]?
mutating func set(foreignKeys: [ForeignKeyInfo], forTable table: String)
}
/// A thread-unsafe database schema cache
final class SimpleDatabaseSchemaCache: DatabaseSchemaCache {
private var primaryKeys: [String: PrimaryKeyInfo] = [:]
private var columns: [String: [ColumnInfo]] = [:]
private var indexes: [String: [IndexInfo]] = [:]
private var foreignKeys: [String: [ForeignKeyInfo]] = [:]
func clear() {
primaryKeys = [:]
// We do clear updateStatementCache and selectStatementCache 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.
updateStatements = [:]
selectStatements = [:]
columns = [:]
indexes = [:]
foreignKeys = [:]
}
func primaryKey(tableName tableName: String) -> PrimaryKey? {
return primaryKeys[tableName]
func primaryKey(_ table: String) -> PrimaryKeyInfo? {
return primaryKeys[table]
}
func setPrimaryKey(primaryKey: PrimaryKey, forTableName tableName: String) {
primaryKeys[tableName] = primaryKey
func set(primaryKey: PrimaryKeyInfo, forTable table: String) {
primaryKeys[table] = primaryKey
}
func updateStatement(sql sql: String) -> UpdateStatement? {
return updateStatements[sql]
func columns(in table: String) -> [ColumnInfo]? {
return columns[table]
}
func setUpdateStatement(statement: UpdateStatement, forSQL sql: String) {
updateStatements[sql] = statement
func set(columns: [ColumnInfo], forTable table: String) {
self.columns[table] = columns
}
func selectStatement(sql sql: String) -> SelectStatement? {
return selectStatements[sql]
func indexes(on table: String) -> [IndexInfo]? {
return indexes[table]
}
func setSelectStatement(statement: SelectStatement, forSQL sql: String) {
selectStatements[sql] = statement
func set(indexes: [IndexInfo], forTable table: String) {
self.indexes[table] = indexes
}
func foreignKeys(on table: String) -> [ForeignKeyInfo]? {
return foreignKeys[table]
}
func set(foreignKeys: [ForeignKeyInfo], forTable table: String) {
self.foreignKeys[table] = foreignKeys
}
}
/// A thread-safe database schema cache
struct SharedDatabaseSchemaCache: DatabaseSchemaCacheType {
private let cache = ReadWriteBox(DatabaseSchemaCache())
final class SharedDatabaseSchemaCache: DatabaseSchemaCache {
private let cache = ReadWriteBox(SimpleDatabaseSchemaCache())
mutating func clear() {
func clear() {
cache.write { $0.clear() }
}
func primaryKey(tableName tableName: String) -> PrimaryKey? {
return cache.read { $0.primaryKey(tableName: tableName) }
func primaryKey(_ table: String) -> PrimaryKeyInfo? {
return cache.read { $0.primaryKey(table) }
}
mutating func setPrimaryKey(primaryKey: PrimaryKey, forTableName tableName: String) {
cache.write { $0.setPrimaryKey(primaryKey, forTableName: tableName) }
func set(primaryKey: PrimaryKeyInfo, forTable table: String) {
cache.write { $0.set(primaryKey: primaryKey, forTable: table) }
}
func updateStatement(sql sql: String) -> UpdateStatement? {
return cache.read { $0.updateStatement(sql: sql) }
func columns(in table: String) -> [ColumnInfo]? {
return cache.read { $0.columns(in: table) }
}
mutating func setUpdateStatement(statement: UpdateStatement, forSQL sql: String) {
cache.write { $0.setUpdateStatement(statement, forSQL: sql) }
func set(columns: [ColumnInfo], forTable table: String) {
cache.write { $0.set(columns: columns, forTable: table) }
}
func selectStatement(sql sql: String) -> SelectStatement? {
return cache.read { $0.selectStatement(sql: sql) }
func indexes(on table: String) -> [IndexInfo]? {
return cache.read { $0.indexes(on: table) }
}
mutating func setSelectStatement(statement: SelectStatement, forSQL sql: String) {
cache.write { $0.setSelectStatement(statement, forSQL: sql) }
func set(indexes: [IndexInfo], forTable table: String) {
cache.write { $0.set(indexes: indexes, forTable: table) }
}
func foreignKeys(on table: String) -> [ForeignKeyInfo]? {
return cache.read { $0.foreignKeys(on: table) }
}
func set(foreignKeys: [ForeignKeyInfo], forTable table: String) {
cache.write { $0.set(foreignKeys: foreignKeys, forTable: table) }
}
}
+265 -147
View File
@@ -1,4 +1,9 @@
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
// MARK: - DatabaseValue
@@ -8,28 +13,70 @@ import Foundation
public struct DatabaseValue {
/// An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).
public enum Storage {
public enum Storage : Equatable {
/// The NULL storage class.
case Null
case null
/// The INTEGER storage class, wrapping an Int64.
case Int64(Swift.Int64)
case int64(Int64)
/// The REAL storage class, wrapping a Double.
case Double(Swift.Double)
case double(Double)
/// The TEXT storage class, wrapping a String.
case String(Swift.String)
case string(String)
/// The BLOB storage class, wrapping NSData.
case Blob(NSData)
/// The BLOB storage class, wrapping Data.
case blob(Data)
/// Returns Int64, Double, String, Data or nil.
public var value: DatabaseValueConvertible? {
switch self {
case .null:
return nil
case .int64(let int64):
return int64
case .double(let double):
return double
case .string(let string):
return string
case .blob(let data):
return data
}
}
/// Return true if the storages are identical.
///
/// Unlike DatabaseValue equality that considers the integer 1 to be
/// equal to the 1.0 double (as SQLite does), int64 and double storages
/// are never equal.
public static func == (_ lhs: Storage, _ rhs: Storage) -> Bool {
switch (lhs, rhs) {
case (.null, .null): return true
case (.int64(let lhs), .int64(let rhs)): return lhs == rhs
case (.double(let lhs), .double(let rhs)): return lhs == rhs
case (.string(let lhs), .string(let rhs)): return lhs == rhs
case (.blob(let lhs), .blob(let rhs)): return lhs == rhs
default: return false
}
}
}
/// The SQLite storage
public let storage: Storage
/// The NULL DatabaseValue.
public static let Null = DatabaseValue(storage: .Null)
public static let null = DatabaseValue(storage: .null)
/// Creates a DatabaseValue from Any.
///
/// The result is nil unless object adopts DatabaseValueConvertible.
public init?(value: Any) {
guard let convertible = value as? DatabaseValueConvertible else {
return nil
}
self = convertible.databaseValue
}
// MARK: - Extracting Value
@@ -37,77 +84,17 @@ public struct DatabaseValue {
/// Returns true if databaseValue is NULL.
public var isNull: Bool {
switch storage {
case .Null:
case .null:
return true
default:
return false
}
}
/// Returns Int64, Double, String, NSData or nil.
public func value() -> DatabaseValueConvertible? {
switch storage {
case .Null:
return nil
case .Int64(let int64):
return int64
case .Double(let double):
return double
case .String(let string):
return string
case .Blob(let data):
return data
}
}
/// Returns the value, converted to the requested type.
///
/// The result is nil if the SQLite value is NULL, or if the SQLite value
/// can not be converted to `Value`.
///
/// Successful conversions include:
///
/// - Integer and real SQLite values to Swift Int, Int32, Int64, Double and
/// Bool (zero is the only false boolean).
/// - Text SQLite values to Swift String.
/// - Blob SQLite values to NSData.
///
/// Types that adopt DatabaseValueConvertible can provide more conversions.
///
/// - returns: An optional *Value*.
public func value<Value: DatabaseValueConvertible>() -> Value? {
return Value.fromDatabaseValue(self)
}
/// Returns the value, converted to the requested type.
///
/// This method crashes if the SQLite value is NULL, or if the SQLite value
/// can not be converted to `Value`.
///
/// Successful conversions include:
///
/// - Integer and real SQLite values to Swift Int, Int32, Int64, Double and
/// Bool (zero is the only false boolean).
/// - Text SQLite values to Swift String.
/// - Blob SQLite values to NSData.
///
/// Types that adopt DatabaseValueConvertible can provide more conversions.
///
/// - returns: A *Value*.
public func value<Value: DatabaseValueConvertible>() -> Value {
guard let value = Value.fromDatabaseValue(self) as Value? else {
fatalError("could not convert \(self) to \(Value.self).")
}
return value
}
// MARK: - Not Public
init(storage: Storage) {
// This initializer is not public because Storage is not a safe type:
// one can create a Storage of zero-length NSData, which is invalid
// because SQLite can't store zero-length blobs.
self.storage = storage
}
@@ -115,22 +102,49 @@ public struct DatabaseValue {
init(sqliteValue: SQLiteValue) {
switch sqlite3_value_type(sqliteValue) {
case SQLITE_NULL:
storage = .Null
storage = .null
case SQLITE_INTEGER:
storage = .Int64(sqlite3_value_int64(sqliteValue))
storage = .int64(sqlite3_value_int64(sqliteValue))
case SQLITE_FLOAT:
storage = .Double(sqlite3_value_double(sqliteValue))
storage = .double(sqlite3_value_double(sqliteValue))
case SQLITE_TEXT:
let cString = UnsafePointer<Int8>(sqlite3_value_text(sqliteValue))
storage = .String(Swift.String.fromCString(cString)!)
storage = .string(String(cString: sqlite3_value_text(sqliteValue)!))
case SQLITE_BLOB:
let bytes = sqlite3_value_blob(sqliteValue)
let length = sqlite3_value_bytes(sqliteValue)
storage = .Blob(NSData(bytes: bytes, length: Int(length))) // copy bytes
if let bytes = sqlite3_value_blob(sqliteValue) {
let count = Int(sqlite3_value_bytes(sqliteValue))
storage = .blob(Data(bytes: bytes, count: count)) // copy bytes
} else {
storage = .blob(Data())
}
case let type:
// Assume a GRDB bug: there is no point throwing any error.
fatalError("Unexpected SQLite value type: \(type)")
}
}
/// Returns a DatabaseValue initialized from a raw SQLite statement pointer.
init(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, Int32(index)) {
case SQLITE_NULL:
storage = .null
case SQLITE_INTEGER:
storage = .int64(sqlite3_column_int64(sqliteStatement, Int32(index)))
case SQLITE_FLOAT:
storage = .double(sqlite3_column_double(sqliteStatement, Int32(index)))
case SQLITE_TEXT:
storage = .string(String(cString: sqlite3_column_text(sqliteStatement, Int32(index))))
case SQLITE_BLOB:
if let bytes = sqlite3_column_blob(sqliteStatement, Int32(index)) {
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
storage = .blob(Data(bytes: bytes, count: count)) // copy bytes
} else {
storage = .blob(Data())
}
case let type:
// Assume a GRDB bug: there is no point throwing any error.
fatalError("Unexpected SQLite column type: \(type)")
}
}
}
@@ -142,55 +156,138 @@ extension DatabaseValue : Hashable {
/// The hash value
public var hashValue: Int {
switch storage {
case .Null:
case .null:
return 0
case .Int64(let int64):
case .int64(let int64):
// 1 == 1.0, hence 1 and 1.0 must have the same hash:
return Double(int64).hashValue
case .Double(let double):
case .double(let double):
return double.hashValue
case .String(let string):
case .string(let string):
return string.hashValue
case .Blob(let data):
case .blob(let data):
return data.hashValue
}
}
/// Returns whether two DatabaseValues are equal.
///
/// 1.databaseValue == "foo".databaseValue // false
/// 1.databaseValue == 1.databaseValue // true
///
/// When comparing integers and doubles, the result is true if and only
/// values are equal, and if converting one type to the other does
/// not lose information:
///
/// 1.databaseValue == 1.0.databaseValue // true
///
/// For a comparison that distinguishes integer and doubles, compare
/// storages instead:
///
/// 1.databaseValue.storage == 1.0.databaseValue.storage // false
public static func == (lhs: DatabaseValue, rhs: DatabaseValue) -> Bool {
switch (lhs.storage, rhs.storage) {
case (.null, .null):
return true
case (.int64(let lhs), .int64(let rhs)):
return lhs == rhs
case (.double(let lhs), .double(let rhs)):
return lhs == rhs
case (.int64(let lhs), .double(let rhs)):
return Int64(exactly: rhs) == lhs
case (.double(let lhs), .int64(let rhs)):
return rhs == Int64(exactly: lhs)
case (.string(let lhs), .string(let rhs)):
return lhs == rhs
case (.blob(let lhs), .blob(let rhs)):
return lhs == rhs
default:
return false
}
}
}
/// DatabaseValue adopts Equatable.
public func ==(lhs: DatabaseValue, rhs: DatabaseValue) -> Bool {
switch (lhs.storage, rhs.storage) {
case (.Null, .Null):
return true
case (.Int64(let lhs), .Int64(let rhs)):
return lhs == rhs
case (.Double(let lhs), .Double(let rhs)):
return lhs == rhs
case (.Int64(let lhs), .Double(let rhs)):
return int64EqualDouble(lhs, rhs)
case (.Double(let lhs), .Int64(let rhs)):
return int64EqualDouble(rhs, lhs)
case (.String(let lhs), .String(let rhs)):
return lhs == rhs
case (.Blob(let lhs), .Blob(let rhs)):
return lhs == rhs
default:
return false
// MARK: - Lossless conversions
extension DatabaseValue {
/// Converts the database value to the type T.
///
/// let dbValue = "foo".databaseValue
/// let string = dbValue.losslessConvert() as String // "foo"
///
/// Conversion is successful if and only if T.fromDatabaseValue returns a
/// non-nil value.
///
/// This method crashes with a fatal error when conversion fails.
///
/// let dbValue = "foo".databaseValue
/// let int = dbValue.losslessConvert() as Int // fatalError
///
/// - parameters:
/// - sql: Optional SQL statement that enhances the eventual
/// conversion error
/// - arguments: Optional statement arguments that enhances the eventual
/// conversion error
public func losslessConvert<T>(sql: String? = nil, arguments: StatementArguments? = nil) -> T where T : DatabaseValueConvertible {
if let value = T.fromDatabaseValue(self) {
return value
}
// Failed conversion: this is data loss, a programmer error.
var error = "could not convert database value \(self) to \(T.self)"
if let sql = sql {
error += " with statement `\(sql)`"
}
if let arguments = arguments, !arguments.isEmpty {
error += " arguments \(arguments)"
}
fatalError(error)
}
/// Converts the database value to the type Optional<T>.
///
/// let dbValue = "foo".databaseValue
/// let string = dbValue.losslessConvert() as String? // "foo"
/// let null = DatabaseValue.null.losslessConvert() as String? // nil
///
/// Conversion is successful if and only if T.fromDatabaseValue returns a
/// non-nil value.
///
/// This method crashes with a fatal error when conversion fails.
///
/// let dbValue = "foo".databaseValue
/// let int = dbValue.losslessConvert() as Int? // fatalError
///
/// - parameters:
/// - sql: Optional SQL statement that enhances the eventual
/// conversion error
/// - arguments: Optional statement arguments that enhances the eventual
/// conversion error
public func losslessConvert<T>(sql: String? = nil, arguments: StatementArguments? = nil) -> T? where T : DatabaseValueConvertible {
// Use fromDatabaseValue first: this allows DatabaseValue to convert NULL to .null.
if let value = T.fromDatabaseValue(self) {
return value
}
if isNull {
// Failed conversion from null: ok
return nil
} else {
// Failed conversion from a non-null database value: this is data
// loss, a programmer error.
var error = "could not convert database value \(self) to \(T.self)"
if let sql = sql {
error += " with statement `\(sql)`"
}
if let arguments = arguments, !arguments.isEmpty {
error += " arguments \(arguments)"
}
fatalError(error)
}
}
}
/// Returns true if i and d hold exactly the same value, and if converting one
/// type into the other does not lose any information.
private func int64EqualDouble(i: Int64, _ d: Double) -> Bool {
// See http://stackoverflow.com/questions/33719132/how-to-test-for-lossless-double-integer-conversion/33784296#33784296
return (d >= Double(Int64.min))
&& (d < Double(Int64.max))
&& (round(d) == d)
&& (i == Int64(d))
}
// MARK: - DatabaseValueConvertible
// MARK: - DatabaseValueConvertible & SQLExpressible & SQLExpression
/// DatabaseValue adopts DatabaseValueConvertible.
extension DatabaseValue : DatabaseValueConvertible {
@@ -199,44 +296,65 @@ extension DatabaseValue : DatabaseValueConvertible {
return self
}
/// Returns *databaseValue*, or nil for NULL input.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> DatabaseValue? {
// Follow protocol semantics: DatabaseValueConvertible types turn NULL
// into nil:
//
// DatabaseValue.fetchOne(db, "SELECT NULL") // nil
return databaseValue.isNull ? nil : databaseValue
/// Returns the database value
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseValue? {
return dbValue
}
}
// MARK: - StatementColumnConvertible
extension DatabaseValue : StatementColumnConvertible {
extension DatabaseValue : SQLExpressible {
/// Returns a DatabaseValue initialized from a raw SQLite statement pointer.
public init(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, Int32(index)) {
case SQLITE_NULL:
storage = .Null
case SQLITE_INTEGER:
storage = .Int64(sqlite3_column_int64(sqliteStatement, Int32(index)))
case SQLITE_FLOAT:
storage = .Double(sqlite3_column_double(sqliteStatement, Int32(index)))
case SQLITE_TEXT:
let cString = UnsafePointer<Int8>(sqlite3_column_text(sqliteStatement, Int32(index)))
storage = .String(String.fromCString(cString)!)
case SQLITE_BLOB:
let bytes = sqlite3_column_blob(sqliteStatement, Int32(index))
let length = sqlite3_column_bytes(sqliteStatement, Int32(index))
storage = .Blob(NSData(bytes: bytes, length: Int(length))) // copy bytes
case let type:
fatalError("Unexpected SQLite column type: \(type)")
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public var sqlExpression: SQLExpression {
return self
}
}
/// DatabaseValue adopts SQLExpression.
extension DatabaseValue : SQLExpression {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func expressionSQL(_ arguments: inout StatementArguments?) -> String {
// fast path for NULL
if isNull {
return "NULL"
}
if arguments != nil {
arguments!.values.append(self)
return "?"
} else {
// Correctness above all: use SQLite to quote the value.
// Assume that the Quote function always succeeds
return DatabaseQueue().inDatabase { try! String.fetchOne($0, "SELECT QUOTE(?)", arguments: [self])! }
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public var negated: SQLExpression {
switch storage {
case .null:
// SELECT NOT NULL -- NULL
return DatabaseValue.null
case .int64(let int64):
return (int64 == 0).sqlExpression
case .double(let double):
return (double == 0.0).sqlExpression
case .string:
// We can't assume all strings are true, and return false:
//
// SELECT NOT '1' -- 0 (because '1' is turned into the integer 1, which is negated into 0)
// SELECT NOT '0' -- 1 (because '0' is turned into the integer 0, which is negated into 1)
return SQLExpressionNot(self)
case .blob:
// We can't assume all blobs are true, and return false:
//
// SELECT NOT X'31' -- 0 (because X'31' is turned into the string '1', then into integer 1, which is negated into 0)
// SELECT NOT X'30' -- 1 (because X'30' is turned into the string '0', then into integer 0, which is negated into 1)
return SQLExpressionNot(self)
}
}
}
// MARK: - CustomStringConvertible
/// DatabaseValue adopts CustomStringConvertible.
@@ -244,15 +362,15 @@ extension DatabaseValue : CustomStringConvertible {
/// A textual representation of `self`.
public var description: String {
switch storage {
case .Null:
case .null:
return "NULL"
case .Int64(let int64):
case .int64(let int64):
return String(int64)
case .Double(let double):
case .double(let double):
return String(double)
case .String(let string):
case .string(let string):
return String(reflecting: string)
case .Blob(let data):
case .blob(let data):
return data.description
}
}
+333 -149
View File
@@ -1,87 +1,176 @@
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
// MARK: - DatabaseValueConvertible
/// Types that adopt DatabaseValueConvertible can be initialized from
/// database values.
///
/// The protocol comes with built-in methods that allow to fetch sequences,
/// The protocol comes with built-in methods that allow to fetch cursors,
/// arrays, or single values:
///
/// String.fetch(db, "SELECT name FROM ...", arguments:...) // DatabaseSequence<String?>
/// String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String?]
/// String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String?
/// try String.fetchCursor(db, "SELECT name FROM ...", arguments:...) // Cursor of String
/// try String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String]
/// try String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String?
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// String.fetch(statement, arguments:...) // DatabaseSequence<String?>
/// String.fetchAll(statement, arguments:...) // [String?]
/// String.fetchOne(statement, arguments:...) // String?
/// let statement = try db.makeSelectStatement("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 : _SQLExpressionType {
public protocol DatabaseValueConvertible : SQLExpressible {
/// Returns a value that can be stored in the database.
var databaseValue: DatabaseValue { get }
/// Returns a value initialized from *databaseValue*, if possible.
static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self?
/// Returns a value initialized from *dbValue*, if possible.
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
}
// SQLExpressible adoption
extension DatabaseValueConvertible {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public var sqlExpression: SQLExpression {
return databaseValue
}
}
/// A cursor of database values extracted from a single column.
/// For example:
///
/// try dbQueue.inDatabase { db in
/// let urls: DatabaseValueCursor<URL> = try URL.fetchCursor(db, "SELECT url FROM links")
/// while let url = urls.next() { // URL
/// print(url)
/// }
/// }
public final class DatabaseValueCursor<Value: DatabaseValueConvertible> : Cursor {
private let statement: SelectStatement
private let sqliteStatement: SQLiteStatement
private let columnIndex: Int32
private var done = false
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
self.statement = statement
// We'll read from leftmost column at index 0, unless adapter mangles columns
self.columnIndex = try Int32(adapter?.baseColumnIndex(atIndex: 0, layout: statement) ?? 0)
self.sqliteStatement = statement.sqliteStatement
statement.cursorReset(arguments: arguments)
}
public func next() throws -> Value? {
if done { return nil }
switch sqlite3_step(sqliteStatement) {
case SQLITE_DONE:
done = true
return nil
case SQLITE_ROW:
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: columnIndex)
return dbValue.losslessConvert() as Value
case let code:
statement.database.selectStatementDidFail(statement)
throw DatabaseError(resultCode: code, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
}
}
}
/// A cursor of optional database values extracted from a single column.
/// For example:
///
/// try dbQueue.inDatabase { db in
/// let urls: NullableDatabaseValueCursor<URL> = try Optional<URL>.fetchCursor(db, "SELECT url FROM links")
/// while let url = urls.next() { // URL?
/// print(url)
/// }
/// }
public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible> : Cursor {
private let statement: SelectStatement
private let sqliteStatement: SQLiteStatement
private let columnIndex: Int32
private var done = false
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
self.statement = statement
// We'll read from leftmost column at index 0, unless adapter mangles columns
self.columnIndex = try Int32(adapter?.baseColumnIndex(atIndex: 0, layout: statement) ?? 0)
self.sqliteStatement = statement.sqliteStatement
statement.cursorReset(arguments: arguments)
}
public func next() throws -> Value?? {
if done { return nil }
switch sqlite3_step(sqliteStatement) {
case SQLITE_DONE:
done = true
return nil
case SQLITE_ROW:
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: columnIndex)
return dbValue.losslessConvert() as Value?
case let code:
statement.database.selectStatementDidFail(statement)
throw DatabaseError(resultCode: code, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
}
}
}
/// DatabaseValueConvertible comes with built-in methods that allow to fetch
/// sequences, arrays, or single values:
/// cursors, arrays, or single values:
///
/// String.fetch(db, "SELECT name FROM ...", arguments:...) // DatabaseSequence<String>
/// String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String]
/// String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String
/// try String.fetchCursor(db, "SELECT name FROM ...", arguments:...) // Cursor of String
/// try String.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String]
/// try String.fetchOne(db, "SELECT name FROM ...", arguments:...) // String?
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// String.fetch(statement, arguments:...) // DatabaseSequence<String>
/// String.fetchAll(statement, arguments:...) // [String]
/// String.fetchOne(statement, arguments:...) // String
/// let statement = try db.makeSelectStatement("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 extension DatabaseValueConvertible {
extension DatabaseValueConvertible {
// MARK: - Fetching From SelectStatement
// MARK: Fetching From SelectStatement
/// Returns a sequence of values fetched from a prepared statement.
/// Returns a cursor over values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = String.fetch(statement) // DatabaseSequence<String>
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try String.fetchCursor(statement) // Cursor of String
/// while let name = try names.next() { // String
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = String.fetch(statement)
/// Array(names) // Arthur, Barbara
/// db.execute("DELETE ...")
/// Array(names) // Arthur
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - returns: A sequence.
@warn_unused_result
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
let sqliteStatement = statement.sqliteStatement
return statement.fetchSequence(arguments: arguments) {
DatabaseValue(sqliteStatement: sqliteStatement, index: 0).value()
}
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseValueCursor<Self> {
return try DatabaseValueCursor(statement: statement, arguments: arguments, adapter: adapter)
}
/// Returns an array of values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = String.fetchAll(statement) // [String]
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try String.fetchAll(statement) // [String]
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array.
@warn_unused_result
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Self] {
return Array(fetch(statement, arguments: arguments))
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from a prepared statement.
@@ -89,65 +178,120 @@ public 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 = db.selectStatement("SELECT name FROM ...")
/// let name = String.fetchOne(statement) // String?
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let name = try String.fetchOne(statement) // String?
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An optional value.
@warn_unused_result
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Self? {
let sequence = statement.fetchSequence(arguments: arguments) {
fromDatabaseValue(DatabaseValue(sqliteStatement: statement.sqliteStatement, index: 0))
}
if let value = sequence.generate().next() {
return value
}
return nil
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
// fetchOne returns nil if there is no row, or if there is a row with a null value
let cursor = try NullableDatabaseValueCursor<Self>(statement: statement, arguments: arguments, adapter: adapter)
return try cursor.next() ?? nil
}
}
extension DatabaseValueConvertible {
// MARK: Fetching From Request
// MARK: - Fetching From SQL
/// Returns a sequence of values fetched from an SQL query.
/// Returns a cursor over values fetched from a fetch request.
///
/// let names = String.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String>
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try String.fetchCursor(db, request) // Cursor of String
/// for let name = try names.next() { // String
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = String.fetch(db, "SELECT name FROM ...")
/// Array(names) // Arthur, Barbara
/// execute("DELETE ...")
/// Array(names) // Arthur
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - request: A fetch request.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ request: Request) throws -> DatabaseValueCursor<Self> {
let (statement, adapter) = try request.prepare(db)
return try fetchCursor(statement, adapter: adapter)
}
/// Returns an array of values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try String.fetchAll(db, request) // [String]
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Self] {
let (statement, adapter) = try request.prepare(db)
return try fetchAll(statement, adapter: adapter)
}
/// Returns a single value fetched from a fetch request.
///
/// The result is nil if the query returns no row, or if no value can be
/// extracted from the first row.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let name = try String.fetchOne(db, request) // String?
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ db: Database, _ request: Request) throws -> Self? {
let (statement, adapter) = try request.prepare(db)
return try fetchOne(statement, adapter: adapter)
}
}
extension DatabaseValueConvertible {
// MARK: Fetching From SQL
/// Returns a cursor over values fetched from an SQL query.
///
/// let names = try String.fetchCursor(db, "SELECT name FROM ...") // Cursor of String
/// while let name = try name.next() { // String
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - returns: A sequence.
@warn_unused_result
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
return fetch(try! db.selectStatement(sql), arguments: arguments)
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseValueCursor<Self> {
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
///
/// let names = String.fetchAll(db, "SELECT name FROM ...") // [String]
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String]
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array.
@warn_unused_result
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Self] {
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
@@ -155,116 +299,156 @@ public extension DatabaseValueConvertible {
/// The result is nil if the query returns no row, or if no value can be
/// extracted from the first row.
///
/// let name = String.fetchOne(db, "SELECT name FROM ...") // String?
/// let name = try String.fetchOne(db, "SELECT name FROM ...") // String?
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An optional value.
@warn_unused_result
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Self? {
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
return try fetchOne(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
}
/// Swift's Optional comes with built-in methods that allow to fetch sequences
/// Swift's Optional comes with built-in methods that allow to fetch cursors
/// and arrays of optional DatabaseValueConvertible:
///
/// Optional<String>.fetch(db, "SELECT name FROM ...", arguments:...) // DatabaseSequence<String?>
/// Optional<String>.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String?]
/// try Optional<String>.fetchCursor(db, "SELECT name FROM ...", arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String?]
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// Optional<String>.fetch(statement, arguments:...) // DatabaseSequence<String?>
/// Optional<String>.fetchAll(statement, arguments:...) // [String?]
/// let statement = try db.makeSelectStatement("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.
public extension Optional where Wrapped: DatabaseValueConvertible {
extension Optional where Wrapped: DatabaseValueConvertible {
// MARK: Fetching From SelectStatement
// MARK: - Fetching From SelectStatement
/// Returns a sequence of optional values fetched from a prepared statement.
/// Returns a cursor over optional values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = Optional<String>.fetch(statement) // DatabaseSequence<String?>
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = Optional<String>.fetch(statement)
/// Array(names) // Arthur, Barbara
/// db.execute("DELETE ...")
/// Array(names) // Arthur
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - returns: A sequence of optional values.
@warn_unused_result
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Wrapped?> {
let sqliteStatement = statement.sqliteStatement
return statement.fetchSequence(arguments: arguments) {
Wrapped.fromDatabaseValue(DatabaseValue(sqliteStatement: sqliteStatement, index: 0))
}
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> NullableDatabaseValueCursor<Wrapped> {
return try NullableDatabaseValueCursor(statement: statement, arguments: arguments, adapter: adapter)
}
/// Returns an array of optional values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = Optional<String>.fetchAll(statement) // [String?]
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try Optional<String>.fetchAll(statement) // [String?]
///
/// - parameter statement: The statement to run.
/// - parameter arguments: Optional statement arguments.
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of optional values.
@warn_unused_result
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Wrapped?] {
return Array(fetch(statement, arguments: arguments))
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
}
}
extension Optional where Wrapped: DatabaseValueConvertible {
// MARK: Fetching From Request
/// Returns a cursor over optional values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A database connection.
/// - requet: A fetch request.
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ request: Request) throws -> NullableDatabaseValueCursor<Wrapped> {
let (statement, adapter) = try request.prepare(db)
return try fetchCursor(statement, adapter: adapter)
}
/// Returns an array of optional values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try Optional<String>.fetchAll(db, request) // [String?]
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Wrapped?] {
let (statement, adapter) = try request.prepare(db)
return try fetchAll(statement, adapter: adapter)
}
}
extension Optional where Wrapped: DatabaseValueConvertible {
// MARK: - Fetching From SQL
// MARK: Fetching From SQL
/// Returns a sequence of optional values fetched from an SQL query.
/// Returns a cursor over optional values fetched from an SQL query.
///
/// let names = Optional<String>.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String?>
/// let names = try Optional<String>.fetchCursor(db, "SELECT name FROM ...") // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = Optional<String>.fetch(db, "SELECT name FROM ...")
/// Array(names) // Arthur, Barbara
/// db.execute("DELETE ...")
/// Array(names) // Arthur
/// The cursor must be iterated in a protected dispath queue.
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
///
/// - parameter db: A Database.
/// - parameter sql: An SQL query.
/// - parameter arguments: Optional statement arguments.
/// - returns: A sequence of optional values.
@warn_unused_result
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Wrapped?> {
return fetch(try! db.selectStatement(sql), arguments: arguments)
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> NullableDatabaseValueCursor<Wrapped> {
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
///
/// let names = String.fetchAll(db, "SELECT name FROM ...") // [String?]
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String?]
///
/// - parameter db: A Database.
/// - parameter sql: An SQL query.
/// - parameter arguments: Optional statement arguments.
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - parameter arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of optional values.
@warn_unused_result
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Wrapped?] {
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
}
+178
View File
@@ -0,0 +1,178 @@
/// The protocol for all types that can update a database.
///
/// It is adopted by DatabaseQueue and DatabasePool.
///
/// The protocol comes with isolation guarantees that describe the behavior of
/// adopting types in a multithreaded application.
///
/// Types that adopt the protocol can in practice provide stronger guarantees.
/// For example, DatabaseQueue provides a stronger isolation level
/// than DatabasePool.
///
/// **Warning**: Isolation guarantees stand as long as there is no external
/// connection to the database. Should you have to cope with external
/// connections, protect yourself with transactions, and be ready to setup a
/// [busy handler](https://www.sqlite.org/c3ref/busy_handler.html).
public protocol DatabaseWriter : DatabaseReader {
// MARK: - Writing in Database
/// Synchronously executes a block that takes a database connection, and
/// returns its result.
///
/// Eventual concurrent database updates are postponed until the block
/// has executed.
///
/// This method is *not* reentrant.
func write<T>(_ block: (Database) throws -> T) rethrows -> T
/// Synchronously executes a block that takes a database connection, and
/// returns its result.
///
/// Eventual concurrent database updates are postponed until the block
/// has executed.
///
/// This method is reentrant. It should be avoided because it fosters
/// dangerous concurrency practices.
func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T
// MARK: - Reading from Database
/// Synchronously or asynchronously executes a read-only block that takes a
/// database connection.
///
/// This method must be called from a writing dispatch queue.
///
/// The *block* argument is guaranteed to see the database in the state it
/// has at the moment this method is called (see below). Eventual concurrent
/// database updates are *not visible* inside the block.
///
/// What is the "current state" of the database?
///
/// - When this method is called outside of any transaction, the current
/// state is the last committed state.
///
/// try writer.write { db in
/// try db.execute("DELETE FROM players")
/// try writer.readFromCurrentState { db in
/// // Guaranteed to be zero
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM players")!
/// }
/// try db.execute("INSERT INTO players ...")
/// }
///
/// - When this method is called inside an uncommitted transation, the
/// current state depends on the caller:
///
/// DatabasePool.readFromCurrentState runs *block* asynchronously in a
/// concurrent reader dispatch queue, and release the writing dispatch
/// queue early, before the block has finished. In the example below,
/// the insertion runs concurrently with the select, and the select sees
/// the database in its last committed state.
///
/// try dbPool.write { db in
/// try db.execute("DELETE FROM players")
/// db.inTransaction {
/// try db.execute("INSERT INTO players ...")
/// try dbPool.readFromCurrentState { db in
/// // Zero
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM players")!
/// }
/// return .commit
/// }
/// }
///
/// DatabaseQueue.readFromCurrentState simply runs *block* synchronously,
/// and returns when the block has completed. In the example below, the
/// select sees the uncommitted state of the database, and the insertion
/// is run after the select.
///
/// try dbQueue.write { db in
/// try db.execute("DELETE FROM players")
/// db.inTransaction {
/// try db.execute("INSERT INTO players ...")
/// try dbQueue.readFromCurrentState { db in
/// // One
/// try Int.fetchOne(db, "SELECT COUNT(*) FROM players")!
/// }
/// return .commit
/// }
/// }
///
/// This method is *not* reentrant.
func readFromCurrentState(_ block: @escaping (Database) -> Void) throws
}
extension DatabaseWriter {
// MARK: - Transaction Observers
/// Add a transaction observer, so that it gets notified of
/// database changes.
///
/// - parameter transactionObserver: A transaction observer.
/// - parameter extent: The duration of the observation. The default is
/// the observer lifetime (observation lasts until observer
/// is deallocated).
public func add(transactionObserver: TransactionObserver, extent: Database.TransactionObservationExtent = .observerLifetime) {
write { $0.add(transactionObserver: transactionObserver, extent: extent) }
}
/// Remove a transaction observer.
public func remove(transactionObserver: TransactionObserver) {
write { $0.remove(transactionObserver: transactionObserver) }
}
}
/// A type-erased DatabaseWriter
///
/// Instances of AnyDatabaseWriter forward their methods to an arbitrary
/// underlying database writer.
public final class AnyDatabaseWriter : DatabaseWriter {
private let base: DatabaseWriter
/// Creates a database writer that wraps a base database writer.
public init(_ base: DatabaseWriter) {
self.base = base
}
public func read<T>(_ block: (Database) throws -> T) throws -> T {
return try base.read(block)
}
public func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T {
return try base.unsafeRead(block)
}
public func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T {
return try base.unsafeReentrantRead(block)
}
public func add(function: DatabaseFunction) {
base.add(function: function)
}
public func remove(function: DatabaseFunction) {
base.remove(function: function)
}
public func add(collation: DatabaseCollation) {
base.add(collation: collation)
}
public func remove(collation: DatabaseCollation) {
base.remove(collation: collation)
}
public func write<T>(_ block: (Database) throws -> T) rethrows -> T {
return try base.write(block)
}
public func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T {
return try base.unsafeReentrantWrite(block)
}
public func readFromCurrentState(_ block: @escaping (Database) -> Void) throws {
try base.readFromCurrentState(block)
}
}
+556
View File
@@ -0,0 +1,556 @@
/// The protocol for all types that define a way to fetch database rows.
///
/// Requests can feed the fetching methods of any fetchable type (Row,
/// value, record):
///
/// let request: Request = ...
/// try Row.fetchCursor(db, request) // RowCursor
/// try String.fetchAll(db, request) // [String]
/// try Player.fetchOne(db, request) // Player?
public protocol Request {
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?)
/// The number of rows fetched by the request.
///
/// Default implementation builds a naive SQL query based on the statement
/// returned by the `prepare` method: `SELECT COUNT(*) FROM (...)`.
///
/// Adopting types can refine this countRequest method and return more
/// efficient SQL.
///
/// - parameter db: A database connection.
func fetchCount(_ db: Database) throws -> Int
}
extension Request {
/// The number of rows fetched by the request.
///
/// This default implementation builds a naive SQL query based on the
/// statement returned by the `prepare` method: `SELECT COUNT(*) FROM (...)`.
///
/// - parameter db: A database connection.
public func fetchCount(_ db: Database) throws -> Int {
let (statement, _) = try prepare(db)
let sql = "SELECT COUNT(*) FROM (\(statement.sql))"
return try Int.fetchOne(db, sql, arguments: statement.arguments)!
}
}
extension Request {
/// Returns a request bound to type T.
///
/// The returned request can fetch if the type T is fetchable (Row,
/// value, record).
///
/// // Int?
/// let maxScore = Player
/// .select(max(scoreColumn))
/// .asRequest(of: Int.self) // <--
/// .fetchOne(db)
///
/// - parameter type: The fetched type T
/// - returns: A typed request bound to type T.
public func asRequest<T>(of type: T.Type) -> AnyTypedRequest<T> {
return AnyTypedRequest { try self.prepare($0) }
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns an adapted request.
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedRequest<Self> {
return AdaptedRequest(self, adapter)
}
}
/// An adapted request.
public struct AdaptedRequest<Base: Request> : Request {
/// Creates an adapted request from a base request and a closure that builds
/// a row adapter from a database connection.
init(_ base: Base, _ adapter: @escaping (Database) throws -> RowAdapter) {
self.base = base
self.adapter = adapter
}
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
///
/// - parameter db: A database connection.
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
let (statement, baseAdapter) = try base.prepare(db)
if let baseAdapter = baseAdapter {
return try (statement, ChainedAdapter(first: baseAdapter, second: adapter(db)))
} else {
return try (statement, adapter(db))
}
}
/// The number of rows fetched by the request.
///
/// - parameter db: A database connection.
public func fetchCount(_ db: Database) throws -> Int {
return try base.fetchCount(db)
}
private let base: Base
private let adapter: (Database) throws -> RowAdapter
}
/// A type-erased Request.
///
/// An instance of AnyRequest forwards its operations to an underlying request,
/// hiding its specifics.
public struct AnyRequest : Request {
/// Creates a new request that wraps and forwards operations to `request`.
public init(_ request: Request) {
self._prepare = { try request.prepare($0) }
}
/// Creates a new request whose `prepare()` method wraps and forwards
/// operations the argument closure.
public init(_ prepare: @escaping (Database) throws -> (SelectStatement, RowAdapter?)) {
_prepare = prepare
}
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
///
/// - parameter db: A database connection.
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
return try _prepare(db)
}
private let _prepare: (Database) throws -> (SelectStatement, RowAdapter?)
}
/// A Request built from raw SQL.
public struct SQLRequest : Request {
/// Creates a new request from an SQL string, optional arguments, and
/// optional row adapter.
///
/// let request = SQLRequest("SELECT * FROM players")
/// let request = SQLRequest("SELECT * FROM players WHERE id = ?", arguments: [1])
///
/// - parameters:
/// - sql: An SQL query.
/// - arguments: Optional 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? = nil, adapter: RowAdapter? = nil, cached: Bool = false) {
self.init(sql, arguments: arguments, adapter: adapter, fromCache: cached ? .user : nil)
}
/// Creates a new request from an SQL string, optional arguments, and
/// optional row adapter.
///
/// let request = SQLRequest("SELECT * FROM players")
/// let request = SQLRequest("SELECT * FROM players WHERE id = ?", arguments: [1])
///
/// - parameters:
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter.
/// - statementCacheName: Optional statement cache name.
/// - returns: A SQLRequest
init(_ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, fromCache statementCacheName: Database.StatementCacheName?) {
self.sql = sql
self.arguments = arguments
self.adapter = adapter
self.statementCacheName = statementCacheName
}
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
///
/// - parameter db: A database connection.
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
let statement: SelectStatement
if let statementCacheName = statementCacheName {
statement = try db.selectStatement(sql, fromCache: statementCacheName)
} else {
statement = try db.makeSelectStatement(sql)
}
if let arguments = arguments {
try statement.setArgumentsWithValidation(arguments)
}
return (statement, adapter)
}
private let sql: String
private let arguments: StatementArguments?
private let adapter: RowAdapter?
private let statementCacheName: Database.StatementCacheName?
}
/// The protocol for requests that know how to decode database rows.
///
/// Typed requests can fetch if their associated type RowDecoder is able to
/// decode rows (Row, value, record)
///
/// struct Player: RowConvertible { ... }
/// let request: ... // Some TypedRequest that fetches Player
/// try request.fetchCursor(db) // Cursor of Player
/// try request.fetchAll(db) // [Player]
/// try request.fetchOne(db) // Player?
public protocol TypedRequest : Request {
/// The type that can convert raw database rows to fetched values
associatedtype RowDecoder
}
extension TypedRequest {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns an adapted typed request.
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedTypedRequest<Self> {
return AdaptedTypedRequest(self, adapter)
}
}
/// An adapted typed request.
public struct AdaptedTypedRequest<Base: TypedRequest> : TypedRequest {
/// The type that can convert raw database rows to fetched values
public typealias RowDecoder = Base.RowDecoder
/// Creates an adapted request from a base request and a closure that builds
/// a row adapter from a database connection.
init(_ base: Base, _ adapter: @escaping (Database) throws -> RowAdapter) {
adaptedRequest = AdaptedRequest(base, adapter)
}
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
///
/// - parameter db: A database connection.
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
return try adaptedRequest.prepare(db)
}
/// The number of rows fetched by the request.
///
/// - parameter db: A database connection.
public func fetchCount(_ db: Database) throws -> Int {
return try adaptedRequest.fetchCount(db)
}
private let adaptedRequest: AdaptedRequest<Base>
}
/// A type-erased TypedRequest.
///
/// An instance of AnyTypedRequest forwards its operations to an underlying
/// typed request, hiding its specifics.
public struct AnyTypedRequest<T> : TypedRequest {
/// The type that can convert raw database rows to fetched values
public typealias RowDecoder = T
/// Creates a new request that wraps and forwards operations to `request`.
public init<Request>(_ request: Request) where Request: TypedRequest, Request.RowDecoder == RowDecoder {
self._prepare = { try request.prepare($0) }
}
/// Creates a new request whose `prepare()` method wraps and forwards
/// operations the argument closure.
public init(_ prepare: @escaping (Database) throws -> (SelectStatement, RowAdapter?)) {
_prepare = prepare
}
/// A tuple that contains a prepared statement that is ready to be
/// executed, and an eventual row adapter.
///
/// - parameter db: A database connection.
public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
return try _prepare(db)
}
private let _prepare: (Database) throws -> (SelectStatement, RowAdapter?)
}
extension TypedRequest where RowDecoder: RowConvertible {
// MARK: Fetching Record and RowConvertible
/// A cursor over fetched records.
///
/// let request: ... // Some TypedRequest that fetches Player
/// let players = try request.fetchCursor(db) // Cursor of Player
/// while let player = try players.next() { // Player
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched records.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> RecordCursor<RowDecoder> {
return try RowDecoder.fetchCursor(db, self)
}
/// An array of fetched records.
///
/// let request: ... // Some TypedRequest that fetches Player
/// let players = try request.fetchAll(db) // [Player]
///
/// - parameter db: A database connection.
/// - returns: An array of records.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
return try RowDecoder.fetchAll(db, self)
}
/// The first fetched record.
///
/// let request: ... // Some TypedRequest that fetches Player
/// let player = try request.fetchOne(db) // Player?
///
/// - parameter db: A database connection.
/// - returns: An optional record.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchOne(_ db: Database) throws -> RowDecoder? {
return try RowDecoder.fetchOne(db, self)
}
}
extension TypedRequest where RowDecoder: DatabaseValueConvertible {
// MARK: Fetching Values
/// A cursor over fetched values.
///
/// let request: ... // Some TypedRequest that fetches String
/// let strings = try request.fetchCursor(db) // Cursor of String
/// while let string = try strings.next() { // String
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> DatabaseValueCursor<RowDecoder> {
return try RowDecoder.fetchCursor(db, self)
}
/// An array of fetched values.
///
/// let request: ... // Some TypedRequest that fetches String
/// let strings = try request.fetchAll(db) // [String]
///
/// - parameter db: A database connection.
/// - returns: An array of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
return try RowDecoder.fetchAll(db, self)
}
/// The first fetched value.
///
/// The result is nil if the request returns no row, or if no value can be
/// extracted from the first row.
///
/// let request: ... // Some TypedRequest that fetches String
/// let string = try request.fetchOne(db) // String?
///
/// - parameter db: A database connection.
/// - returns: An optional value.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchOne(_ db: Database) throws -> RowDecoder? {
return try RowDecoder.fetchOne(db, self)
}
}
extension TypedRequest where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible {
// MARK: Fetching Values
/// A cursor over fetched values.
///
/// let request: ... // Some TypedRequest that fetches String
/// let strings = try request.fetchCursor(db) // Cursor of String
/// while let string = try strings.next() { // String
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> ColumnCursor<RowDecoder> {
return try RowDecoder.fetchCursor(db, self)
}
/// An array of fetched values.
///
/// let request: ... // Some TypedRequest that fetches String
/// let strings = try request.fetchAll(db) // [String]
///
/// - parameter db: A database connection.
/// - returns: An array of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [RowDecoder] {
return try RowDecoder.fetchAll(db, self)
}
/// The first fetched value.
///
/// The result is nil if the request returns no row, or if no value can be
/// extracted from the first row.
///
/// let request: ... // Some TypedRequest that fetches String
/// let string = try request.fetchOne(db) // String?
///
/// - parameter db: A database connection.
/// - returns: An optional value.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchOne(_ db: Database) throws -> RowDecoder? {
return try RowDecoder.fetchOne(db, self)
}
}
extension TypedRequest where RowDecoder: _OptionalProtocol, RowDecoder._Wrapped: DatabaseValueConvertible {
// MARK: Fetching Optional values
/// A cursor over fetched optional values.
///
/// let request: ... // Some TypedRequest that fetches Optional<String>
/// let strings = try request.fetchCursor(db) // Cursor of String?
/// while let string = try strings.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> NullableDatabaseValueCursor<RowDecoder._Wrapped> {
return try Optional<RowDecoder._Wrapped>.fetchCursor(db, self)
}
/// An array of fetched optional values.
///
/// let request: ... // Some TypedRequest that fetches Optional<String>
/// let strings = try request.fetchAll(db) // [String?]
///
/// - parameter db: A database connection.
/// - returns: An array of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [RowDecoder._Wrapped?] {
return try Optional<RowDecoder._Wrapped>.fetchAll(db, self)
}
}
extension TypedRequest where RowDecoder: _OptionalProtocol, RowDecoder._Wrapped: DatabaseValueConvertible & StatementColumnConvertible {
// MARK: Fetching Optional values
/// A cursor over fetched optional values.
///
/// let request: ... // Some TypedRequest that fetches Optional<String>
/// let strings = try request.fetchCursor(db) // Cursor of String?
/// while let string = try strings.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> NullableColumnCursor<RowDecoder._Wrapped> {
return try Optional<RowDecoder._Wrapped>.fetchCursor(db, self)
}
/// An array of fetched optional values.
///
/// let request: ... // Some TypedRequest that fetches Optional<String>
/// let strings = try request.fetchAll(db) // [String?]
///
/// - parameter db: A database connection.
/// - returns: An array of values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [RowDecoder._Wrapped?] {
return try Optional<RowDecoder._Wrapped>.fetchAll(db, self)
}
}
extension TypedRequest where RowDecoder: Row {
// MARK: Fetching Rows
/// A cursor over fetched rows.
///
/// let request: ... // Some TypedRequest that fetches Row
/// let rows = try request.fetchCursor(db) // RowCursor
/// while let row = try rows.next() { // Row
/// let id: Int64 = row[0]
/// let name: String = row[1]
/// }
///
/// Fetched rows are reused during the cursor iteration: don't turn a row
/// cursor into an array with `Array(rows)` or `rows.filter { ... }` since
/// you would not get the distinct rows you expect. Use `Row.fetchAll(...)`
/// instead.
///
/// For the same reason, make sure you make a copy whenever you extract a
/// row for later use: `row.copy()`.
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameter db: A database connection.
/// - returns: A cursor over fetched rows.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchCursor(_ db: Database) throws -> RowCursor {
return try Row.fetchCursor(db, self)
}
/// An array of fetched rows.
///
/// let request: ... // Some TypedRequest that fetches Row
/// let rows = try request.fetchAll(db)
///
/// - parameter db: A database connection.
/// - returns: An array of fetched rows.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchAll(_ db: Database) throws -> [Row] {
return try Row.fetchAll(db, self)
}
/// The first fetched row.
///
/// let request: ... // Some TypedRequest that fetches Row
/// let row = try request.fetchOne(db)
///
/// - parameter db: A database connection.
/// - returns: A,n optional rows.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public func fetchOne(_ db: Database) throws -> Row? {
return try Row.fetchOne(db, self)
}
}
+713 -406
View File
File diff suppressed because it is too large. Load diff
+423
View File
@@ -0,0 +1,423 @@
import Foundation
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// LayoutedColumnMapping is a type that supports the RowAdapter protocol.
public struct LayoutedColumnMapping {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// An array of (baseIndex, mappedName) pairs, where baseIndex is the index
/// of a column in a base row, and mappedName the mapped name of
/// that column.
public let layoutColumns: [(Int, String)]
/// A cache for layoutIndex(ofColumn:)
let lowercaseColumnIndexes: [String: Int] // [mappedColumn: layoutColumnIndex]
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Creates a LayoutedColumnMapping from an array of (baseIndex, mappedName)
/// pairs. In each pair:
///
/// - baseIndex is the index of a column in a base row
/// - name is the mapped name of the column
///
/// For example, the following LayoutedColumnMapping defines two columns, "foo"
/// and "bar", based on the base columns at indexes 1 and 2:
///
/// LayoutedColumnMapping(layoutColumns: [(1, "foo"), (2, "bar")])
///
/// Use it in your custom RowAdapter type:
///
/// struct FooBarAdapter : RowAdapter {
/// func layoutAdapter(layout: RowLayout) throws -> LayoutedRowAdapter {
/// return LayoutedColumnMapping(layoutColumns: [(1, "foo"), (2, "bar")])
/// }
/// }
///
/// // <Row foo:"foo" bar: "bar">
/// try Row.fetchOne(db, "SELECT NULL, 'foo', 'bar'", adapter: FooBarAdapter())
public init<S: Sequence>(layoutColumns: S) where S.Iterator.Element == (Int, String) {
self.layoutColumns = Array(layoutColumns)
self.lowercaseColumnIndexes = Dictionary(
layoutColumns
.enumerated()
.map { ($0.element.1.lowercased(), $0.offset) },
uniquingKeysWith: { (left, _) in left }) // keep leftmost indexes
}
func baseColumnIndex(atMappingIndex index: Int) -> Int {
return layoutColumns[index].0
}
func columnName(atMappingIndex index: Int) -> String {
return layoutColumns[index].1
}
}
/// LayoutedColumnMapping adopts LayoutedRowAdapter
extension LayoutedColumnMapping : LayoutedRowAdapter {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns self.
public var mapping: LayoutedColumnMapping {
return self
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns the empty dictionary.
public var scopes: [String: LayoutedRowAdapter] {
return [:]
}
}
extension LayoutedColumnMapping : RowLayout {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns the index of the leftmost column named `name`, in a
/// case-insensitive way.
public func layoutIndex(ofColumn name: String) -> Int? {
if let index = lowercaseColumnIndexes[name] {
return index
}
return lowercaseColumnIndexes[name.lowercased()]
}
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// LayoutedRowAdapter is a protocol that supports the RowAdapter protocol.
///
/// GRBD ships with a ready-made type that adopts this protocol:
/// LayoutedColumnMapping.
public protocol LayoutedRowAdapter {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// A LayoutedColumnMapping that defines how to map a column name to a
/// column in a base row.
var mapping: LayoutedColumnMapping { get }
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// The layouted row adapters for each scope.
var scopes: [String: LayoutedRowAdapter] { get }
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// RowLayout is a protocol that supports the RowAdapter protocol. It describes
/// a layout of a base row.
public protocol RowLayout {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// An array of (baseIndex, name) pairs, where baseIndex is the index
/// of a column in a base row, and name the name of that column.
var layoutColumns: [(Int, String)] { get }
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// Returns the index of the leftmost column named `name`, in a
/// case-insensitive way.
func layoutIndex(ofColumn name: String) -> Int?
}
extension SelectStatement : RowLayout {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public var layoutColumns: [(Int, String)] {
return Array(columnNames.enumerated())
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func layoutIndex(ofColumn name: String) -> Int? {
return index(ofColumn: name)
}
}
/// RowAdapter is a protocol that helps two incompatible row interfaces working
/// together.
///
/// GRDB ships with four concrete types that adopt the RowAdapter protocol:
///
/// - ColumnMapping: renames row columns
/// - SuffixRowAdapter: hides the first columns of a row
/// - RangeRowAdapter: only exposes a range of columns
/// - ScopeAdapter: groups several adapters together to define named scopes
///
/// To use a row adapter, provide it to any method that fetches:
///
/// let adapter = SuffixRowAdapter(fromIndex: 2)
/// let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
///
/// // <Row baz:3>
/// try Row.fetchOne(db, sql, adapter: adapter)
public protocol RowAdapter {
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
///
/// You never call this method directly. It is called for you whenever an
/// adapter has to be applied.
///
/// The result is a value that adopts LayoutedRowAdapter, such as
/// LayoutedColumnMapping.
///
/// For example:
///
/// // An adapter that turns any row to a row that contains a single
/// // column named "foo" whose value is the leftmost value of the
/// // base row.
/// struct FirstColumnAdapter : RowAdapter {
/// func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
/// return LayoutedColumnMapping(layoutColumns: [(0, "foo")])
/// }
/// }
///
/// // <Row foo:1>
/// try Row.fetchOne(db, "SELECT 1, 2, 3", adapter: FirstColumnAdapter())
func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter
}
extension RowAdapter {
/// Returns an adapter based on self, with added scopes.
///
/// If self already defines scopes, the added scopes replace
/// eventual existing scopes with the same name.
///
/// - parameter scopes: A dictionary that maps scope names to
/// row adapters.
public func addingScopes(_ scopes: [String: RowAdapter]) -> RowAdapter {
return ScopeAdapter(mainAdapter: self, scopes: scopes)
}
}
extension RowAdapter {
func baseColumnIndex(atIndex index: Int, layout: RowLayout) throws -> Int {
return try layoutedAdapter(from: layout).mapping.baseColumnIndex(atMappingIndex: index)
}
}
/// ColumnMapping is a row adapter that maps column names.
///
/// let adapter = ColumnMapping(["foo": "bar"])
/// let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
///
/// // <Row foo:"bar">
/// try Row.fetchOne(db, sql, adapter: adapter)
public struct ColumnMapping : RowAdapter {
/// A dictionary from mapped column names to column names in a base row.
let mapping: [String: String]
/// Creates a ColumnMapping with a dictionary from mapped column names to
/// column names in a base row.
public init(_ mapping: [String: String]) {
self.mapping = mapping
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
let layoutColumns = try mapping
.map { (mappedColumn, baseColumn) -> (Int, String) in
guard let index = layout.layoutIndex(ofColumn: baseColumn) else {
let columnNames = layout.layoutColumns.map { $0.1 }
throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "Mapping references missing column \(baseColumn). Valid column names are: \(columnNames.joined(separator: ", ")).")
}
let baseIndex = layout.layoutColumns[index].0
return (baseIndex, mappedColumn)
}
.sorted { $0.0 < $1.0 } // preserve ordering of base columns
return LayoutedColumnMapping(layoutColumns: layoutColumns)
}
}
/// SuffixRowAdapter is a row adapter that hides the first columns in a row.
///
/// let adapter = SuffixRowAdapter(fromIndex: 2)
/// let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
///
/// // <Row baz:3>
/// try Row.fetchOne(db, sql, adapter: adapter)
public struct SuffixRowAdapter : RowAdapter {
/// The suffix index
let index: Int
/// Creates a SuffixRowAdapter that hides all columns before the
/// provided index.
///
/// If index is 0, the layout row is identical to the base row.
public init(fromIndex index: Int) {
GRDBPrecondition(index >= 0, "Negative column index is out of range")
self.index = index
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
return LayoutedColumnMapping(layoutColumns: layout.layoutColumns.suffix(from: index))
}
}
/// RangeRowAdapter is a row adapter that only exposes a range of columns.
///
/// let adapter = RangeRowAdapter(1..<3)
/// let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz, 4 as qux"
///
/// // <Row bar:2 baz: 3>
/// try Row.fetchOne(db, sql, adapter: adapter)
public struct RangeRowAdapter : RowAdapter {
/// The range
let range: CountableRange<Int>
/// Creates a RangeRowAdapter that only exposes a range of columns.
public init(_ range: CountableRange<Int>) {
GRDBPrecondition(range.lowerBound >= 0, "Negative column index is out of range")
self.range = range
}
/// Creates a RangeRowAdapter that only exposes a range of columns.
public init(_ range: CountableClosedRange<Int>) {
GRDBPrecondition(range.lowerBound >= 0, "Negative column index is out of range")
self.range = range.lowerBound..<(range.upperBound + 1)
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
return LayoutedColumnMapping(layoutColumns: layout.layoutColumns[range])
}
}
/// ScopeAdapter is a row adapter that lets you define scopes on rows.
///
/// // Two adapters
/// let fooAdapter = ColumnMapping(["value": "foo"])
/// let barAdapter = ColumnMapping(["value": "bar"])
///
/// // Define scopes
/// let adapter = ScopeAdapter([
/// "foo": fooAdapter,
/// "bar": barAdapter])
///
/// // Fetch
/// let sql = "SELECT 'foo' AS foo, 'bar' AS bar"
/// let row = try Row.fetchOne(db, sql, adapter: adapter)!
///
/// // Scoped rows:
/// if let fooRow = row.scoped(on: "foo") {
/// fooRow["value"] // "foo"
/// }
/// if let barRow = row.scopeed(on: "bar") {
/// barRow["value"] // "bar"
/// }
public struct ScopeAdapter : RowAdapter {
/// The main adapter
let mainAdapter: RowAdapter
/// The scope adapters
let scopes: [String: RowAdapter]
/// Creates a scoped adapter.
///
/// - parameter scopes: A dictionary that maps scope names to
/// row adapters.
public init(_ scopes: [String: RowAdapter]) {
self.mainAdapter = SuffixRowAdapter(fromIndex: 0) // Use SuffixRowAdapter(fromIndex: 0) as the identity adapter
self.scopes = scopes
}
init(mainAdapter: RowAdapter, scopes: [String: RowAdapter]) {
self.mainAdapter = mainAdapter
self.scopes = scopes
}
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
let layoutedAdapter = try mainAdapter.layoutedAdapter(from: layout)
var layoutedScopes = layoutedAdapter.scopes
for (name, adapter) in scopes {
try layoutedScopes[name] = adapter.layoutedAdapter(from: layout)
}
return LayoutedScopeAdapter(
mapping: layoutedAdapter.mapping,
scopes: layoutedScopes)
}
}
/// The LayoutedRowAdapter for ScopeAdapter
struct LayoutedScopeAdapter : LayoutedRowAdapter {
let mapping: LayoutedColumnMapping
let scopes: [String: LayoutedRowAdapter]
}
struct ChainedAdapter : RowAdapter {
let first: RowAdapter
let second: RowAdapter
func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter {
return try second.layoutedAdapter(from: first.layoutedAdapter(from: layout).mapping)
}
}
extension Row {
/// Creates a row from a base row and a statement adapter
convenience init(base: Row, adapter: LayoutedRowAdapter) {
self.init(impl: AdapterRowImpl(base: base, adapter: adapter))
}
/// Returns self if adapter is nil
func adapted(with adapter: RowAdapter?, layout: RowLayout) throws -> Row {
guard let adapter = adapter else {
return self
}
return try Row(base: self, adapter: adapter.layoutedAdapter(from: layout))
}
}
struct AdapterRowImpl : RowImpl {
let base: Row
let adapter: LayoutedRowAdapter
let mapping: LayoutedColumnMapping
init(base: Row, adapter: LayoutedRowAdapter) {
self.base = base
self.adapter = adapter
self.mapping = adapter.mapping
}
var count: Int {
return mapping.layoutColumns.count
}
var isFetched: Bool {
return base.isFetched
}
func databaseValue(atUncheckedIndex index: Int) -> DatabaseValue {
return base[mapping.baseColumnIndex(atMappingIndex: index)]
}
func dataNoCopy(atUncheckedIndex index:Int) -> Data? {
return base.dataNoCopy(atIndex: mapping.baseColumnIndex(atMappingIndex: index))
}
func columnName(atUncheckedIndex index: Int) -> String {
return mapping.columnName(atMappingIndex: index)
}
func index(ofColumn name: String) -> Int? {
return mapping.layoutIndex(ofColumn: name)
}
func scoped(on name: String) -> Row? {
guard let adapter = adapter.scopes[name] else {
return nil
}
return Row(base: base, adapter: adapter)
}
var scopeNames: Set<String> {
return Set(adapter.scopes.keys)
}
func copy(_ row: Row) -> Row {
return Row(base: base.copy(), adapter: adapter)
}
}
+62
View File
@@ -0,0 +1,62 @@
import Dispatch
/// SchedulingWatchdog makes sure that databases connections are used on correct
/// dispatch queues, and warns the user with a fatal error whenever she misuses
/// a database connection.
///
/// 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
/// single dispatch queue can be temporarily shared by two or more connections.
///
/// - SchedulingWatchdog.makeSerializedQueue(allowingDatabase:) creates a
/// dispatch queue that allows one database.
///
/// It does so by registering one instance of SchedulingWatchdog as a specific
/// of the dispatch queue, a SchedulingWatchdog that allows that database only.
///
/// Later on, the queue can be shared by several databases with the method
/// allowing(databases:execute:). See SerializedDatabase.sync() for
/// an example.
///
/// - preconditionValidQueue() crashes whenever a database is used in an invalid
/// dispatch queue.
final class SchedulingWatchdog {
private static let specificKey = DispatchSpecificKey<SchedulingWatchdog>()
private(set) var allowedDatabases: [Database]
private init(allowedDatabase database: Database) {
allowedDatabases = [database]
}
static func makeSerializedQueue(allowingDatabase database: Database) -> DispatchQueue {
let queue = DispatchQueue(label: "GRDB.SerializedDatabase")
let watchdog = SchedulingWatchdog(allowedDatabase: database)
queue.setSpecific(key: specificKey, value: watchdog)
return queue
}
// Temporarily allows `databases` while executing `body`
func allowing<T>(databases: [Database], execute body: () throws -> T) rethrows -> T {
let backup = allowedDatabases
allowedDatabases.append(contentsOf: databases)
defer { allowedDatabases = backup }
return try body()
}
static func preconditionValidQueue(_ db: Database, _ message: @autoclosure() -> String = "Database was not used on the correct thread.", file: StaticString = #file, line: UInt = #line) {
GRDBPrecondition(allows(db), message, file: file, line: line)
}
static func allows(_ db: Database) -> Bool {
return current?.allows(db) ?? false
}
func allows(_ db: Database) -> Bool {
return allowedDatabases.contains { $0 === db }
}
static var current: SchedulingWatchdog? {
return DispatchQueue.getSpecific(key: specificKey)
}
}
+137 -49
View File
@@ -2,18 +2,21 @@ import Foundation
/// A class that serializes accesses to a database.
final class SerializedDatabase {
/// The database
private let database: Database
/// The database connection
private let db: Database
/// The database configuration
var configuration: Configuration {
return database.configuration
return db.configuration
}
/// The dispatch queue
private let queue: dispatch_queue_t
/// The path to the database file
var path: String
convenience init(path: String, configuration: Configuration = Configuration(), schemaCache: DatabaseSchemaCacheType) throws {
/// The dispatch queue
private let queue: DispatchQueue
init(path: String, configuration: Configuration = Configuration(), schemaCache: DatabaseSchemaCache) throws {
// According to https://www.sqlite.org/threadsafe.html
//
// > SQLite support three different threading modes:
@@ -32,50 +35,135 @@ final class SerializedDatabase {
// Since our database connection is only used via our serial dispatch
// queue, there is no purpose using the default serialized mode.
var config = configuration
config.threadingMode = .MultiThread
config.threadingMode = .multiThread
let database = try Database(path: path, configuration: config, schemaCache: schemaCache)
self.init(database: database)
}
private init(database: Database) {
self.database = database
self.queue = dispatch_queue_create("com.github.groue.GRDB", nil)
// Activate database.preconditionValidQueue()
let databaseQueueID = unsafeBitCast(database, UnsafeMutablePointer<Void>.self)
dispatch_queue_set_specific(queue, Database.databaseQueueIDKey, databaseQueueID, nil)
database.databaseQueueID = databaseQueueID
}
func inDatabase<T>(block: (db: Database) throws -> T) rethrows -> T {
// This method is NOT reentrant.
//
// Avoiding dispatch_sync and calling block() right away if the specific
// is currently self.databaseQueueID looks like a promising solution:
//
// serializedDatabase.inDatabase { db in
// serializedDatabase.inDatabase { db in
// // Look, ma! I'm reentrant!
// }
// }
//
// However it does not survive this code, which deadlocks:
//
// let queue = dispatch_queue_create("...", nil)
// serializedDatabase.inDatabase { db in
// dispatch_sync(queue) {
// serializedDatabase.inDatabase { db in
// // Never run
// }
// }
// }
//
// I try not to ship half-baked solutions, so until a complete solution
// is found to this problem, I prefer discouraging reentrancy.
precondition(database.databaseQueueID != dispatch_get_specific(Database.databaseQueueIDKey), "Database methods are not reentrant.")
return try dispatchSync(queue) {
try block(db: self.database)
db = try Database(path: path, configuration: config, schemaCache: schemaCache)
queue = SchedulingWatchdog.makeSerializedQueue(allowingDatabase: db)
self.path = path
try queue.sync {
try db.setup()
}
}
deinit {
// Database may be deallocated in its own queue: allow reentrancy
reentrantSync { db in
db.close()
}
}
/// Synchronously executes a block the serialized dispatch queue, and
/// returns its result.
///
/// This method is *not* reentrant.
func sync<T>(_ block: (Database) throws -> T) rethrows -> T {
// Three different cases:
//
// 1. A database is invoked from some queue like the main queue:
//
// dbQueue.inDatabase { db in // <-- we're here
// }
//
// 2. A database is invoked in a reentrant way:
//
// dbQueue.inDatabase { db in
// dbQueue.inDatabase { db in // <-- we're here
// }
// }
//
// 3. A database in invoked from another database:
//
// dbQueue1.inDatabase { db1 in
// dbQueue2.inDatabase { db2 in // <-- we're here
// }
// }
guard let watchdog = SchedulingWatchdog.current else {
// Case 1
return try queue.sync {
try block(db)
}
}
// Case 2 is forbidden.
GRDBPrecondition(!watchdog.allows(db), "Database methods are not reentrant.")
// Case 3
return try queue.sync {
try SchedulingWatchdog.current!.allowing(databases: watchdog.allowedDatabases) {
try block(db)
}
}
}
/// Synchronously executes a block the serialized dispatch queue, and
/// returns its result.
///
/// This method is reentrant.
func reentrantSync<T>(_ block: (Database) throws -> T) rethrows -> T {
// Three different cases:
//
// 1. A database is invoked from some queue like the main queue:
//
// dbQueue.inDatabase { db in // <-- we're here
// }
//
// 2. A database is invoked in a reentrant way:
//
// dbQueue.inDatabase { db in
// dbQueue.inDatabase { db in // <-- we're here
// }
// }
//
// 3. A database in invoked from another database:
//
// dbQueue1.inDatabase { db1 in
// dbQueue2.inDatabase { db2 in // <-- we're here
// }
// }
guard let watchdog = SchedulingWatchdog.current else {
// Case 1
return try queue.sync {
try block(db)
}
}
// Case 2
if watchdog.allows(db) {
return try block(db)
}
// Case 3
return try queue.sync {
try SchedulingWatchdog.current!.allowing(databases: watchdog.allowedDatabases) {
try block(db)
}
}
}
/// Asynchronously executes a block in the serialized dispatch queue.
func async(_ block: @escaping (Database) -> Void) {
queue.async {
block(self.db)
}
}
/// Returns true if any only if the current dispatch queue is valid.
var onValidQueue: Bool {
return SchedulingWatchdog.allows(db)
}
/// Executes the block in the current queue.
///
/// - precondition: the current dispatch queue is valid.
func execute<T>(_ block: (Database) throws -> T) rethrows -> T {
preconditionValidQueue()
return try block(db)
}
/// Fatal error if current dispatch queue is not valid.
func preconditionValidQueue(_ message: @autoclosure() -> String = "Database was not used on the correct thread.", file: StaticString = #file, line: UInt = #line) {
SchedulingWatchdog.preconditionValidQueue(db, message, file: file, line: line)
}
}
+702 -401
View File
File diff suppressed because it is too large. Load diff
+377 -80
View File
@@ -1,19 +1,46 @@
/// When a type adopts both DatabaseValueConvertible and
/// StatementColumnConvertible, it is granted with faster access to the SQLite
/// database values.
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// 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
/// improvements.
///
/// To use it, have a value type adopt both StatementColumnConvertible and
/// DatabaseValueConvertible. GRDB will then automatically apply the
/// optimization whenever direct access to SQLite is possible:
///
/// let rows = Row.fetchCursor(db, "SELECT ...")
/// while let row = try rows.next() {
/// let int: Int = row[0] // there
/// }
/// let ints = Int.fetchAll(db, "SELECT ...") // there
/// struct Player {
/// init(row: Row) {
/// name = row["name"] // there
/// score = row["score"] // there
/// }
/// }
///
/// StatementColumnConvertible is already adopted by all Swift integer types,
/// Float, Double, String, and Bool.
public protocol StatementColumnConvertible {
/// Returns a value initialized from a raw SQLite statement pointer.
/// Initializes a value from a raw SQLite statement pointer.
///
/// As an example, here is the how Int64 adopts StatementColumnConvertible:
/// For example, here is the how Int64 adopts StatementColumnConvertible:
///
/// extension Int64: StatementColumnConvertible {
/// public init(sqliteStatement: SQLiteStatement, index: Int32) {
/// init(sqliteStatement: SQLiteStatement, index: Int32) {
/// self = sqlite3_column_int64(sqliteStatement, index)
/// }
/// }
///
/// When you implement this method, don't check for NULL.
/// This initializer is never called for NULL database values: don't perform
/// any extra check.
///
/// See https://www.sqlite.org/c3ref/column_blob.html for more information.
///
@@ -23,140 +50,410 @@ public protocol StatementColumnConvertible {
init(sqliteStatement: SQLiteStatement, index: Int32)
}
/// A cursor of database values extracted from a single column.
/// For example:
///
/// try dbQueue.inDatabase { db in
/// let names: ColumnCursor<String> = try String.fetchCursor(db, "SELECT name FROM players")
/// while let name = names.next() { // String
/// print(name)
/// }
/// }
public final class ColumnCursor<Value: DatabaseValueConvertible & StatementColumnConvertible> : Cursor {
private let statement: SelectStatement
private let sqliteStatement: SQLiteStatement
private let columnIndex: Int32
private var done = false
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
self.statement = statement
// We'll read from leftmost column at index 0, unless adapter mangles columns
self.columnIndex = try Int32(adapter?.baseColumnIndex(atIndex: 0, layout: statement) ?? 0)
self.sqliteStatement = statement.sqliteStatement
statement.cursorReset(arguments: arguments)
}
public func next() throws -> Value? {
if done { return nil }
switch sqlite3_step(sqliteStatement) {
case SQLITE_DONE:
done = true
return nil
case SQLITE_ROW:
if sqlite3_column_type(sqliteStatement, columnIndex) == SQLITE_NULL {
var error = "could not convert database value NULL to \(Value.self) with statement `\(statement.sql)`"
if !statement.arguments.isEmpty {
error += " arguments \(statement.arguments)"
}
fatalError(error)
}
return Value(sqliteStatement: sqliteStatement, index: columnIndex)
case let code:
statement.database.selectStatementDidFail(statement)
throw DatabaseError(resultCode: code, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
}
}
}
/// A cursor of optional database values extracted from a single column.
/// For example:
///
/// try dbQueue.inDatabase { db in
/// let emails: NullableColumnCursor<String> = try Optional<String>.fetchCursor(db, "SELECT email FROM players")
/// while let email = emails.next() { // String?
/// print(email ?? "<NULL>")
/// }
/// }
public final class NullableColumnCursor<Value: DatabaseValueConvertible & StatementColumnConvertible> : Cursor {
private let statement: SelectStatement
private let sqliteStatement: SQLiteStatement
private let columnIndex: Int32
private var done = false
init(statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
self.statement = statement
// We'll read from leftmost column at index 0, unless adapter mangles columns
self.columnIndex = try Int32(adapter?.baseColumnIndex(atIndex: 0, layout: statement) ?? 0)
self.sqliteStatement = statement.sqliteStatement
statement.cursorReset(arguments: arguments)
}
public func next() throws -> Value?? {
if done { return nil }
switch sqlite3_step(sqliteStatement) {
case SQLITE_DONE:
done = true
return nil
case SQLITE_ROW:
if sqlite3_column_type(sqliteStatement, columnIndex) == SQLITE_NULL {
return .some(nil)
}
return Value(sqliteStatement: sqliteStatement, index: columnIndex)
case let code:
statement.database.selectStatementDidFail(statement)
throw DatabaseError(resultCode: code, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
}
}
}
/// Types that adopt both DatabaseValueConvertible and
/// StatementColumnConvertible can be efficiently initialized from
/// database values.
///
/// See DatabaseValueConvertible for more information.
public extension DatabaseValueConvertible where Self: StatementColumnConvertible {
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
// MARK: - Fetching From SelectStatement
// MARK: Fetching From SelectStatement
/// Returns a sequence of values fetched from a prepared statement.
/// Returns a cursor over values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = String.fetch(statement) // DatabaseSequence<String>
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try String.fetchCursor(statement) // Cursor of String
/// while let name = try names.next() { // String
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = String.fetch(statement)
/// Array(names) // Arthur, Barbara
/// db.execute("DELETE ...")
/// Array(names) // Arthur
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - returns: A sequence of values.
@warn_unused_result
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
let sqliteStatement = statement.sqliteStatement
return statement.fetchSequence(arguments: arguments) {
guard sqlite3_column_type(sqliteStatement, 0) != SQLITE_NULL else {
fatalError("could not convert NULL to \(Self.self).")
}
return Self.init(sqliteStatement: sqliteStatement, index: 0)
}
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> ColumnCursor<Self> {
return try ColumnCursor(statement: statement, arguments: arguments, adapter: adapter)
}
/// Returns an array of values fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let names = String.fetchAll(statement) // [String]
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try String.fetchAll(statement) // [String]
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of values.
@warn_unused_result
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Self] {
return Array(fetch(statement, arguments: arguments))
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from a prepared statement.
///
/// let statement = db.selectStatement("SELECT name FROM ...")
/// let name = String.fetchOne(statement) // String?
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let name = try String.fetchOne(statement) // String?
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An optional value.
@warn_unused_result
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Self? {
let sqliteStatement = statement.sqliteStatement
let sequence = statement.fetchSequence(arguments: arguments) {
(sqlite3_column_type(sqliteStatement, 0) == SQLITE_NULL) ?
(nil as Self?) :
Self.init(sqliteStatement: sqliteStatement, index: 0)
}
if let value = sequence.generate().next() {
return value
}
return nil
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
// fetchOne returns nil if there is no row, or if there is a row with a null value
let cursor = try NullableColumnCursor<Self>(statement: statement, arguments: arguments, adapter: adapter)
return try cursor.next() ?? nil
}
}
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
// MARK: Fetching From Request
// MARK: - Fetching From SQL
/// Returns a sequence of values fetched from an SQL query.
/// Returns a cursor over values fetched from a fetch request.
///
/// let names = String.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String>
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try String.fetchCursor(db, request) // Cursor of String
/// while let name = try names.next() { // String
/// ...
/// }
///
/// The returned sequence can be consumed several times, but it may yield
/// different results, should database changes have occurred between two
/// generations:
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// let names = String.fetch(db, "SELECT name FROM ...")
/// Array(names) // Arthur, Barbara
/// execute("DELETE ...")
/// Array(names) // Arthur
///
/// If the database is modified while the sequence is iterating, the
/// remaining elements are undefined.
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - request: A fetch request.
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ request: Request) throws -> ColumnCursor<Self> {
let (statement, adapter) = try request.prepare(db)
return try fetchCursor(statement, adapter: adapter)
}
/// Returns an array of values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try String.fetchAll(db, request) // [String]
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Self] {
let (statement, adapter) = try request.prepare(db)
return try fetchAll(statement, adapter: adapter)
}
/// Returns a single value fetched from a fetch request.
///
/// The result is nil if the query returns no row, or if no value can be
/// extracted from the first row.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let name = try String.fetchOne(db, request) // String?
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ db: Database, _ request: Request) throws -> Self? {
let (statement, adapter) = try request.prepare(db)
return try fetchOne(statement, adapter: adapter)
}
}
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
// MARK: Fetching From SQL
/// Returns a cursor over values fetched from an SQL query.
///
/// let names = try String.fetchCursor(db, "SELECT name FROM ...") // Cursor of String
/// while let name = try names.next() { // String
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - returns: A sequence of values.
@warn_unused_result
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
return fetch(try! db.selectStatement(sql), arguments: arguments)
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> ColumnCursor<Self> {
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
///
/// let names = String.fetchAll(db, "SELECT name FROM ...") // [String]
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String]
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of values.
@warn_unused_result
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Self] {
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] {
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
///
/// let name = String.fetchOne(db, "SELECT name FROM ...") // String?
/// let name = try String.fetchOne(db, "SELECT name FROM ...") // String?
///
/// - parameters:
/// - db: A Database.
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An optional value.
@warn_unused_result
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Self? {
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
return try fetchOne(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
}
/// Swift's Optional comes with built-in methods that allow to fetch cursors
/// and arrays of optional DatabaseValueConvertible:
///
/// try Optional<String>.fetchCursor(db, "SELECT name FROM ...", arguments:...) // Cursor of String?
/// try Optional<String>.fetchAll(db, "SELECT name FROM ...", arguments:...) // [String?]
///
/// let statement = try db.makeSelectStatement("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
/// Returns a cursor over optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> NullableColumnCursor<Wrapped> {
return try NullableColumnCursor(statement: statement, arguments: arguments, adapter: adapter)
}
/// Returns an array of optional values fetched from a prepared statement.
///
/// let statement = try db.makeSelectStatement("SELECT name FROM ...")
/// let names = try Optional<String>.fetchAll(statement) // [String?]
///
/// - parameters:
/// - statement: The statement to run.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
return try Array(fetchCursor(statement, arguments: arguments, adapter: adapter))
}
}
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible {
// MARK: Fetching From Request
/// Returns a cursor over optional values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A database connection.
/// - requet: A fetch request.
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ request: Request) throws -> NullableColumnCursor<Wrapped> {
let (statement, adapter) = try request.prepare(db)
return try fetchCursor(statement, adapter: adapter)
}
/// Returns an array of optional values fetched from a fetch request.
///
/// let nameColumn = Column("name")
/// let request = Player.select(nameColumn)
/// let names = try Optional<String>.fetchAll(db, request) // [String?]
///
/// - parameter db: A database connection.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ request: Request) throws -> [Wrapped?] {
let (statement, adapter) = try request.prepare(db)
return try fetchAll(statement, adapter: adapter)
}
}
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible {
// MARK: Fetching From SQL
/// Returns a cursor over optional values fetched from an SQL query.
///
/// let names = try Optional<String>.fetchCursor(db, "SELECT name FROM ...") // Cursor of String?
/// while let name = try names.next() { // String?
/// ...
/// }
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
///
/// The cursor must be iterated in a protected dispath queue.
///
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: A cursor over fetched optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> NullableColumnCursor<Wrapped> {
return try fetchCursor(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
///
/// let names = try String.fetchAll(db, "SELECT name FROM ...") // [String?]
///
/// - parameters:
/// - db: A database connection.
/// - sql: An SQL query.
/// - parameter arguments: Optional statement arguments.
/// - adapter: Optional RowAdapter
/// - returns: An array of optional values.
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] {
return try fetchAll(db, SQLRequest(sql, arguments: arguments, adapter: adapter))
}
}
+3 -3
View File
@@ -8,9 +8,9 @@ extension CGFloat : DatabaseValueConvertible {
return Double(self).databaseValue
}
/// Returns a CGFloat initialized from *databaseValue*, if possible.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> CGFloat? {
guard let double = Double.fromDatabaseValue(databaseValue) else {
/// Returns a CGFloat initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> CGFloat? {
guard let double = Double.fromDatabaseValue(dbValue) else {
return nil
}
return CGFloat(double)
+32
View File
@@ -0,0 +1,32 @@
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// Data is convertible to and from DatabaseValue.
extension Data : DatabaseValueConvertible, StatementColumnConvertible {
public init(sqliteStatement: SQLiteStatement, index: Int32) {
if let bytes = sqlite3_column_blob(sqliteStatement, Int32(index)) {
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
self.init(bytes: bytes, count: count) // copy bytes
} else {
self.init()
}
}
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
return DatabaseValue(storage: .blob(self))
}
/// Returns a Data initialized from *dbValue*, if it contains
/// a Blob.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Data? {
guard case .blob(let data) = dbValue.storage else {
return nil
}
return data
}
}
@@ -1,32 +0,0 @@
import Foundation
/// DatabaseCoder reads and stores objects that conform to NSCoding in
/// the database.
public struct DatabaseCoder: DatabaseValueConvertible {
/// The object
public let object: AnyObject
/// Creates a DatabaseCoder from an object that conforms to NSCoding.
///
/// The result is nil if and only if *object* is nil.
public init?(_ object: AnyObject?) {
guard let object = object else {
return nil
}
self.object = object
}
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
return NSKeyedArchiver.archivedDataWithRootObject(object).databaseValue
}
/// Returns a DatabaseCoder if *databaseValue* contains an archived object.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> DatabaseCoder? {
guard let data = NSData.fromDatabaseValue(databaseValue) else {
return nil
}
return DatabaseCoder(NSKeyedUnarchiver.unarchiveObjectWithData(data))
}
}
@@ -1,6 +1,6 @@
import Foundation
/// DatabaseDateComponents reads and stores NSDateComponents in the database.
/// DatabaseDateComponents reads and stores DateComponents in the database.
public struct DatabaseDateComponents : DatabaseValueConvertible {
/// The available formats for reading and storing date components.
@@ -46,21 +46,21 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
// MARK: - NSDateComponents conversion
/// The date components
public let dateComponents: NSDateComponents
public let dateComponents: DateComponents
/// The database format
public let format: Format
/// Creates a DatabaseDateComponents from an NSDateComponents and a format.
/// Creates a DatabaseDateComponents from a DateComponents and a format.
///
/// The result is nil if and only if *dateComponents* is nil.
///
/// - parameters:
/// - dateComponents: An optional NSDateComponents.
/// - dateComponents: An optional DateComponents.
/// - format: The format used for storing the date components in
/// the database.
/// - returns: An optional DatabaseDateComponents.
public init?(_ dateComponents: NSDateComponents?, format: Format) {
public init?(_ dateComponents: DateComponents?, format: Format) {
guard let dateComponents = dateComponents else {
return nil
}
@@ -76,9 +76,9 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
let dateString: String?
switch format {
case .YMD_HM, .YMD_HMS, .YMD_HMSS, .YMD:
let year = (dateComponents.year == NSDateComponentUndefined) ? 0 : dateComponents.year
let month = (dateComponents.month == NSDateComponentUndefined) ? 1 : dateComponents.month
let day = (dateComponents.day == NSDateComponentUndefined) ? 1 : dateComponents.day
let year = dateComponents.year ?? 0
let month = dateComponents.month ?? 1
let day = dateComponents.day ?? 1
dateString = NSString(format: "%04d-%02d-%02d", year, month, day) as String
default:
dateString = nil
@@ -87,30 +87,30 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
let timeString: String?
switch format {
case .YMD_HM, .HM:
let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour
let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute
let hour = dateComponents.hour ?? 0
let minute = dateComponents.minute ?? 0
timeString = NSString(format: "%02d:%02d", hour, minute) as String
case .YMD_HMS, .HMS:
let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour
let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute
let second = (dateComponents.second == NSDateComponentUndefined) ? 0 : dateComponents.second
let hour = dateComponents.hour ?? 0
let minute = dateComponents.minute ?? 0
let second = dateComponents.second ?? 0
timeString = NSString(format: "%02d:%02d:%02d", hour, minute, second) as String
case .YMD_HMSS, .HMSS:
let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour
let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute
let second = (dateComponents.second == NSDateComponentUndefined) ? 0 : dateComponents.second
let nanosecond = (dateComponents.nanosecond == NSDateComponentUndefined) ? 0 : dateComponents.nanosecond
let hour = dateComponents.hour ?? 0
let minute = dateComponents.minute ?? 0
let second = dateComponents.second ?? 0
let nanosecond = dateComponents.nanosecond ?? 0
timeString = NSString(format: "%02d:%02d:%02d.%03d", hour, minute, second, Int(round(Double(nanosecond) / 1_000_000.0))) as String
default:
timeString = nil
}
return [dateString, timeString].flatMap { $0 }.joinWithSeparator(" ").databaseValue
return [dateString, timeString].flatMap { $0 }.joined(separator: " ").databaseValue
}
/// Returns a DatabaseDateComponents if *databaseValue* contains a
/// Returns a DatabaseDateComponents if *dbValue* contains a
/// valid date.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> DatabaseDateComponents? {
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseDateComponents? {
// https://www.sqlite.org/lang_datefunc.html
//
// Supported formats are:
@@ -127,19 +127,19 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
// - HH:MM:SS.SSS
// We need a String
guard let string = String.fromDatabaseValue(databaseValue) else {
guard let string = String.fromDatabaseValue(dbValue) else {
return nil
}
let dateComponents = NSDateComponents()
let scanner = NSScanner(string: string)
scanner.charactersToBeSkipped = NSCharacterSet()
var dateComponents = DateComponents()
let scanner = Scanner(string: string)
scanner.charactersToBeSkipped = CharacterSet()
let hasDate: Bool
// YYYY or HH
var initialNumber: Int = 0
if !scanner.scanInteger(&initialNumber) {
if !scanner.scanInt(&initialNumber) {
return nil
}
switch scanner.scanLocation {
@@ -166,44 +166,44 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
}
// -
if !scanner.scanString("-", intoString: nil) {
if !scanner.scanString("-", into: nil) {
return nil
}
// MM
var month: Int = 0
if scanner.scanInteger(&month) && month >= 1 && month <= 12 {
if scanner.scanInt(&month) && month >= 1 && month <= 12 {
dateComponents.month = month
} else {
return nil
}
// -
if !scanner.scanString("-", intoString: nil) {
if !scanner.scanString("-", into: nil) {
return nil
}
// DD
var day: Int = 0
if scanner.scanInteger(&day) && day >= 1 && day <= 31 {
if scanner.scanInt(&day) && day >= 1 && day <= 31 {
dateComponents.day = day
} else {
return nil
}
// YYYY-MM-DD
if scanner.atEnd {
if scanner.isAtEnd {
return DatabaseDateComponents(dateComponents, format: .YMD)
}
// T/space
if !scanner.scanString("T", intoString: nil) && !scanner.scanString(" ", intoString: nil) {
if !scanner.scanString("T", into: nil) && !scanner.scanString(" ", into: nil) {
return nil
}
// HH
var hour: Int = 0
if scanner.scanInteger(&hour) && hour >= 0 && hour <= 23 {
if scanner.scanInt(&hour) && hour >= 0 && hour <= 23 {
dateComponents.hour = hour
} else {
return nil
@@ -214,20 +214,20 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
}
// :
if !scanner.scanString(":", intoString: nil) {
if !scanner.scanString(":", into: nil) {
return nil
}
// MM
var minute: Int = 0
if scanner.scanInteger(&minute) && minute >= 0 && minute <= 59 {
if scanner.scanInt(&minute) && minute >= 0 && minute <= 59 {
dateComponents.minute = minute
} else {
return nil
}
// [YYYY-MM-DD] HH:MM
if scanner.atEnd {
if scanner.isAtEnd {
if hasDate {
return DatabaseDateComponents(dateComponents, format: .YMD_HM)
} else {
@@ -236,20 +236,20 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
}
// :
if !scanner.scanString(":", intoString: nil) {
if !scanner.scanString(":", into: nil) {
return nil
}
// SS
var second: Int = 0
if scanner.scanInteger(&second) && second >= 0 && second <= 59 {
if scanner.scanInt(&second) && second >= 0 && second <= 59 {
dateComponents.second = second
} else {
return nil
}
// [YYYY-MM-DD] HH:MM:SS
if scanner.atEnd {
if scanner.isAtEnd {
if hasDate {
return DatabaseDateComponents(dateComponents, format: .YMD_HMS)
} else {
@@ -258,15 +258,15 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
}
// .
if !scanner.scanString(".", intoString: nil) {
if !scanner.scanString(".", into: nil) {
return nil
}
// SSS
var millisecondDigits: NSString? = nil
if scanner.scanCharactersFromSet(NSCharacterSet.decimalDigitCharacterSet(), intoString: &millisecondDigits), var millisecondDigits = millisecondDigits {
if scanner.scanCharacters(from: .decimalDigits, into: &millisecondDigits), var millisecondDigits = millisecondDigits {
if millisecondDigits.length > 3 {
millisecondDigits = millisecondDigits.substringToIndex(3)
millisecondDigits = NSString(string: millisecondDigits.substring(to: 3))
}
dateComponents.nanosecond = millisecondDigits.integerValue * 1_000_000
} else {
@@ -274,7 +274,7 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
}
// [YYYY-MM-DD] HH:MM:SS.SSS
if scanner.atEnd {
if scanner.isAtEnd {
if hasDate {
return DatabaseDateComponents(dateComponents, format: .YMD_HMSS)
} else {
@@ -1,34 +0,0 @@
import Foundation
/// Foundation support for DatabaseValue
extension DatabaseValue {
/// Builds a DatabaseValue from AnyObject.
///
/// The result is nil unless object adopts DatabaseValueConvertible (NSData,
/// NSDate, NSNull, NSNumber, NSString, NSURL).
public init?(object: AnyObject) {
guard let convertible = object as? DatabaseValueConvertible else {
return nil
}
self.init(storage: convertible.databaseValue.storage)
}
/// Converts a DatabaseValue to AnyObject.
///
/// - returns: NSNull, NSNumber, NSString, or NSData.
public func toAnyObject() -> AnyObject {
switch storage {
case .Null:
return NSNull()
case .Int64(let int64):
return NSNumber(longLong: int64)
case .Double(let double):
return NSNumber(double: double)
case .String(let string):
return string as NSString
case .Blob(let data):
return data
}
}
}
@@ -0,0 +1,41 @@
import Foundation
/// DatabaseValueConvertible is free for ReferenceConvertible types whose
/// ReferenceType is itself DatabaseValueConvertible.
///
/// class FooReference { ... }
/// struct Foo : ReferenceConvertible {
/// typealias ReferenceType = FooReference
/// }
///
/// // If the ReferenceType adopts DatabaseValueConvertible...
/// extension FooReference : DatabaseValueConvertible { ... }
///
/// // ... then the ReferenceConvertible type can freely adopt DatabaseValueConvertible:
/// extension Foo : DatabaseValueConvertible { /* empty */ }
extension DatabaseValueConvertible where Self: ReferenceConvertible, Self.ReferenceType: DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
return (self as! ReferenceType).databaseValue
}
/// Returns a value initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
return ReferenceType.fromDatabaseValue(dbValue).flatMap { cast($0) }
}
}
public extension DatabaseValueConvertible where Self: Decodable & ReferenceConvertible, Self.ReferenceType: DatabaseValueConvertible {
public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
// Preserve custom database decoding
return ReferenceType.fromDatabaseValue(databaseValue).flatMap { cast($0) }
}
}
public extension DatabaseValueConvertible where Self: Encodable & ReferenceConvertible, Self.ReferenceType: DatabaseValueConvertible {
public var databaseValue: DatabaseValue {
// Preserve custom database encoding
return (self as! ReferenceType).databaseValue
}
}
+126
View File
@@ -0,0 +1,126 @@
import Foundation
/// NSDate is stored in the database using the format
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
extension NSDate : DatabaseValueConvertible {
/// Returns a database value that contains the date encoded as
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
public var databaseValue: DatabaseValue {
return (self as Date).databaseValue
}
/// Returns a date initialized from dbValue, if possible.
///
/// If database value contains a number, that number is interpreted as a
/// timeinterval since 00:00:00 UTC on 1 January 1970.
///
/// If database value contains a string, that string is interpreted as a
/// [SQLite date](https://sqlite.org/lang_datefunc.html) in the UTC time
/// zone. Nil is returned if the date string does not contain at least the
/// year, month and day components. Other components (minutes, etc.)
/// are set to zero if missing.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
guard let date = Date.fromDatabaseValue(dbValue) else {
return nil
}
return cast(date)
}
}
/// Date is stored in the database using the format
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
extension Date : DatabaseValueConvertible {
/// Returns a database value that contains the date encoded as
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
public var databaseValue: DatabaseValue {
return storageDateFormatter.string(from: self).databaseValue
}
/// Returns a date initialized from dbValue, if possible.
///
/// If database value contains a number, that number is interpreted as a
/// timeinterval since 00:00:00 UTC on 1 January 1970.
///
/// If database value contains a string, that string is interpreted as a
/// [SQLite date](https://sqlite.org/lang_datefunc.html) in the UTC time
/// zone. Nil is returned if the date string does not contain at least the
/// year, month and day components. Other components (minutes, etc.)
/// are set to zero if missing.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Date? {
if let databaseDateComponents = DatabaseDateComponents.fromDatabaseValue(dbValue) {
return Date(databaseDateComponents: databaseDateComponents)
}
if let timestamp = Double.fromDatabaseValue(dbValue) {
return Date(timeIntervalSince1970: timestamp)
}
return nil
}
private init?(databaseDateComponents: DatabaseDateComponents) {
guard databaseDateComponents.format.hasYMDComponents else {
// Refuse to turn hours without any date information into Date:
return nil
}
guard let date = UTCCalendar.date(from: databaseDateComponents.dateComponents) else {
return nil
}
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate)
}
/// Creates a date from a [Julian Day](https://en.wikipedia.org/wiki/Julian_day).
public init?(julianDay: Double) {
// Conversion uses the same algorithm as SQLite: https://www.sqlite.org/src/artifact/8ec787fed4929d8c
// TODO: check for overflows one day, and return nil when computation can't complete.
let JD = Int64(julianDay * 86400000)
let Z = Int(((JD + 43200000)/86400000))
var A = Int(((Double(Z) - 1867216.25)/36524.25))
A = Z + 1 + A - (A/4)
let B = A + 1524
let C = Int(((Double(B) - 122.1)/365.25))
let D = (36525*(C&32767))/100
let E = Int((Double(B-D)/30.6001))
let X1 = Int((30.6001*Double(E)))
let day = B - D - X1
let month = E<14 ? E-1 : E-13
let year = month>2 ? C - 4716 : C - 4715
var s = Int(((JD + 43200000) % 86400000))
var second = Double(s)/1000.0
s = Int(second)
second -= Double(s)
let hour = s/3600
s -= hour*3600
let minute = s/60
second += Double(s - minute*60)
var dateComponents = DateComponents()
dateComponents.year = year
dateComponents.month = month
dateComponents.day = day
dateComponents.hour = hour
dateComponents.minute = minute
dateComponents.second = Int(second)
dateComponents.nanosecond = Int((second - Double(Int(second))) * 1.0e9)
guard let date = UTCCalendar.date(from: dateComponents) else {
return nil
}
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate)
}
}
/// The DatabaseDate date formatter for stored dates.
private let storageDateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
return formatter
}()
// The NSCalendar for stored dates.
private let UTCCalendar: Calendar = {
var calendar = Calendar(identifier: .gregorian)
calendar.locale = Locale(identifier: "en_US_POSIX")
calendar.timeZone = TimeZone(secondsFromGMT: 0)!
return calendar
}()
+6 -11
View File
@@ -2,23 +2,18 @@ import Foundation
/// NSData is convertible to and from DatabaseValue.
extension NSData : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
// SQLite cant' store zero-length blobs.
guard length > 0 else {
return .Null
}
return DatabaseValue(storage: .Blob(self))
return (self as Data).databaseValue
}
/// Returns an NSData initialized from *databaseValue*, if it contains
/// Returns an NSData initialized from *dbValue*, if it contains
/// a Blob.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
switch databaseValue.storage {
case .Blob(let data):
return self.init(data: data)
default:
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
guard let data = Data.fromDatabaseValue(dbValue) else {
return nil
}
return cast(data)
}
}
-84
View File
@@ -1,84 +0,0 @@
import Foundation
/// NSDate are stored in the database using the format
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
extension NSDate : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
return storageDateFormatter.stringFromDate(self).databaseValue
}
/// Returns an NSDate initialized from *databaseValue*, if possible.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
if let databaseDateComponents = DatabaseDateComponents.fromDatabaseValue(databaseValue) {
return fromDatabaseDateComponents(databaseDateComponents)
}
if let julianDayNumber = Double.fromDatabaseValue(databaseValue) {
return fromJulienDayNumber(julianDayNumber)
}
return nil
}
private static func fromJulienDayNumber(julianDayNumber: Double) -> Self? {
// Conversion uses the same algorithm as SQLite: https://www.sqlite.org/src/artifact/8ec787fed4929d8c
let JD = Int64(julianDayNumber * 86400000)
let Z = Int(((JD + 43200000)/86400000))
var A = Int(((Double(Z) - 1867216.25)/36524.25))
A = Z + 1 + A - (A/4)
let B = A + 1524
let C = Int(((Double(B) - 122.1)/365.25))
let D = (36525*(C&32767))/100
let E = Int((Double(B-D)/30.6001))
let X1 = Int((30.6001*Double(E)))
let day = B - D - X1
let month = E<14 ? E-1 : E-13
let year = month>2 ? C - 4716 : C - 4715
var s = Int(((JD + 43200000) % 86400000))
var second = Double(s)/1000.0
s = Int(second)
second -= Double(s)
let hour = s/3600
s -= hour*3600
let minute = s/60
second += Double(s - minute*60)
let dateComponents = NSDateComponents()
dateComponents.year = year
dateComponents.month = month
dateComponents.day = day
dateComponents.hour = hour
dateComponents.minute = minute
dateComponents.second = Int(second)
dateComponents.nanosecond = Int((second - Double(Int(second))) * 1.0e9)
let date = UTCCalendar.dateFromComponents(dateComponents)!
return self.init(timeInterval: 0, sinceDate: date)
}
private static func fromDatabaseDateComponents(databaseDateComponents: DatabaseDateComponents) -> Self? {
guard databaseDateComponents.format.hasYMDComponents else {
// Refuse to turn hours without any date information into NSDate:
return nil
}
let date = UTCCalendar.dateFromComponents(databaseDateComponents.dateComponents)!
return self.init(timeInterval: 0, sinceDate: date)
}
}
/// The DatabaseDate date formatter for stored dates.
private let storageDateFormatter: NSDateFormatter = {
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
return formatter
}()
// The NSCalendar for stored dates.
private let UTCCalendar: NSCalendar = {
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
calendar.locale = NSLocale(localeIdentifier: "en_US_POSIX")
calendar.timeZone = NSTimeZone(forSecondsFromGMT: 0)
return calendar
}()
+4 -4
View File
@@ -1,15 +1,15 @@
import Foundation
/// NSNull adopts DatabaseValueConvertible
extension NSNull: DatabaseValueConvertible {
extension NSNull : DatabaseValueConvertible {
/// Returns DatabaseValue.Null.
/// Returns DatabaseValue.null.
public var databaseValue: DatabaseValue {
return .Null
return .null
}
/// Returns nil.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
return nil
}
}
+35 -19
View File
@@ -1,31 +1,46 @@
import Foundation
private let integerRoundingBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
/// NSNumber adopts DatabaseValueConvertible
extension NSNumber: DatabaseValueConvertible {
extension NSNumber : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
switch String.fromCString(objCType)! {
// Don't lose precision: store integers that fits in Int64 as Int64
if let decimal = self as? NSDecimalNumber,
decimal == decimal.rounding(accordingToBehavior: integerRoundingBehavior), // integer
decimal.compare(NSDecimalNumber(value: Int64.max)) != .orderedDescending, // decimal <= Int64.max
decimal.compare(NSDecimalNumber(value: Int64.min)) != .orderedAscending // decimal >= Int64.min
{
return int64Value.databaseValue
}
switch String(cString: objCType) {
case "c":
return Int64(charValue).databaseValue
return Int64(int8Value).databaseValue
case "C":
return Int64(unsignedCharValue).databaseValue
return Int64(uint8Value).databaseValue
case "s":
return Int64(shortValue).databaseValue
return Int64(int16Value).databaseValue
case "S":
return Int64(unsignedShortValue).databaseValue
return Int64(uint16Value).databaseValue
case "i":
return Int64(intValue).databaseValue
return Int64(int32Value).databaseValue
case "I":
return Int64(unsignedIntValue).databaseValue
return Int64(uint32Value).databaseValue
case "l":
return Int64(longValue).databaseValue
return Int64(intValue).databaseValue
case "L":
return Int64(unsignedLongValue).databaseValue
let uint = uintValue
GRDBPrecondition(UInt64(uint) <= UInt64(Int64.max), "could not convert \(uint) to an Int64 that can be stored in the database")
return Int64(uint).databaseValue
case "q":
return Int64(longLongValue).databaseValue
return Int64(int64Value).databaseValue
case "Q":
return Int64(unsignedLongLongValue).databaseValue
let uint64 = uint64Value
GRDBPrecondition(uint64 <= UInt64(Int64.max), "could not convert \(uint64) to an Int64 that can be stored in the database")
return Int64(uint64).databaseValue
case "f":
return Double(floatValue).databaseValue
case "d":
@@ -33,17 +48,18 @@ extension NSNumber: DatabaseValueConvertible {
case "B":
return boolValue.databaseValue
case let objCType:
// Assume a GRDB bug: there is no point throwing any error.
fatalError("DatabaseValueConvertible: Unsupported NSNumber type: \(objCType)")
}
}
/// Returns an NSNumber initialized from *databaseValue*, if possible.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
switch databaseValue.storage {
case .Int64(let int64):
return self.init(longLong: int64)
case .Double(let double):
return self.init(double: double)
/// Returns an NSNumber initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
switch dbValue.storage {
case .int64(let int64):
return self.init(value: int64)
case .double(let double):
return self.init(value: double)
default:
return nil
}
+4 -4
View File
@@ -1,16 +1,16 @@
import Foundation
/// NSString adopts DatabaseValueConvertible
extension NSString: DatabaseValueConvertible {
extension NSString : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
return (self as String).databaseValue
}
/// Returns an NSString initialized from *databaseValue*, if possible.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
guard let string = String.fromDatabaseValue(databaseValue) else {
/// Returns an NSString initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
guard let string = String.fromDatabaseValue(dbValue) else {
return nil
}
return self.init(string: string)
-19
View File
@@ -1,19 +0,0 @@
import Foundation
/// NSURL adopts DatabaseValueConvertible.
extension NSURL : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
/// (the URL's absoluteString).
public var databaseValue: DatabaseValue {
return absoluteString.databaseValue
}
/// Returns an NSURL initialized from *databaseValue*, if possible.
public static func fromDatabaseValue(databaseValue: DatabaseValue) -> Self? {
guard let string = String.fromDatabaseValue(databaseValue) else {
return nil
}
return self.init(string: string)
}
}
@@ -1,39 +0,0 @@
import Foundation
/// Foundation support for Row
extension Row {
/// Builds a row from an NSDictionary.
///
/// The result is nil unless all dictionary keys are strings, and values
/// adopt DatabaseValueConvertible (NSData, NSDate, NSNull, NSNumber,
/// NSString, NSURL).
public convenience init?(_ dictionary: NSDictionary) {
var initDictionary = [String: DatabaseValueConvertible?]()
for (key, value) in dictionary {
guard let columnName = key as? String else {
return nil
}
guard let databaseValue = DatabaseValue(object: value) else {
return nil
}
initDictionary[columnName] = databaseValue
}
self.init(initDictionary)
}
/// Converts a row to an NSDictionary.
///
/// When the row contains duplicated column names, the dictionary contains
/// the value of the leftmost column.
///
/// - returns: An NSDictionary.
public func toNSDictionary() -> NSDictionary {
let dictionary = NSMutableDictionary(capacity: count)
// Reverse so that the result dictionary contains values for the leftmost columns.
for (columnName, databaseValue) in reverse() {
dictionary[columnName] = databaseValue.toAnyObject()
}
return dictionary
}
}
@@ -1,79 +0,0 @@
import Foundation
extension StatementArguments {
// MARK: Positional Arguments
/// Initializes arguments from an NSArray.
///
/// The result is nil unless all objects adopt DatabaseValueConvertible
/// (NSData, NSDate, NSNull, NSNumber, NSString, NSURL).
///
/// let values: NSArray = ["foo", "bar", "baz"]
/// db.execute("INSERT ... (?,?,?)", arguments: StatementArguments(values)!)
///
/// - parameter array: An NSArray
/// - returns: A StatementArguments.
public init?(_ array: NSArray) {
// IMPLEMENTATION NOTE
//
// This initializer is required for the following code to compile:
//
// let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (?, ?)")
// let persons = [ // NSArray of NSArray, actually
// ["Arthur", 41],
// ["Barbara", 38],
// ]
// for person in persons {
// try statement.execute(StatementArguments(person)) // Avoid an error here
// }
var values = [DatabaseValueConvertible?]()
for object in array {
guard let databaseValue = DatabaseValue(object: object) else {
return nil
}
values.append(databaseValue)
}
self.init(values)
}
// MARK: Named Arguments
/// Initializes arguments from an NSDictionary.
///
/// The result is nil unless all dictionary keys are strings, and values
/// adopt DatabaseValueConvertible (NSData, NSDate, NSNull, NSNumber,
/// NSString, NSURL).
///
/// let values: NSDictionary = ["firstName": "Arthur", "lastName": "Miller"]
/// db.execute("INSERT ... (?,?,?)", arguments: StatementArguments(values)!)
///
/// - parameter dictionary: An NSDictionary
/// - returns: A StatementArguments.
public init?(_ dictionary: NSDictionary) {
// IMPLEMENTATION NOTE
//
// This initializer is required for the following code to compile:
//
// let statement = try db.updateStatement("INSERT INTO persons (name, age) VALUES (:name, :age)")
// let persons = [ // NSArray of NSDictionary, actually
// ["name": "Arthur", "age": 41],
// ["name": "Barbara", "age": 38],
// ]
// for person in persons {
// try statement.execute(StatementArguments(person)) // Avoid an error here
// }
var initDictionary = [String: DatabaseValueConvertible?]()
for (key, value) in dictionary {
guard let columnName = key as? String else {
return nil
}
guard let databaseValue = DatabaseValue(object: value) else {
return nil
}
initDictionary[columnName] = databaseValue
}
self.init(initDictionary)
}
}
+22
View File
@@ -0,0 +1,22 @@
import Foundation
/// NSURL stores its absoluteString in the database.
extension NSURL : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
/// (the URL's absoluteString).
public var databaseValue: DatabaseValue {
return absoluteString?.databaseValue ?? .null
}
/// Returns an NSURL initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
guard let string = String.fromDatabaseValue(dbValue) else {
return nil
}
return cast(URL(string: string))
}
}
/// URL stores its absoluteString in the database.
extension URL : DatabaseValueConvertible { }
+25
View File
@@ -0,0 +1,25 @@
import Foundation
/// NSUUID adopts DatabaseValueConvertible
extension NSUUID : DatabaseValueConvertible {
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16)
return uuidBytes.withUnsafeMutableBufferPointer { buffer in
getBytes(buffer.baseAddress!)
return NSData(bytes: buffer.baseAddress, length: 16).databaseValue
}
}
/// Returns an NSUUID initialized from *dbValue*, if possible.
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
guard let data = NSData.fromDatabaseValue(dbValue), data.length == 16 else {
return nil
}
return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self))
}
}
/// UUID adopts DatabaseValueConvertible
extension UUID : DatabaseValueConvertible { }
@@ -0,0 +1,91 @@
private struct DatabaseValueDecodingContainer: SingleValueDecodingContainer {
let dbValue: DatabaseValue
let codingPath: [CodingKey]
/// Decodes a null value.
///
/// - returns: Whether the encountered value was null.
func decodeNil() -> Bool {
return dbValue.isNull
}
/// Decodes a single value of the given type.
///
/// - parameter type: The type to decode as.
/// - returns: A value of the requested type.
/// - throws: `DecodingError.typeMismatch` if the encountered encoded value cannot be converted to the requested type.
/// - throws: `DecodingError.valueNotFound` if the encountered encoded value is null.
func decode(_ type: Bool.Type) throws -> Bool { return dbValue.losslessConvert() }
func decode(_ type: Int.Type) throws -> Int { return dbValue.losslessConvert() }
func decode(_ type: Int8.Type) throws -> Int8 { return dbValue.losslessConvert() }
func decode(_ type: Int16.Type) throws -> Int16 { return dbValue.losslessConvert() }
func decode(_ type: Int32.Type) throws -> Int32 { return dbValue.losslessConvert() }
func decode(_ type: Int64.Type) throws -> Int64 { return dbValue.losslessConvert() }
func decode(_ type: UInt.Type) throws -> UInt { return dbValue.losslessConvert() }
func decode(_ type: UInt8.Type) throws -> UInt8 { return dbValue.losslessConvert() }
func decode(_ type: UInt16.Type) throws -> UInt16 { return dbValue.losslessConvert() }
func decode(_ type: UInt32.Type) throws -> UInt32 { return dbValue.losslessConvert() }
func decode(_ type: UInt64.Type) throws -> UInt64 { return dbValue.losslessConvert() }
func decode(_ type: Float.Type) throws -> Float { return dbValue.losslessConvert() }
func decode(_ type: Double.Type) throws -> Double { return dbValue.losslessConvert() }
func decode(_ type: String.Type) throws -> String { return dbValue.losslessConvert() }
/// Decodes a single value of the given type.
///
/// - parameter type: The type to decode as.
/// - returns: A value of the requested type.
/// - throws: `DecodingError.typeMismatch` if the encountered encoded value cannot be converted to the requested type.
/// - throws: `DecodingError.valueNotFound` if the encountered encoded value is null.
func decode<T>(_ type: T.Type) throws -> T where T : Decodable {
if let type = T.self as? DatabaseValueConvertible.Type {
// Prefer DatabaseValueConvertible decoding over Decodable.
// This allows custom database decoding, such as decoding Date from
// String, for example.
return type.fromDatabaseValue(dbValue) as! T
} else {
return try T(from: DatabaseValueDecoder(dbValue: dbValue, codingPath: codingPath))
}
}
}
private struct DatabaseValueDecoder: Decoder {
let dbValue: DatabaseValue
init(dbValue: DatabaseValue, codingPath: [CodingKey]) {
self.dbValue = dbValue
self.codingPath = codingPath
}
// Decoder
let codingPath: [CodingKey]
var userInfo: [CodingUserInfoKey : Any] { return [:] }
func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> {
throw DecodingError.typeMismatch(
type,
DecodingError.Context(codingPath: codingPath, debugDescription: "keyed decoding is not supported"))
}
func unkeyedContainer() throws -> UnkeyedDecodingContainer {
throw DecodingError.typeMismatch(
UnkeyedDecodingContainer.self,
DecodingError.Context(codingPath: codingPath, debugDescription: "unkeyed decoding is not supported"))
}
func singleValueContainer() throws -> SingleValueDecodingContainer {
return DatabaseValueDecodingContainer(dbValue: dbValue, codingPath: codingPath)
}
}
public extension DatabaseValueConvertible where Self: Decodable {
public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
return try? self.init(from: DatabaseValueDecoder(dbValue: databaseValue, codingPath: []))
}
}
public extension DatabaseValueConvertible where Self: Decodable & RawRepresentable, Self.RawValue: DatabaseValueConvertible {
public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? {
// Preserve custom database decoding
return RawValue.fromDatabaseValue(databaseValue).flatMap { self.init(rawValue: $0) }
}
}
Loaded 100 of 464 files, more files were not shown because too many files have changed in this diff. Show more