Replies: 1 comment 3 replies
-
|
You can always cast things using the LocalAssetTaskData.Columns(
taskId: task.id,
checksum: #sql("\(asset.checksum)"),
isFavorite: #sql("\(asset.isFavorite)"),
createdAt: #sql("\(asset.createdAt)"),
updatedAt: #sql("\(asset.updatedAt)")
)You could maybe even hoist that work up to do it a single time: let asset = #sql("\(asset)", as: LocalAsset.self)
return LocalAssetTaskData.Columns(
taskId: task.id,
checksum: asset.checksum,
isFavorite: asset.isFavorite,
createdAt: asset.createdAt,
updatedAt: asset.updatedAt
) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to do something like this:
But the type inference doesn't realize that
asset.checksumisn't optional in this query, and I haven't found a way to assert this in the query builder. There are workarounds like using ?? or accepting that it's an optional and asserting it later, but it feels like there should be a better way to handle it unless I'm missing something.Edit:
asset.checksum.cast(as: String.self)makes the typing happy, but it looks to be deprecated? Is there a non-deprecated API to use for this?Beta Was this translation helpful? Give feedback.
All reactions