Drizzle Team

DT

Drizzle Team

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

Join

Unwanted db.execute() behavior; trying to pass in an array instead of a record or its singular

When trying to pass an array (ex. number[], bigint[], string[]) that contains only one element into sql``​, it will be transformed into their non-list type (ex. number, bigint, string respectively). When I put two elements in, it then turns into a Postgres record, which is not what I want. What I expect is that the array stays an array. ...

TypeError: client.unsafe is not a function

I was attempting to run tests in a different monorepo folder (my trpc folder) than my core folder where drizzle is and ran into this . I am spinning up temp docker containers. It works in my core folder just fine but I can't figure out why i am getting this issue. Perhaps a drizzle bug? ```ts...
No description

What is the purpose of the _meta directory?

I am currently looking into using drizzle-kit for migrations and was wondering what the _meta directory does. Currently this part of the migration workflow is undocumented leaving several questions unanswered. Initially I tried to inspect the code myself and find out what it is used alas the source code of drizzle-kit is still not available (https://github.com/drizzle-team/drizzle-orm/issues/580). Currently I wonder if it has to be checked in to git, and under what circumstances it is required to read from as well as write to this directory. This would influence how drizzle migrations can/will be deployed on production: Does it have to be part of the deployed code, can it be non-existent, is it only needed for ephemeral data or does it have to persist data (i.e. in docker this would have to be a mounted volume), is it sufficient to only read from there (i.e. in docker this would allow increased security by marking the filesystem as readonly) etc... https://github.com/drizzle-team/drizzle-kit-mirror/issues/196...

`tablesFilter` cli arg "unknown option"

from the 'help' message
--tablesFilter Table name filters
--tablesFilter Table name filters
...

[BUG] Multi schema tables with same name

I have two tables with the same name in two different schemas. Drizzle seem to not take into account the schema when generating the SQL, and it generates only one of the two tables. This heavily brakes a lot of functionality

many-to-may relation

How do i define relation like a post probably has many comments that nested, for example a person can reply to other person's comment, ``` export const comments = mysqlTable( 'comments',{ id: serial('id').primaryKey(),...

Responses are coming back with Capitalized table names

When I run queries and joins, my table names are coming back with uppercase table names which breaks my models and UI that has existed with lowercase further down the chain. Any way to force everything to be lowercase? For example: ``` [...

TypeError: Seems like the schema generic is missing - did you forget to add it to your DB type?

How can I solve the following generic error relating to the db.query.users in my code below? ```bash Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?"> | { [x: string]:RelationalQueryBuilder<ExtractTablesWithRelations<any>, { ...; }>; }'. Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?">'.ts(2339)...

Can I create tables at runtime?

Is it possible to create a user-specific schema and then generate tables within that schema when a user signs up?

Execute is not exist on a type LibSQLDatabase

const url = env.TURSO_DB_URL if (url === undefined) { throw new Error('TURSO_DB_URL is not defined'); } ...

Transactions, PgBouncer/Supavisor, prepared statements

okay... i have spent way to long trying to figure out why when using transactions and a pooler on transaction mode it causes the connection to reset mid transaction statement causing a prepared statement 'name' does not exist which was very hard to debug. still don't fully understand why transaction won't work i've tried everything i could find setting params binary_parameters=yes (not even sure what this does, resetting database server (supabase). using a direct connection worked but wasn't something i could do forever. so my fix was.... just remove transactions from my endpoints (which sucks but it is what it is) ...

how enable wal for sqlite with drizzle ?

how enable wal for sqlite with drizzle ?

Simple ForeignKey With statement not working

Hi - I am attempting to use a with statement on a query and am getting this error: Cannot read properties of undefined (reading 'referencedTable') Here's the query: ``` await db.query.faves.findMany({...

MySQL UUID as PK

I am unable to get a PK setup which has a default UUID value. I have ```ts...

totalCount from relational query

is it somehow possible to get the total count of a relational query? Core queries aren't possible here due to a bug in how drizzle builds the column identifiers (multiple columns have the same name here and duplicates are discarded, resulting in undefined values) I thought maybe I could utilize CTEs here but then how would I get the benefit of relational queries?...

Cannot read properties of undefined (reading \'columns\')

I tired using relational queries ` const bookmarkdb = drizzle(pool, { schema }); const resources = await bookmarkdb.query.bookmark.findFirst({...

Does Drizzle support Microsoft SQL Server?

Does Drizzle support Microsoft SQL Server ?

Findfirst and Findmany config

Hello I am new to using drizzle and can't seem to make the findFirst and findMany work. I am using postgress here's the code for my connection :
No description

Trouble running JEST testing in Hono for Cloudfare Workers

So, I have an API setup in Hono with cloudfare workers and I setup the JEST tests but they don't seem to inject the D1 DB into the context environment so I can use it to init the DB and perform the associated request actions. I am trying to just do this locally. What am I doing wrong? I'm kinda new so any help would be much appreciated. The test just sends requests to the server, do I have to manually add the DB to the context so Drizzle ORM can be initialized or something else. Sorry, if I'm no...