Drizzle Team

DT

Drizzle Team

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

Join

Drizzle-zod combined with regular zod? 🙃

So I have a drizzle-zod schema for the server, and a regular zod rich schema for client side validation. Does anyone have a way to merge regular zod with drizzle-zod for the strictest type to use on my server? If not I don't see much point in drizzle-zod. Since I might as well just use my regular zod for types....

What are the possible ways to prevent race conditions in this postgres insert operation?

Here are typescript types for instructions and sections database tables: ```ts type Instruction = { body: string; id: string;...

Mapping Query Builder Results to Nested Objects in Drizzle

I'm transitioning to Drizzle ORM from a NestJS-TypeORM background : TypeORM: Both the repository and query builder return similar structured results, making it easy to work with joined data. Drizzle: db.query() returns nicely structured nested data (e.g., users and their posts grouped together)....

There is not enough information to infer relation

Error: There is not enough information to infer relation "public.AttractivePointTable.userToAttractive" at https://local.drizzle.studio/index.js:14459:1815 at async VKl (https://local.drizzle.studio/index.js:14459:2818) Hi, I have no idea where error come out.. anyone help?...

Is there a way to force a text field to be certain values?

I want a certain column to be one of three values, “Entered”, “Committed”, and “Withdrawn”. Is there a way to do that at the DB level with drizzle?

Enum Error When Push

``` D:\projects\wildcard\icc2>npx drizzle-kit push
No config path provided, using default 'drizzle.config.ts' Reading config file 'D:\projects\wildcard\icc2\drizzle.config.ts'...

Get type of raw sql record

I want to use Supabase webhooks (https://supabase.com/docs/guides/database/webhooks) but I'm struggling to type the payloads. Is there a way to access the raw sql record type from a drizzle schema, before renaming? i.e. if my schema is {firstName: text("first_name").notNull()} the type would be {first_name: string}....

How to store/query multi-line text in database?

Hey there! I'm currently having some problems storing (or querying; actually not quite sure where the problem lies) multi-line texts in my MySQL database using Drizzle. When I use drizzle or drizzle studio to write a string like "Hello\nWorld!" to the database and then query it, it comes back with all \ns escaped. ...

question/problem about new drizzle-seed

Hey, I was having a play around with the new drizzle-seed package with a project and couldn't seem to get it to work properly. I get no output on the console and as far as I can see using a debugger it ends up in a infinite loop on the method getOrderedTablesList() of the SeedService class. I have about 24 tables so nothing crazy in terms of requirements. Is there a requirement to define the "drizzle relations" for it to work? I removed all of those a while ago and have stuck to using the db.select() function for all queries as I find it easier. If so maybe this should be included in the docs. PS: I forgot to mention, the package looks great otherwise, good job!...

How to types and parsing with raw sql

So I'm having to fall back to raw sql for a slightly gnarly query I'm doing. What's the best way to make typescript happy, and get things like dates parsed properly? Do I want something like mapWith? That seems to only be for a single value.....

Import problem with drizzle-kit generate

I'm migrating from TypeORM to Drizzle in my Node.js project to manage player data, but I'm facing an issue. I have created schemas in a folder to manage all of them, for example, core/schemas/*.schema.ts. Some schemas need to use interfaces or types from my project or platform node modules. For example, I created a custom type for Vector3 from alt-server as follows: Custom type code: ```import { Vector3 } from 'alt-server';...

Why Isn't RLS Working with Drizzle and Supabase?

Hi everyone, When I enable the new RLS (Row-Level Security) feature on Drizzle and Supabase and migrate, I can see it applied, but it doesn't seem to work as expected. Unfortunately, all data is still accessible, even though the default behavior should block access if no policies are defined. Do I need to write some specific queries with Drizzle for RLS to function properly?...
No description

Unable to create a check constraint for NaN values

I am working to prevent any chance of NaN from being inserted into my DB, so I created a check constraint that looks like the following: (table) => [ check("fancy_check_name", sql${table.amount} <> NaN),...

How to fix collision / race condition

Hey there. I am working on a project with another team member. We are using Drizzle ORM. I merged the code of my team mate to my branch and when I trying to generate a new migration, I am getting this error:...

Passing transaction to functions

Hey everyone. Quite new to the drizzle sphere. Coming from Go, i am quite used to passing db transactions from function to function, to be able to orchestrate a bigger function from smaller ones. As an example, say i have some music track. each track can have multiple genres, and each genre could be associated with different tracks - a many-to-many relationship. Essentially, i would love to be able to create this chain of functions:...

Switched to Neon Websockets but now some queries are timing out

Hi everyone, I was using transactions for a specific query (needed all of them to cancel if one failed for a form builder). So I followed this tutorial to switch from Neon HTTP to Neon Websockets: https://orm.drizzle.team/docs/connect-neon But now I'm seeing that other queries are extremely slow & some are even failing (see attached screenshot)...
No description

Drizzle Kit

Im using neon driver and i'm getting some wierd errors when migrating or pushing changes

TSC build error

When i try to build my package with tsc, I get 71 errors, all of which look like this:
../../../node_modules/drizzle-orm/sqlite-core/utils.d.cts:25:56 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.ts")' call instead.

25 query: TExisting extends true ? undefined : import("../index.ts").SQL<unknown>;
../../../node_modules/drizzle-orm/sqlite-core/utils.d.cts:25:56 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.ts")' call instead.

25 query: TExisting extends true ? undefined : import("../index.ts").SQL<unknown>;
```Found 71 errors in 24 files....

There's no drizzle-orm/connect anymore?

I'm on the latest vestion and I'm seeing this. I thought it was release on 0.34?
No description

Greater than comparisons with timestamp mode string

I'm getting type errors with the gte comparison operator on a timestamp column that has a mode of string. The mode should only affect the output data type of queries, not the type in the DB right?