Drizzle Team

DT

Drizzle Team

The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!

Join

`db.$count` with extras throws error when correlating with outer table

Hi! I'm trying to use .extras() with db.query.orderTable.findMany() to get the count of related orderItemTable rows like this: ```ts const orders = await db.query.orderTable.findMany({ extras: (t) => ({ itemCount: db.$count(orderItemTable, eq(orderItemTable.orderId, t.id)),...

Why does drizzle-zod refinements overwrite the nullability of the field?

I was previously on v0.5.1 and I could provide a typeOverrides object that specifies all the schemas that should be applied to createInsertSchema and createSelectSchema. Depending on the schema, the override would be applied and then the nullability of the column would be applied on top of the refinement. After upgrading to 0.8.2, it seems this is no longer the case and the website documentation even states it explicitly: https://orm.drizzle.team/docs/zod#refinements In the example on the site, preferences is a nullable json field. The way this example overwrites the nullability, you can easily insert null values into the preferences field but using the userSelectSchema to parse data coming out of the DB would fail....

How to refine seed data using `with` clause in drizzle seed

I have a table called workout that has a one-to-many relationship to another table called exercise (i.e one workout has many exercises associated with it). Now, when I try to seed some workouts, I want to be able to seed each workout with multiple exercises. I want to be able to refine what parameters are allowed for the nested exercises, but I see no way to do that. Here's what I have: ```javascript await seed(db, { workout, exercise }).refine((funcs) => ({ workout: {...

Drizzle-kit keeps recreating foreign key constraints

Every time I run drizzle-kit push, it drops and recreates my foreign key constraints ``` wilson@Wilsons-MacBook-Pro joeldim % pnpm exec drizzle-kit push No config path provided, using default 'drizzle.config.ts'...

drizzle doesnt connect to GCP database string

Hello I want to connect drizzle on production to my database string which looks like this
`postgresql://postgres:${password}@localhost/${database_name}?host=/cloudsql/educate-393101:us-central1:educate-ai&connection_limit=10`
`postgresql://postgres:${password}@localhost/${database_name}?host=/cloudsql/educate-393101:us-central1:educate-ai&connection_limit=10`
and it fails...

Unable to load Drizzle Studio due to error

I started encountering a Studio error that I can't get past, as of this morning: ``` TypeError: Cannot read properties of undefined (reading 'descending') at https://local.drizzle.studio/index.js:1027:1029...

studio can not delete/update a record,

Please add a primary key column to your table to update or delete rows This message always shows up when I try to update/delete a row "drizzle-kit": "0.30.1"...
No description

#drizzle-studio Error ID: b7abbd6110e9The result contains the unsupported data type "CHAR".

Hi team, I'm encountering an error in Drizzle Studio that seems to be recurring. Here's the message I received: ``` Unexpected error happened 😕
Error ID: b7abbd6110e94f219f2e6596b88e168e
The result contains the unsupported data type "CHAR"....

Type-safe subquery in "extras" of findMany query

```ts extras: (fields) => { const subquery = db.select({ … }).from(…).where(eq(…, fields.id)) return {...

Help Drizzle-kit studio

ID: adde822a6785455ab2c69b6704b6b036
No description

Studio stopped working after update to latest stable versions of kit and ORM

I'm on the latest stable versions: "drizzle-orm": "^0.44.2" "drizzle-kit": "0.31.2" ...
No description

Issue with Drizzle Kit

"devDependencies": {
"drizzle-kit": "^0.31.2"
},
"devDependencies": {
"drizzle-kit": "^0.31.2"
},
...
No description

how to get type bigint return type "number | undefined" in schema ?

my schema looks like this: export const buckets = pgTable('buckets', { ... allowed_size_limit: bigint(mode{:number}).notNull() // returns "number"...

Update with CTE

I am running complex update in SQL, which requires additional context previously i built it with UPDATE .. SET .. FROM .. WHERE .. now i tried to change to WITH .. UPDATE .. SET .. WHERE .. by following the example provided in drizzle docs (https://orm.drizzle.team/docs/update#with-update-clause) it shows the error of missing FROM-clause entry for table [CTE name here] may I know if it requires FROM keyword like original query, or without it will works too?...

Types don't infer correctly for tables with`references` method?

I'm using Drizzle with Expo SQLite in an Expo managed app. On my schema all of the tables that contain simple column data, i.e. primitive types like text or int, get typed correctly. Any time I create an association with the references method the generated type becomes { [x: string]: any }. I'm using: - Expo SDK: 51 - Expo SQLite: 14.0.6...

Why does the same query not work using `select`?

I'm using SQLite and the "tags" field is a json data type. This the following works fine: ```ts...

How to use a prepared query inside a transaction?

I have a prepared query like this: ```ts const userAddressBookQuery = db.query.userAddressTable .findMany({ where: (fields) => eq(fields.userId, sql.placeholder('userId')),...

CloudflareSocket is not a constructor

Hey guys, does anyone had this issue before? I start getting that today, after some debugging and testing with different versions of drizzle and pg libs didn't manage to sovle that problem
No description

Schema that needs to joins twice from the same schema

Right now I have a schema that is like this: ```js export const games = sqliteTable("games", { id: text().primaryKey().$defaultFn(v4), redTeamId: text().references(() => teamScores.id),...
No description