I'm working on a GRDB data model. My problem might be rooted by working on beta: Version 12.0 beta 2 (12A6163b).
I've got an intermittent error showing up in several structs. Cannot find 'CodingKeys'
shows up on a few lines in a few struct definitions. This happens after CodingKeys
has been accepted on several lines before or after the indicated line. See below for sample code.
I'm using a enum based on GRDB documentation.
My data model has 13 tables and struct definitions. This error is showing up six of the struct definitions on one or two of the lines in the Columns
enum. I cannot find any common denominator for which lines the error shows up on.
The error on the sample below, uuidCommodity is a UUID type variable, but I've also seen the error on rows with Date, String, and Int types.
Anyone else seeing this problem? Anyone have any suggestions? I filed this with Apple Feedback last night, no answers from there yet, but it is the weekend.
import Foundation
import GRDB
struct Accounts: Codable, Identifiable {
var id: UUID {
return uuidKey
}
// MARK: - GrandSync Properties
var uuidKey: UUID
var uuidUser: UUID
var uuidFamily: UUID
var dateCreated: Date
var dateModified: Date? // nil if never saved
var dateArchived: Date? // nil if never archived
var datePost: Date? // nil if not synced to Postgres
var myName: String
// MARK: - Subclass Properties
var limitCents: Int
var uuidCommodity: UUID
var uuidParent: UUID?
}
// MARK: - SQL Generation
extension Accounts: TableRecord, FetchableRecord, PersistableRecord {
static let databaseTableName = "accounts"
/// The table columns
enum Columns {
static let uuidKey = Column(CodingKeys.uuidKey)
static let uuidUser = Column(CodingKeys.uuidUser)
static let uuidFamily = Column(CodingKeys.uuidFamily)
static let dateCreated = Column(CodingKeys.dateCreated)
static let dateModified = Column(CodingKeys.dateModified)
static let dateArchived = Column(CodingKeys.dateArchived)
static let datePost = Column(CodingKeys.datePost)
static let myName = Column(CodingKeys.myName)
static let limitCents = Column(CodingKeys.limitCents)
static let uuidCommodity = Column(CodingKeys.uuidCommodity) // Error shows up on this line
static let uuidParent = Column(CodingKeys.uuidParent)
}
...
Edit: Adding an explicit CodingKeys enum made the error go away, but I still don't know why the initial error was there.
enum CodingKeys: String, CodingKey {
case uuidKey, uuidUser, uuidFamily, dateCreated, dateModified, dateArchived, datePost, myName, abrv, iCommodityType
}