Files
GRDB.swift/TODO.md
T
2019-11-07 12:01:07 +01:00

8.3 KiB

Cleanup

Documentation

  • Document that creating "too many" ValueObservation increases database contention. This also applies to database pools, because when observations create reader contention, they also create writer contention. Context: https://github.com/groue/GRDB.swift/issues/601#issuecomment-524615772
  • Enhance the introduction to SQLRequest, based on the feedback in https://github.com/groue/GRDB.swift/issues/617
  • Association: document how to use aggregates with inner join (testAnnotatedWithHasManyDefaultMaxJoiningRequired)
  • Association: document ordered vs. non-ordered hasMany and hasManyThrough associations

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