Drizzle Team

DT

Drizzle Team

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

Join

Error while pushing/pulling from pg DB (supabase)

``` if (column7.column_default.endsWith("[]")) { ^ TypeError: Cannot read properties of undefined (reading 'endsWith')...

[solved] useLiveQuery seems to always run the query twice

I'm using drizzle-orm in an expo app and it seems to me (with logging turned on) every instance of useLiveQuery causes the query to happen twice in quick succession. Why is this?

NULLS LAST in orderBy

I am trying to create a query and the only way i have been able to order by with nulls last is this: ```TS const rows = await db...

[SOLVED] invalid reference to FROM-clause entry for table

Hi all, I'm trying to fetch data with some joins from a postgres db. My query looks like this:...

Manual Migrations

Guys quick question, I've migrated some of the migrations manually by running the SQL queries, how do I update the __drizzle_migrations table to match the current state? so that I can use npx drizzle-kit migrate...

Help with 'in' queries

Hi - sorry if this has been asked, but it's kind of hard to search for! If it helps, I'm using cloudflare's D1 database (sqlite). What I'd like to do is the following query:...

Can't create relation between two tables

I'm trying to create a relation between a clients table and a sheets tables where a client can have multiple sheets linked to their ID, but I keep getting complaints about incompatible foreign keys due to my bad schema Fixed; for anyone wondering, instead of using references(() => clients.id) very shallowly you have to create proper relations like such: ```ts...

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './connect' is not defined by "exports"

Hi, i have a strange error. I installed sqlite and drizzle, but cannot make drizzle work. I have this strange error....

Extend/omit from table schema.

Let's say I have this schema. ```ts export const users = pgTable('users', { id: serial('id').primaryKey(), email: varchar('email', { length: 255 }).notNull().unique(),...

Error: ... not assignable to parameter of type SelectedFields

I am trying to build a wrapper around drizzle select and this is being hard to achieve. What do I want? I want to create a wrapper that receives a where clause and SelectedFields, but I want the type-safety in order to suggest only valid columns to the user. I have something like this: ```typescript get<TWhere>( where: SQL<TWhere>,...

transations

Greetings! I am trying to perform 2 inserts to my SQLite db, but I want that if one of the 2 fails, it will revert any changes made to it. I then decided to use a transaction. My goal is to achieve that when inserting an account, a user is then created and associated with it. But I get an error when executing this function.
No description

Help with the connection between Drizzle and Supabase

Good afternoon!! Could anyone help me with the connection between Drizzle and Supabase in a Remix application? I'm having trouble getting it to work.
Thanks in advance!...

reusing placeholders

Is it possible to reuse placeholders with the same value instead of passing them to the driver every time they're referenced? Simply giving them the same name doesn't seem work. Drizzle creates a separate SQL parameter for each placeholder regardless. Example...

Error with drizzle-kit push

`node:internal/modules/cjs/loader:1251 throw err; ^ Error: Cannot find module 'drizzle-orm/casing'...

How to use sub query or CTE inside values method of insert?

I want to the results from CTE or sub query inside the select ``` const tableOneSubQuery = db.select({name: tableOne.columnOne}).from(tableOne).as('table_one_sub_query'); ...

many to many relation to same table with one relation field

I would like to depict the following scenario. There is a table “Avatars” which has a relation “Friends” that refers to itself, i.e. the table “Avatars”. Something like that: ```js...

Error when running migrations in newest drizzle-kit

When running a migration (drizzle-kit generate), I'm getting the following error: "(0 , import_pg_core.isPgSequence) is not a function" I'm using drizzle-orm 0.34.1 and drizzle-kit 0.24.0. ...

Need help migrating from "reference" declarations to "foreignKeys"

I'm doing some refactoring on our codebase (to eliminate circular dependencies) One of the main culprits is the <name>.table.ts files we have defined for our schema. I want to avoid generating unnecessary migrations, so was trying to use the same names that were automatically assigned for the references....

Can i share drizzle transaction with knex.js's transaction (postgresql)

If i can do this, i'm able to gradually migrate from knex.js