Drizzle Team

DT

Drizzle Team

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

Join

$returningId returning extra rows

Not sure if this is intended behaviour but with the mysql2 driver in drizzle-orm this:
console.log(await db.insert(table).values([row1, row2]).$returningId())
console.log(await db.insert(table).values([row1, row2]).$returningId())
Outputs...

Error when pulling from MySQL

I'm following the instructions on https://orm.drizzle.team/docs/get-started/mysql-existing and have just installed Drizzle Kit 0.25.0. However when I run yarn drizzle-kit pull, I get the following error: ``` /<path redacted>/node_modules/drizzle-kit/bin.cjs:30727 Request2 = class extends GlobalRequest { ^...

Get the count of a nested relation in findMany()

Is it currently possible to get the count of a nested relation in findMany() query? ```ts const data = await db.query.docs.findMany({ with: { articles: {...

How to `as` a table name

Hey 👋 , I have a parent query that use a table let's say A, and in this parent query it contains another query which will also use A, how in drizzle can I as the table name for the sub query ? The code would roughtly look like so:...

No overload matches call even with strict=true

Hello! I have the problem this issue describe https://github.com/drizzle-team/drizzle-orm/issues/2619 It seems that using strict=true fixes it for everyone except for me. Does someone have an idea why ? I made sure to reload my window after changing my tsconfig.json and it did make the error go away. here's my code & error, IDE highlights "id" on error. ```typescript...

Resolved: Need help with my multi column primary and foreign key table

Setup: ``` Turso / libsql, dialect is set to turso Versions: "@libsql/client": "^0.14.0"...

Edge runtime issues after upgrading drizzle-orm to v0.34.1

Hello! I am using drizzle with Next.js project that is hosted on vercel. One of the routes is using edge runtime. After upgrading from v0.33.0 to v0.34.1 I sometimes (not always) get INTERNAL_EDGE_FUNCTION_INVOCATION_FAILED from vercel when visiting that route. I create a new drizzle client for every request like this: ```ts import { Pool } from '@neondatabase/serverless'; import { drizzle } from 'drizzle-orm/neon-serverless'; const pool = new Pool({ connectionString: env.DATABASE_URL });...

Extremely weird behaviour

Apologies for the lack of better title. I have come across a weird behaviour where select().from(tablename) returns old and stale data. `...

Drizzle kit push and migrate don't match typescript schema

Hello, I'm having issues with both push and migrate commands with drizzle kit generating incorrect SQL based on my typescipt schema. Any help would be much appreciated! drizzle.config.ts ```ts import { defineConfig } from 'drizzle-kit'...
No description

bun documentation

I ended up resolving the issue myself but the documentation on bun:sqlite is pretty unclear about the fact that you have to install @libsql/client to do migrations and specifically it doesn't list that in the installation step. The error message if you don't have it installed also does not specify that installing @libsql/client will fix the issue and installing better-sqlite3 will not.

PgCore: QueryBuilder Issue

Has anyone come across this issue with QueryBuilder where if a subquery generated directly with a database connection (const connection = drizzle(client, { schema });) works but if a subquery generated with a QueryBuilder doesn't?

Subquery select without left join

Is it possible to select fields from a correlated subquery on a table without doing a LEFT JOIN? Drizzle keeps telling me that it needs to be in a JOIN, but I don't want to join.

InferSelectModel does not work with a view

I have a simple view defined as ```ts const qb = new QueryBuilder(); const ordinaryUsersQuery = qb .select({...

unable to use the `push` command

I keep getting this error. ``` adam@Adams-MacBook-Pro blackbird % pnpm drizzle-kit push No config path provided, using default 'drizzle.config.ts'...

Cant drizzle-kit pull with next.js from supabase postgres

Hello, trying to learn drizzle by connecting it to an existing supabase project (postgres), and need to pull the DB schemas into drizzle. My drizzle.config.ts: ``` import { config } from "dotenv";...

Trying to use deno...

So i'm trying to generate migrations using drizzle-kit with deno? ```bash deno run -A npm:drizzle-kit generate [22:31:46] Failed to find Response internal state key...

Cannot use pgEnum with aws aurora

Hi. I can't seem to use pgEnum with the AWS aurora adapter, as i keep getting the same error over and over. It seems weird, as intellisense doesn't say that the types are wrong at all when i am doing the update query, but pg returns an error ERROR: column "status" is of type "EmailStatus" but expression is of type text; Hint: You will need to rewrite or cast the expression.; Position: 31; SQLState: 42804 ```ts await db...

Setting Procedures and Triggers and custom SQLs

Hi. I am using drizzle with mysql in ts, I want to add functionality of procedures and trigger them after specific db calls. How to do it? and if i change something in procedure like edit/delete/add how to handle it's migration. In on case i have table and it has primary key which is autoincreement but i need to start the count from 1000, how to handle this and If I add something like this to other table after deploying my database how to handle it's migration...

mapping data inside select function

Hi. Is there no other way to map data with nested object with select() function other than array.reduce? I would like to do it using the query, not JS as the amount of data can be big and take a long time. For now I am doing this by writing a big query using sql function in execute() but then I don't get real TS support for my types and I feel uncertain about possible bugs.

db client typing

Good morning. I am using the new connect method, and working on typing. I am new to TS so still working out how to make it work. ```ts interface Client { config: Config;...