I have a nice #GRDB branch that simplifies the definition of SQLite requests from Swift code:
// 🙄 String-based (current state of the lib)
Player.filter(Column("score") > 1000)
// 😐 Enum-based (current state of the lib)
Player.filter(Player.Columns.score > 1000)
// 🤩 NEW
Player.filter { $0.score > 1000 }
It comes for free for record types that follow the recommended practices (i.e. define a nested `Columns` enum). 🎁
The commit that updates the demo app shows a nice win, at +9/-44 https://github.com/groue/GRDB.swift/commit/261c0ccf866029c0f65a88b881aabf46effc4f9e
The problem is that it breaks apps that define their records in packages/frameworks. The `Columns` enum must become `public` when the record type is, or the compiler won't compile it (even if its members are not public). 😖
In order to avoid the breaking change, I'll have to choose a name that is not `Columns`.
TableColumns? RecordColumns? Cols? Col? C?
In my own practice, this type sometimes contains expressions that are not columns, as below. Maybe the name should not refer to "columns", after all. TableLayout? TableComponents? SQLElements?
enum Columns {
// The date column
static let start = Column(CodingKeys.start)
// An expression derived from the date column
static let startDateUTC = SQL("date(\(Columns.start))").sqlExpression
}