lorentz
lorentz
KKysely
Created by lorentz on 9/12/2024 in #help
how to union two queries with json_build_object?
i would like to union two queries to get a result of type QueryA | QueryB. this query fails the type checker but the generated query seems to work as intended. is there a type hint i can provide somehow? https://kyse.link/2TBLF
10 replies
KKysely
Created by lorentz on 8/5/2024 in #help
how to decode a point to `{x: number, y: number}` when selected inside `jsonBuildObject`?
when i select a column of type point the basic way i get it decoded to {x: number, y: number}, but when i wrap it in jsonBuildObject i get it as the raw string. example:
const query = db
.selectFrom('event')
.select((eb) => [
'event.location',
jsonBuildObject({
location: eb.ref('event.location'),
}).as('wrapperObject'),
]);
const query = db
.selectFrom('event')
.select((eb) => [
'event.location',
jsonBuildObject({
location: eb.ref('event.location'),
}).as('wrapperObject'),
]);
[
{
"location": {
"x": 4.9,
"y": 52.378
},
"wrapperObject": {
"location": "(4.9,52.378)"
}
}
]
[
{
"location": {
"x": 4.9,
"y": 52.378
},
"wrapperObject": {
"location": "(4.9,52.378)"
}
}
]
12 replies
KKysely
Created by lorentz on 5/22/2024 in #help
are conditional CTEs possible?
i don't find any hints here https://kysely.dev/docs/category/cte. i have tried the conditional where approach (https://kysely.dev/docs/examples/WHERE/conditional-where-calls), but i get type error Type 'QueryCreatorWithCommonTableExpression ... The types returned by 'with(...)' are incompatible between these types.
5 replies