lorentz
lorentz
KKysely
Created by lorentz on 9/12/2024 in #help
how to union two queries with json_build_object?
ok i think i have something https://kyse.link/xpMTf. perhaps not ideal, but works. thank you very much for the help!
10 replies
KKysely
Created by lorentz on 9/12/2024 in #help
how to union two queries with json_build_object?
ah ok! 🙇 so this in full https://kyse.link/CtZGS. now i realize what i need is really a discriminated union type though, so something closer to this https://kyse.link/4Zw87. the result gets the correct type now
const rows: ({
id: number;
type: "person";
details: {
first_name: string;
};
} | {
id: number;
type: "pet";
details: {
name: string;
};
})[]
const rows: ({
id: number;
type: "person";
details: {
first_name: string;
};
} | {
id: number;
type: "pet";
details: {
name: string;
};
})[]
but then back to Types of property 'details' are incompatible. where union is not happy. is there any way to just convince the union that all is good? 😄 don't mind explicitly casting anything at this point
10 replies
KKysely
Created by lorentz on 9/12/2024 in #help
how to union two queries with json_build_object?
alright thanks. so there is no way to make kysely type the whole result to this?
({
id: number;
details: {
first_name: string;
};
} | {
id: number;
details: {
name: string;
};
})[]
({
id: number;
details: {
first_name: string;
};
} | {
id: number;
details: {
name: string;
};
})[]
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`?
ah ok, thanks! in my case the point column is nullable, making it more complicated i guess 🤔 if i were to do it in js-land instead, is a plugin with transformResult a reasonable approach?
12 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`?
i fail to find the source code for where the point decoding is done in the basic select case
12 replies
KKysely
Created by lorentz on 5/22/2024 in #help
are conditional CTEs possible?
thx! and good suggestion. i shall try to figure it out 👍
5 replies