I'm trying to fetch a simple record with an association but I'm a little unclear about how the glue code works with the decoding of the QueryInterfaceRequest.
I have a request like
let request = CalendarEntryRecord.filter(Column("id") == entryID).including(optional: CalendarEntryRecord.bookmark)
and defined a temporary struct to decode into (following the docs) like so
struct Response : Equatable, FetchableRecord, Decodable {
let entry: CalendarEntryRecord
let bookmark: CalendarEntryBookmarkRecord?
}
However, when I perform a Response.fetchAll(...
the bookmark property alway comes back as nil
.
I verified the table rows are present by using the Row.fetchAll(...
form and printing the output:
[ [id:Data(16 bytes) date:"2021-07-17 00:00:00.000" wordID:Data(16 bytes) wordDefaultForm:"noun" wordSpellingUS:"test"]
unadapted: [id:Data(16 bytes) date:"2021-07-17 00:00:00.000" wordID:Data(16 bytes) wordDefaultForm:"noun" wordSpellingUS:"test"]" id:1 entryID:Data(16 bytes) createdAt:"2021-07-17 14:26:22.791"]
- entry_bookmark: [id:1 entryID:Data(16 bytes) createdAt:"2021-07-17 14:26:22.791"]]`
I can see the entry_bookmark
is in that print output with the expected values but it's not decoding into the bookmark
property on the response, that is always nil
.
What am I doing wrong? I feel like it must have something to do with the names of the properties on Response
or involves customising CodingKeys
somehow, but I'm not sure how/exactly what is awry.
Note: The print output is abridged to exclude a bunch more properties on the CalendarEntryRecord
type.