Files
GRDB.swift/TODO.md
T
2019-09-13 14:04:43 +02:00

8.5 KiB

Cleanup

  • Deprecate DatabaseQueue/Pool.addFunction, collation, tokenizer: those should be done in Configuration.prepareDatabase

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

  • Write regression tests for #156 and #157

  • Fix matchingRowIds (todo: what is the problem, already?)

  • deprecate ScopeAdapter(base, scopes), because base.addingScopes has a better implementation

  • https://github.com/groue/GRDB.swift/issues/514

  • Test NOT TESTED methods

  • Cancellation of a started ValueObservation. Context: https://github.com/groue/GRDB.swift/issues/601#issuecomment-524733140

  • Test that one can force a JOIN with association aggregates:

    // SELECT author.*, MAX(book.publishDate) AS maxBookPublishDate
    // FROM author
    // JOIN book ON book.authorId = author.id 
    // GROUP BY author.id
    Author
        .annotated(with: Author.books.max(Column("publishDate")))
        .joining(required: Author.books)
    

    It is important to have an explicit test for this technique because it is the only currently available that forces a JOIN, and we don't want to break it in the future, even if association aggregates change implementation eventually.

Documentation

Features

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