Ben-xD
Ben-xD
Explore posts from servers
DTDrizzle Team
Created by tc on 11/6/2023 in #help
drizzle-zod with custom types
5 replies
DTDrizzle Team
Created by tc on 11/6/2023 in #help
drizzle-zod with custom types
5 replies
DTDrizzle Team
Created by tc on 11/6/2023 in #help
drizzle-zod with custom types
I've got a highly related problem, if you don't mind 🙂 I'm using a custom type (e.g. citext), but drizzle-zod will return that field as unknown instead of string. Does anyone know why?
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string }>({
dataType() {
return "citext";
},
});
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string }>({
dataType() {
return "citext";
},
});
5 replies
DTDrizzle Team
Created by Ben-xD on 7/29/2024 in #help
How to convert filters (e.g. eq(), ne(), lte(), like()) into SQL string, for use in sql.raw()
ahh i know why that happens. Basically, the filter queryParams.startTime is sometimes undefined: it's number | undefined. I just need to use sql a bit better
5 replies
DTDrizzle Team
Created by Ben-xD on 7/29/2024 in #help
How to convert filters (e.g. eq(), ne(), lte(), like()) into SQL string, for use in sql.raw()
I tried sql too, but it errors with error: syntax error at or near ")"
const query = db.select().from(user).innerJoin(message, eq(user.id, message.userId))
.where(sql`
message.received_at = (
SELECT MIN(received_at)
FROM message
WHERE message.user_id = user.id
AND message.received_at >= ${queryParams.startTime}
AND message.received_at <= ${queryParams.endTime}
)
`).orderBy(desc(message.receivedAtS));
const query = db.select().from(user).innerJoin(message, eq(user.id, message.userId))
.where(sql`
message.received_at = (
SELECT MIN(received_at)
FROM message
WHERE message.user_id = user.id
AND message.received_at >= ${queryParams.startTime}
AND message.received_at <= ${queryParams.endTime}
)
`).orderBy(desc(message.receivedAtS));
5 replies
DTDrizzle Team
Created by Ben-xD on 7/29/2024 in #help
How to convert filters (e.g. eq(), ne(), lte(), like()) into SQL string, for use in sql.raw()
This gets me halfway there: https://orm.drizzle.team/docs/sql#convert-sql-to-string-and-params But the problem is the params I passed into the filters (e.g. eq(user.id, userId)) is not added to the string.
5 replies
DTDrizzle Team
Created by hugo on 11/16/2023 in #help
Unable to generate migration for sqlite
I see the same thing, I think pg is now accidentally required for drizzle, even for sqlite projects? Edit: updating dependencies fixed it, though migration files are empty
7 replies