lorentz
lorentz
KKysely
Created by lorentz on 4/16/2025 in #help
Using AsyncLocalStorage to Propagate Transaction Context
thank you! i will explore these
9 replies
KKysely
Created by lorentz on 4/16/2025 in #help
Using AsyncLocalStorage to Propagate Transaction Context
yeah, alright 😦 thanks for responding, and thank you for an amazing library. our broader problem is that we accumulated a substantial collection of queries that we combine in various ways as subqueries, which works really really well so far. it's working better than any other db lib ive worked with ⭐ the only issue now is that we have an increasing need to wrap queries in transactions, and the code change to transform all queries to functions taking an optional transaction would be significant. so far those are the only two options i've thought of: 1. wrapping in functions with optional transaction argument 2. use AsyncLocalStorage are there any other approaches to this problem im not thinking of?
9 replies
KKysely
Created by lorentz on 2/4/2025 in #help
postgres helper wrapping to_json referencing CTE?
(tried to mark βœ… but getting The application did not respond)
8 replies
KKysely
Created by lorentz on 2/4/2025 in #help
postgres helper wrapping to_json referencing CTE?
amazing! thank you so much. so much simpler ☺️
8 replies
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