Drizzle Team

DT

Drizzle Team

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

Join

Is there a way to get typed results from executing a function on Postgres?

I have a function, get_widgets that returns rows. The default signature for rows returned is Record<string, unknown>[] Is there a way to specify the row type without having to cast to unknown first? ``` interface Widget { id: number...

Are there any array size limitations for "inArray" filter method?

Are there are any such limits, either in MySQL or DrizzleORM itself?

Uuid always the same with Bun randomUUIDv7() (?)

Hey there I'm working on a sqlite db and have this table: const session = sqliteTable("session", { id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }), ipAddress: text("ip_address").notNull(),...

{mode: "json"} sqlite/libs sql does nothing

The types are reflected correctly, but no actual parsing stringifying seems to occur ``` "dependencies": { "@jitl/quickjs-wasmfile-release-sync": "^0.31.0",...

COALESCE to json array not working in sql function

I am using the sql operator in a postgres db and when I try to coalesece to an empty array it doesn't work as expected. It returns null. This is how I am doing it. Is it wrong? ``typescript const productItemsImagesSQLAgg = sql<ProductItemImages[]> COALESCE(...

How to access a db from linux

i'm using dirzzle on linux, how can i access the db?

migrate using Bun SQL api

Hey, rookie here! i'm testing bun 1.2.1 using drizzle, and I want to use SQL api for migrate schemas, how can I use it in drizzle.config.ts? do I have to create the migrate command? ps. I'm using it for querys but dont get it in config...

[Solved] Drizzle Studio blocked by CORS, mkcert "no security databases found"

Running Linux Mint 21.3, tried using my daily driver Flatpak ungoogled-chromium as well as apt Firefox (pre-installed on Mint).
# mkcert --install
The local CA is already installed in the system trust store! 👍
ERROR: no Firefox and/or Chrome/Chromium security databases found
# mkcert --install
The local CA is already installed in the system trust store! 👍
ERROR: no Firefox and/or Chrome/Chromium security databases found
...

Tightening types on successful insert to not be `object | undefined`

When doing db.insert(someTable).values(someValues).returning() what would be the preferred way to narrow the type of the return value from object | undefined if the insert is successful? I'm trying to do some seeding where I create some entries in one table and save them as variables, and then attempt to insert the IDs of those entries into another table as a foreign key that's non-nullable and TS tells me that they're potentially undefined, which is true. Since this is seeding, I know I'm clearing my DB before this, so I know the inserts will succeed and that it's not an issue if they don't) so would the best way to silence these errors just be to add ! to the objects when doing returnedObject!.id? ...

Missing Refine type after update

Seem like with a recent release of drizzle-zod, we lost an exported type (namely Refine) to satisfy types in a single place. Anyone know of a better way to do this so we don't need to repeat code? And maybe any way we can export the Refine type (seems like its BuildRefine now 🤔)? ```ts import type { Refine } from 'drizzle-zod'; import { teamsTable } from '../teams-table';...

CHECK constraints not working with drizzle-orm/pg-core

Hello, I have an issue. I can't add CHECK constraints to my table. I tried with a simple example, but it's not working. Could this be a bug? I followed the code from the documentation, but the CHECK constraints aren't being applied :'( Here is my code: https://drizzle.run/m8kdhex9yw6yqaxbywunfyj4...
Code_doc

Type Inference Issue: Missing | null on Relational Fields in Drizzle ORM

When querying a company and joining related customer data, the resulting inferred TypeScript type for the customer property does not allow for null even though no record may exist. Because of this, the type inference is overly strict. In many cases, customer can be null, especially with a left join or if the relation is optional. ``ts // Query 1: Drizzle relational query // Result type incorrectly omits | undefined or | null for customer`. const res = db.query.company.findFirst({...

foreignKey function options

```ts foreignKey({ columns: [table.orgId, table.topicName], foreignColumns: [topics.orgId, topics.name], }),...

restart increment for refNumber column starting from 1

All examples I've seen increment globally for the column. I need to restart increment from 1. how would I do that? ``` export const orderItems = pgTable( "order_items",...

Neon migrations are not running in transaction

Hello, I notice that if a migration fails half way through, what ever commands happened before are being saved? Is this a bug?

Bad Field Error

I have a view that I created that joins two table. here is my implementation : ```ts export const cartView = mysqlView("carts_and_products").as((qb) => { return qb .select({...

Do all migration files get executed in single transaction?

Lets say I generated a couple migration files due to making a few changes. When the migrations run via drizzle-kit migrate, will both of the files run in a single transaction, or could 1 file run > commit > then the second file fail? This is for Neon, if that matters....

transactions rollback

Hi there! Do Drizzle transactions automatically roll back when an unexpected error occurs?

Error: getaddrinfo ENOTFOUND ep-delicate-thunder-a58xbwga.us-east-2.aws.neon.tech

I am only able to generate the migrations npx drizzle-kit generate but not able to migrate it npx drizzle-kit migrate or npx drizzle-kit studio when I am trying to open up the drizzle studio or run migrations, I am getting this error please find attachments. don't know from where it's coming, my internet is working fine...
Solution:
Seems like a Neon issue
No description