Dan Claroni
Dan Claroni
Explore posts from servers
DTDrizzle Team
Created by Lloyd on 6/11/2024 in #help
Top-level await in drizzle.config.ts
there isnt a way you know of to get migrate to work with top-level await is there? e.g. a patch to drizzle?
13 replies
DTDrizzle Team
Created by Lloyd on 6/11/2024 in #help
Top-level await in drizzle.config.ts
ah gotcha. I'm using SST and secrets make that more difficult to do. I suppose I can pass it in as an env var as well?
13 replies
DTDrizzle Team
Created by Lloyd on 6/11/2024 in #help
Top-level await in drizzle.config.ts
do you have a workaround
13 replies
DTDrizzle Team
Created by Lloyd on 6/11/2024 in #help
Top-level await in drizzle.config.ts
is there any update on this? I'm struggling with the same thing
13 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
Thank you!
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
@alexblokh @Andrew Sherman any ideas on this?
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
@Sillvva I got around to trying this today and it doenst work. you have to specify either db.select or db.with(sq).select for the right side of the union. Either way, drizzle wraps the entire left side in its own parens and the entire right side in its own parens, so the CTE is scoped within the parens. I tried using a query builder object too, but same issue
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
does that query you posted work for you just fine?
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
it's wrapping everything up until the union in parens
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
PostgresError: relation "usersSubQuery" does not exist
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
const usersSubQuery = db
.$with(usersSubQueryName)
.as(getUsersWithPrefsQuery());

const prefsSubQuery = getPrefsQuery(usersSubQuery); // uses db.with(usersSubQuery)

const recurringPrefsSubQuery = getRecurringPrefsQuery( // doesnt use db.with(usersSubQuery), but does use usersSubQuery in the from block
usersSubQuery,
);

const rows = await prefsSubQuery
.union(recurringPrefsSubQuery)
const usersSubQuery = db
.$with(usersSubQueryName)
.as(getUsersWithPrefsQuery());

const prefsSubQuery = getPrefsQuery(usersSubQuery); // uses db.with(usersSubQuery)

const recurringPrefsSubQuery = getRecurringPrefsQuery( // doesnt use db.with(usersSubQuery), but does use usersSubQuery in the from block
usersSubQuery,
);

const rows = await prefsSubQuery
.union(recurringPrefsSubQuery)
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
@Sillvva that query in the Union block throws an error that it doesn’t know about the usersSubQuery
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
i opened a GH issue with it, since I dont think this is possible https://github.com/drizzle-team/drizzle-orm/issues/2230
16 replies
DTDrizzle Team
Created by Dan Claroni on 4/27/2024 in #help
using unions with "with" clause
i'd like to do something like await db.with(usersSubQuery).union(prefsSubQuery, recurringPrefsSubQuery);
16 replies
DTDrizzle Team
Created by beneidel on 7/15/2023 in #help
"Cannot parse date or time" using AWS Data API, aurora postgres
The problem appears to be in drizzle-orm/pg-core/columns/timestamp.js. The offending code is:
mapToDriverValue = (value) => {
return this.withTimezone ? value.toUTCString() : value.toISOString();
};
mapToDriverValue = (value) => {
return this.withTimezone ? value.toUTCString() : value.toISOString();
};
the toUTCString() doesnt work for the data api, so I am going to make a patch where I just always congvert it to an ISO string. I'm assuming this has other implications for other drivers, but I don't know enough about that
17 replies
DTDrizzle Team
Created by beneidel on 7/15/2023 in #help
"Cannot parse date or time" using AWS Data API, aurora postgres
I’m not sure I want to remove the with timestamp. It appears drizzle is setup to convert date objects to ISO strings and then replace the T and the Z but for me it’s just using toString and still replacing the T, which you see when the T in Thurs is replaced with a space
17 replies
DTDrizzle Team
Created by beneidel on 7/15/2023 in #help
"Cannot parse date or time" using AWS Data API, aurora postgres
BadRequestException: Cannot parse date or time " hu, 22 Feb 2024 12:20:00 GMT"
17 replies
DTDrizzle Team
Created by beneidel on 7/15/2023 in #help
"Cannot parse date or time" using AWS Data API, aurora postgres
this was working for me for a while, but now this same issue appears to exist with between query filters when the value is a date object and when inserting again:
return await db.query.table.findMany({
where: (table, { eq, between }) =>
and(
eq(table.fkId, fkId),
between(table.time, startDate, endDate),
),
});
return await db.query.table.findMany({
where: (table, { eq, between }) =>
and(
eq(table.fkId, fkId),
between(table.time, startDate, endDate),
),
});
export const upsert = async (itemToUpsert: NewItem[]) => {
const upserted = await db
.insert(table)
.values(itemToUpsert)
.returning();

return upserted;
};
export const upsert = async (itemToUpsert: NewItem[]) => {
const upserted = await db
.insert(table)
.values(itemToUpsert)
.returning();

return upserted;
};
i'm using a pg table with the following column: time: timestamp('time', { mode: 'date', withTimezone: true }).notNull(),
17 replies
DTDrizzle Team
Created by Vinny on 2/18/2024 in #help
How can I make my Postgres schema automatically insert `UTC` time when using `defaultNow()`?
try adding { mode: 'date', withTimezone: true } to the timestamp column config (second arg after column name) to set timezone
4 replies