Files
GRDB.swift/TODO.md
T

8.6 KiB

Cleanup

Documentation

Features

  • Alternative technique for custom SQLite builds: see the Podfile at https://github.com/CocoaPods/CocoaPods/issues/9104, and https://github.com/clemensg/sqlite3pod

  • Attach databases. Interesting question: what happens when one attaches a non-WAL db to a databasePool?

  • SQL Generation

  • Allow concurrent reads from a snapshot

  • Decode NSDecimalNumber from text database values

  • Check https://sqlite.org/sqlar.html

  • FTS: prefix queries

  • A way to stop a ValueObservation observer without waiting for deinit

  • More schema alterations

  • Query interface updates. One use case for query interface updates that is uneasy to deal with raw SQL:

    // Uneasy to do with raw SQL
    let players = Player.filter(...) // Returns a request that filters on column A or column B depending on the argument
    players.update(...)              // Runs the expected UPDATE statement
    
  • Database.decrypt(with:)

    • In order to allow SQLCipher tests to run all tests in an encrypted database, we need to make it possible to register several independent preparation blocks:
      • Deprecate DatabaseConfiguration.prepareDatabase
      • Introduce DatabaseConfiguration.onConnect { ... } as a replacement for DatabaseConfiguration.prepareDatabase
      • Consider introducing DatabaseConfiguration.onDisconnect { ... }
    • Deprecate change(passphrase:), and provide a static function instead
    • Introduce Database.decrypt(with:). Make it a no-op if DatabaseConfiguration.passphrase is not nil.
    • Deprecate DatabaseConfiguration.passphrase
    • Remove SQLiteConnectionDidOpen and

Unsure if necessary

Unsure how

  • Joins and full-text tables

  • UPSERT https://www.sqlite.org/lang_UPSERT.html

  • Support for "INSERT INTO ... SELECT ...".

  • Look at the jazzy configuration of https://github.com/bignerdranch/Deferred

  • Predicates, so that a filter can be evaluated both on the database, and on a record instance.

    After investigation, we can't do it reliably without knowing the collation used by a column. And SQLite does not provide this information elsewhere than in the full CREATE TABLE statement stored in sqlite_master.

  • ValueObservation erasure

    // Do better than this
    observation.mapReducer { _, reducer in AnyValueReducer(reducer) }
    
  • FetchedRecordsController diff algorithm: check https://github.com/RxSwiftCommunity/RxDataSources/issues/256

  • new.updateChanges(from: old) vs. old.updateChanges(with: { old.a = new.a }). This is confusing.

  • 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
    }
    

Reading list