You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Table("item")
struct Item: Codable, Hashable, Identifiable {
let id: UUID
var name: String
}
@Table("object_relate")
struct ObjectRelate: Codable, Hashable, Identifiable {
let id: UUID
var objectId: String?
var attribue: String
}
My actual scheme is more complex than the example. objectId could be Item.id.uuidString, or it could be the string id of a network API object. Now I want to get the ObjectRelate associated with Item, but using the following statement results in an error:
Cannot convert value of type 'CoalesceFunction<TableColumn<ObjectRelate.TableColumns.QueryValue, String?>.QueryValue.Wrapped>' (aka 'CoalesceFunction<TableColumn<ObjectRelate, Optional<String>>.QueryValue.Wrapped>') to expected argument type 'String'
let result = try await database.read { db in
try Item
.where({ $0.id == id })
.leftJoin(ObjectRelate.all) { $0.id == UUID(uuidString: $1.objectId ?? "") }
.fetchAll(db)
}
I tried the following statement and it doesn't give an error, but I can't get the ObjectRelate data.:
let result = try await database.read { db in
try Item
.where({ $0.id == id })
.leftJoin(ObjectRelate.all) { $0.id == #sql("\($1.objectId)") }
.fetchAll(db)
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
My actual scheme is more complex than the example. objectId could be
Item.id.uuidString, or it could be the string id of a network API object. Now I want to get the ObjectRelate associated with Item, but using the following statement results in an error:I tried the following statement and it doesn't give an error, but I can't get the ObjectRelate data.:
Is there a way to solve this?
Beta Was this translation helpful? Give feedback.
All reactions