Hi,
I'm querying the database on a unique index:
extension DerivableRequest where RowDecoder == Aperture {
func identicalAperture(as aperture: Aperture) -> Self {
filter(key: ["code": aperture.code,
<a whole list>
"flashText": aperture.flashText])
}
}
I get the following error when GRDB tries to make it into a query: Fatal error: could not convert database value NULL to String (column:
name, column index: 2, row: [seqno:0 cid:-2 name:NULL])
All properties of the type are optionals, and many of them are in fact nil
during the query.
The unique index is created as follows:
try db.execute(sql: "CREATE UNIQUE INDEX \"uniqueAperture\" ON \"aperture\"
(IFNULL(code,255) AS code, <a whole list of IFNULL()>,
IFNULL(flashText,255))")
I could not find a GRDB way of creating this unique index and I have a feeling that the IFNULL()
calls are the problem here.
How can I make this query work?
Thanks in advance.
Kind regards,
Remco Poelstra