<commit_before>- [ ] FetchedRecordsController compareRecordsByPrimaryKey: make it work with tables without explicit primary key
- [ ] Row to dictionary conversion
- [ ] FTS3Record.fetchCount(db)
- [ ] FTS: check https://www.sqlite.org/spellfix1.html
- [ ] Store dates as timestamp (https://twitter.com/gloparco/status/780948021613912064, https://github.com/groue/GRDB.swift/issues/97)
    - Global config?
    
    - New enum case in DatabaseValue.Storage?
        
        ```swift
        extension Date : DatabaseValueConvertible {
            var databaseValue: DatabaseValue {
                return DatabaseValue(storage: .date(self))
            }
        }
        extension DatabaseValue {
            func canonicalDatabaseValue(in database: Database) -> DatabaseValue {
                switch storage {
                case .date(let date):
                    switch database.configuration.dateFormat {
                        case .iso8601:
                            return ...
                        case .timestamp:
                            return ...
                    }
                default:
                    return self
                }
            }
        }
        ```
        
    - Rename DatabaseValueConvertible to Bindable?
        
        ```swift
        protocol Bindable {
            var databaseBinding: Binding { get }
            static func fromDatabaseValue(...)
        }
        protocol Binding {
            func databaseValue(in database: Database) -> DatabaseValue
        }
        extension Int : Binding { ... }
        extension String : Binding { ... }
        extension Date : Binding {
            func databaseValue(in database: Database) -> DatabaseValue {
                switch database.configuration.dateFormat {
                    case .iso8601:
                        return ...
                    case .timestamp:
                        return ...
                }
            }
        }
        ```
        
- [ ] ROUND function: read http://marc.info/?l=sqlite-users&m=130419182719263
- [ ] Remove DatabaseWriter.writeForIssue117 when https://bugs.swift.org/browse/SR-2623 is fixed (remove `writeForIssue117`, use `write` instead, and build in Release configuration) 
- [ ] Restore SQLCipher
- [ ] Restore dispatching tests in GRDBOSXTests (they are disabled in order to avoid linker errors)
    - DatabasePoolReleaseMemoryTests
    - DatabasePoolSchemaCacheTests
    - DatabaseQueueReleaseMemoryTests
    - DatabasePoolBackupTests
    - DatabasePoolConcurrencyTests
    - DatabasePoolReadOnlyTests
    - DatabaseQueueConcurrencyTests
- [ ] FetchedRecordsController throttling (suggested by @hdlj)
- [ ] Test Row.value(SQLColumn)
- [ ] What is the behavior inTransaction and inSavepoint behaviors in case of commit error? Code looks like we do not rollback, leaving the app in a weird state (out of Swift transaction block with a SQLite transaction that may still be opened).
- [ ] GRDBCipher / custom SQLite builds: remove limitations on iOS or OS X versions
- [ ] FetchedRecordsController: take inspiration from https://github.com/jflinter/Dwifft
- [ ] File protection: Read https://github.com/ccgus/fmdb/issues/262 and understand https://lists.apple.com/archives/cocoa-dev/2012/Aug/msg00527.html
- [ ] Support for resource values (see https://developer.apple.com/library/ios/qa/qa1719/_index.html)
- [ ] Query builder
    - [ ] SELECT readers.*, books.* FROM ... JOIN ...
    - [ ] date functions
    - [ ] NOW
    - [ ] RANDOM() https://www.sqlite.org/lang_corefunc.html
    - [ ] LIKE https://www.sqlite.org/lang_expr.html
    - [ ] GLOB https://www.sqlite.org/lang_expr.html
    - [ ] MATCH https://www.sqlite.org/lang_expr.html
    	FTSPattern.token("database") =~ Column("body")
    - [ ] REGEXP https://www.sqlite.org/lang_expr.html
    - [ ] CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END https://www.sqlite.org/lang_expr.html


Not sure

- [X] Have Row adopt LiteralDictionaryConvertible
    - [ ] ... allowing non unique column names
- [ ] Remove DatabaseValue.value()
    - [X] Don't talk about DatabaseValue.value() in README.md
- [ ] Support for NSColor/UIColor. Beware UIColor components can go beyond [0, 1.0] in iOS10.


Require changes in the Swift language:

- [ ] Specific and optimized Optional<StatementColumnConvertible>.fetch... methods when http://openradar.appspot.com/22852669 is fixed.


Requires recompilation of SQLite:

- [ ] https://www.sqlite.org/c3ref/column_database_name.html could help extracting out of a row a subrow only made of columns that come from a specific table. Requires SQLITE_ENABLE_COLUMN_METADATA which is not set on the sqlite3 lib that ships with OSX.



Reading list:

- VACUUM (https://blogs.gnome.org/jnelson/)<commit_msg>TODO.md<commit_after>- [ ] FTS: check https://www.sqlite.org/spellfix1.html
- [ ] Store dates as timestamp (https://twitter.com/gloparco/status/780948021613912064, https://github.com/groue/GRDB.swift/issues/97)
    - Global config?
    
    - New enum case in DatabaseValue.Storage?
        
        ```swift
        extension Date : DatabaseValueConvertible {
            var databaseValue: DatabaseValue {
                return DatabaseValue(storage: .date(self))
            }
        }
        extension DatabaseValue {
            func canonicalDatabaseValue(in database: Database) -> DatabaseValue {
                switch storage {
                case .date(let date):
                    switch database.configuration.dateFormat {
                        case .iso8601:
                            return ...
                        case .timestamp:
                            return ...
                    }
                default:
                    return self
                }
            }
        }
        ```
        
    - Rename DatabaseValueConvertible to Bindable?
        
        ```swift
        protocol Bindable {
            var databaseBinding: Binding { get }
            static func fromDatabaseValue(...)
        }
        protocol Binding {
            func databaseValue(in database: Database) -> DatabaseValue
        }
        extension Int : Binding { ... }
        extension String : Binding { ... }
        extension Date : Binding {
            func databaseValue(in database: Database) -> DatabaseValue {
                switch database.configuration.dateFormat {
                    case .iso8601:
                        return ...
                    case .timestamp:
                        return ...
                }
            }
        }
        ```
        
- [ ] ROUND function: read http://marc.info/?l=sqlite-users&m=130419182719263
- [ ] Remove DatabaseWriter.writeForIssue117 when https://bugs.swift.org/browse/SR-2623 is fixed (remove `writeForIssue117`, use `write` instead, and build in Release configuration) 
- [ ] Restore SQLCipher
- [ ] Restore dispatching tests in GRDBOSXTests (they are disabled in order to avoid linker errors)
    - DatabasePoolReleaseMemoryTests
    - DatabasePoolSchemaCacheTests
    - DatabaseQueueReleaseMemoryTests
    - DatabasePoolBackupTests
    - DatabasePoolConcurrencyTests
    - DatabasePoolReadOnlyTests
    - DatabaseQueueConcurrencyTests
- [ ] FetchedRecordsController throttling (suggested by @hdlj)
- [ ] What is the behavior inTransaction and inSavepoint behaviors in case of commit error? Code looks like we do not rollback, leaving the app in a weird state (out of Swift transaction block with a SQLite transaction that may still be opened).
- [ ] GRDBCipher / custom SQLite builds: remove limitations on iOS or OS X versions
- [ ] FetchedRecordsController: take inspiration from https://github.com/jflinter/Dwifft
- [ ] File protection: Read https://github.com/ccgus/fmdb/issues/262 and understand https://lists.apple.com/archives/cocoa-dev/2012/Aug/msg00527.html
- [ ] Support for resource values (see https://developer.apple.com/library/ios/qa/qa1719/_index.html)
- [ ] Query builder
    - [ ] SELECT readers.*, books.* FROM ... JOIN ...
    - [ ] date functions
    - [ ] NOW
    - [ ] RANDOM() https://www.sqlite.org/lang_corefunc.html
    - [ ] GLOB https://www.sqlite.org/lang_expr.html
    - [ ] REGEXP https://www.sqlite.org/lang_expr.html
    - [ ] CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END https://www.sqlite.org/lang_expr.html


Not sure

- [X] Have Row adopt LiteralDictionaryConvertible
    - [ ] ... allowing non unique column names
- [ ] Remove DatabaseValue.value()
    - [X] Don't talk about DatabaseValue.value() in README.md
- [ ] Support for NSColor/UIColor. Beware UIColor components can go beyond [0, 1.0] in iOS10.


Require changes in the Swift language:

- [ ] Specific and optimized Optional<StatementColumnConvertible>.fetch... methods when http://openradar.appspot.com/22852669 is fixed.


Requires recompilation of SQLite:

- [ ] https://www.sqlite.org/c3ref/column_database_name.html could help extracting out of a row a subrow only made of columns that come from a specific table. Requires SQLITE_ENABLE_COLUMN_METADATA which is not set on the sqlite3 lib that ships with OSX.



Reading list:

- VACUUM (https://blogs.gnome.org/jnelson/)
{'fraction_non_alphanumeric': 0.09470234844347351, 'fraction_numerical': 0.019770617149098852, 'mean_word_length': 2.16926272066459, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 30, 'lorem ipsum': 0, 'www.': 14, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '384083', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2434, 'n_words': 689}