Files
GRDB.swift/TODO.md
T
2017-03-26 13:58:26 +02:00

6.4 KiB

  • SQLiteLib 3.17.0

    We can't ship SQLiteLib 3.17.0: it has a FTS5 bug similar to an old FTS3 bug:

    CREATE VIRTUAL TABLE t1 USING FTS5(content);
    INSERT INTO t1(content) VALUES ('some text');
    SELECT last_insert_rowid(); // 10
    SELECT rowid FROM t1;       // 1
    

    This prevents FTS5-based records to have the correct id after insertion, and breaks an id comparison in FTS5RecordTests.testRowIdIsSelectedByDefault.

  • fts3tokenize was introduced in SQLite 3.7.17 (iOS 8.2 and OS X 10.10). And GRDB uses it before.

  • Make GRDB less stringly-typed: For each API that eats column names, check if it couldn't eat both Column and String. If this requires Column to adopt ExpressibleByStringLiteral, check if it does not introduce awful ambiguities

  • We share the database cache between database pool writers and readers. But what if a writer modifies the database schema within a transaction, and a concurrent reader reads the cache? Bad things, isn't it? Write failing tests first, and fix the bug.

  • FetchedRecordsController is not reactive:

    We need to be able to start and stop subscribing to changes made on a request. This means that diffs have to be performed between two arbitraty states of the database, not only between two transactions.

    And let's lift the restriction on Record: make this able to work on any fetchable type (row, record, value, optional value).

    Being reactive may also address the feature request by @hdlj for FetchedRecordsController throttling

  • Think about supporting Cursor's underestimatedCount, which could speed up Array(cursor) and fetchAll()

  • Attach databases (this could be the support for fetched records controller caches). Interesting question: what happens when one attaches a non-WAL db to a databasePool?

  • SQLCipher: sqlite3_rekey is discouraged (https://github.com/ccgus/fmdb/issues/547#issuecomment-259219320)

  • 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).

  • Support for resource values (see https://developer.apple.com/library/ios/qa/qa1719/_index.html)

  • Query builder

Not sure

  • Support for OR ROLLBACK, and mismatch between the Swift depth and the SQLite depth of nested transactions/savepoint:

    try db.inTransaction {           // Swift depth: 1, SQLite depth: 1
        try db.execute("COMMIT")     // Swift depth: 1, SQLite depth: 0
        try db.execute("INSERT ...") // Should throw an error since this statement is no longer protected by a transaction
        try db.execute("SELECT ...") // Should throw an error since this statement is no longer protected by a transaction
        return .commit 
    }
    
    try db.inTransaction {
        try db.execute("INSERT OR ROLLBACK ...") // throws 
        return .commit // not executed because of error
    }   // Should not ROLLBACK since transaction has already been rollbacked
    
    try db.inTransaction {
        do {
            try db.execute("INSERT OR ROLLBACK ...") // throws
        } catch {
        }
        try db.execute("INSERT ...") // Should throw an error since this statement is no longer protected by a transaction
        try db.execute("SELECT ...") // Should throw an error since this statement is no longer protected by a transaction
        return .commit
    }
    
    try db.inTransaction {
        do {
            try db.execute("INSERT OR ROLLBACK ...") // throws
        } catch {
        }
        return .commit  // Should throw an error since transaction has been rollbacked and user's intent can not be applied
    }
    
  • Document or deprecate DatabaseCoder

  • Support for NSColor/UIColor. Beware UIColor components can go beyond [0, 1.0] in iOS10.

  • Store dates as timestamp (https://twitter.com/gloparco/status/780948021613912064, https://github.com/groue/GRDB.swift/issues/97)

Require changes in the Swift language:

Requires recompilation of SQLite:

Reading list: