Files
GRDB.swift/TODO.md
T
2018-04-04 09:49:38 +02:00

6.5 KiB

GRDB 3.0

  • Rename "changes tracking" (ambiguous with database observation) to "record comparison"
  • Refactor SQL generation and rowId extraction from expression on the visitor pattern. Provide more documentation for literal expressions which become the only way to extend GRDB.
  • Hide useless scheduling methods behind protocols : https://forums.swift.org/t/discouraging-protocol-methods-on-concrete-values/8737/4?u=gwendal.roue
  • Make DatabasePool.write safe. See https://github.com/groue/GRDB.swift/commit/5e3c7d9c430df606a1cccfd4983be6b50e778a5c#commitcomment-26988970
  • Do one of those two:
    1. Make save() impossible to customize: remove it from Persistable protocol, and remove performSave() from tne public API.
    2. Open Record.save(), and have RecordBox.save() forward this method to its underlying type.
  • Not sure: Make the MutablePersistable.update(_:columns:) method mutating (as support for an updatedDate column)
  • Not sure: type safety
    • Introduce some record protocol with an associated primary key type. Restrict filter(key:) methods to this type. Allow distinguishing FooId from BarId types.
    • Replace Column with TypedColumn. How to avoid code duplication (repeated types)? Keypaths?
  • Rename Request to FetchRequest, because Request is a bad name: https://github.com/swift-server/http/pull/7#issuecomment-308448528
  • Rename RowConvertible, TableMapping, MutablePersistable and Persistable so that their names contain Record: FetchableRecord, TableRecord, MutablePersistableRecord, PersistableRecord?
  • Not sure: Consider introducing RowDecodable and RowEncodable on top of FetchableRecord and MutablePersistableRecord. This would allow keeping fetching and persistence methods private in some files.
  • Drop IteratorCursor, use AnyCursor instead
  • Drop TypedRequest, have FetchRequest defaults to Row requests.
  • Rename columnCount -> numberOfColumns
  • Try to remove double Persistable/MutablePersistable protocols: Would non-mutating Record methods help?

Not sure

  • encode/decode nested records/arrays/dictionaries as JSON?

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

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

Requires recompilation of SQLite:

Reading list: