warflash
warflash
Explore posts from servers
DTDrizzle Team
Created by warflash on 5/6/2024 in #help
`null` is not assignable to nullable string column?
No description
3 replies
DTDrizzle Team
Created by warflash on 2/9/2024 in #help
Custom Logic in Upsert/Insert on conflict
Hey everyone! I'm looking for ideas on how the following could be implemented using drizzle:
INSERT INTO my_table (id, language, name, data, updated_at)
VALUES ($1, $2, $3, $4, NOW())
ON CONFLICT (id, language) DO UPDATE
SET
name = EXCLUDED.name,
data = EXCLUDED.data,
updated_at = CASE
WHEN (my_table.name IS DISTINCT FROM EXCLUDED.name OR
my_table.data IS DISTINCT FROM EXCLUDED.data) THEN NOW()
ELSE my_table.updated_at
END
WHERE my_table.name IS DISTINCT FROM EXCLUDED.name OR
my_table.data IS DISTINCT FROM EXCLUDED.data;
INSERT INTO my_table (id, language, name, data, updated_at)
VALUES ($1, $2, $3, $4, NOW())
ON CONFLICT (id, language) DO UPDATE
SET
name = EXCLUDED.name,
data = EXCLUDED.data,
updated_at = CASE
WHEN (my_table.name IS DISTINCT FROM EXCLUDED.name OR
my_table.data IS DISTINCT FROM EXCLUDED.data) THEN NOW()
ELSE my_table.updated_at
END
WHERE my_table.name IS DISTINCT FROM EXCLUDED.name OR
my_table.data IS DISTINCT FROM EXCLUDED.data;
I need to check whether the inserted data differs to the existing data by comparing them using IS DISTINCT FROM. Appreciate any suggestion with how that could be done using insert().values().onConflictDoUpdate() that drizzle provides. Thanks!
3 replies
DTDrizzle Team
Created by warflash on 6/10/2023 in #help
Custom Function to Transform Subqueries is missing types
👋 So I am trying to write helper functions that are able to transform subqueries. The goal is to work around not having access either RPC's nor subqueries in select statements. A bit more context in this discussion: https://discord.com/channels/1043890932593987624/1085153354340114563/1116875363193192470 However using something like
function transformWithSubquery<T extends WithSubqueryWithSelection<ColumnsSelection, string>>(subquery: T) {
// do magic things
function transformWithSubquery<T extends WithSubqueryWithSelection<ColumnsSelection, string>>(subquery: T) {
// do magic things
doesn't seem to do the trick to actually work with subqueries as the types are hidden from what I can tell: https://github.com/drizzle-team/drizzle-orm/blob/1c9d63bd689e6b8b6a6abf3db1ec32ab6cf179ac/drizzle-orm/src/subquery.ts#L9 Would appreciate any insight, I've been stuck with this for the entire week now and it's starting to block a lot of other things on the team - thank you!
1 replies
DTDrizzle Team
Created by warflash on 5/5/2023 in #help
TS query types dont match + no return types
7 replies
DTDrizzle Team
Created by warflash on 5/3/2023 in #help
Tables are not being generated
6 replies