Drizzle Team

DT

Drizzle Team

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

Join

Running `drizzle-kit introspect:pg` returns "client password must be a string"

I'm attempting to move from objection.js+knex.js over to Drizzle and I'm running drizzle-kit introspect:pg against my database but I'm getting the error:
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
...

noob help : transaction not acid

``` return await this.drizzle.db.transaction(async (trx) => { const u = await trx .select({ usd: users.usd,...

Explicit inferred types

```ts async loginWithGoogle(user: NonNullable<Request['user']>) { const existingUser = await this.db.query.users.findFirst({ where: eq(users.email, user.email), });...

Many-to-Many where in far table

I'm trying to findMany() Pokemon(s) by a type name ``` pokemons pokemonsToType types ======== =============== =======...

Cannot call onConflictDoNothing() or on onConflctDoUpdate() on select

Hello guys, this is probably right in front of me, but when I insert at the end of values I cannot find .onConflict, just onDuplicateKeyUpdate. Many thanks!

Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020

Hey I just upgraded to the v^0.26.2 and I get the following error: ``` Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides) ...

can you Infer relations?

im really loving how drizzle plays well with relations, but im wondering is there a way to get types for relations? in prisma you can use Prisma.YourModelGetPayload<{}> to generate a type with relations, is this possible with infermodel? i tired the most obvious way and that didnt work
InferModel<typeof userRelations>;
InferModel<typeof userRelations>;
...

subRows.map is not a function

I am getting a subRows.map is not a function error when adding the "with" parameter to my relational queries. here is my schema; ```export const users = pgTable("users", {...

Postgres's Serial column type doesn't automatically have a default

Hello, when using postgres's serial types, and setting them as primary keys, there is an issue currently that does not mark them as has default. What I mean is, from the docs The data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases), the Serial types already have a default implementation, but if you use them as is in Drizzle, they aren't regarded as having a default ``` type NewTest = InferModel<typeof test, 'insert'>; ^? type NewTest = {...

How to insert into a table without providing values

I've got the following schema for users in sqlite, it only contains an id, which is an auto incrementing primary key. ```typescript export const users = sqliteTable("users", { id: integer("id").primaryKey({ autoIncrement: true })...

Doent infer type in Callback syntax for query

Im querying the users table like this `db.query.user.findFirst({ where: (user, { eq }) => { return eq(user.email, whereArgs?.email); },...

Bug When Trying To Increment A Field

this set the field to 0 instead of increasing by one it used to work in other routes ``` await db .update(Artists)...

Maximum call stack exceeded with relation to self

I have the following table ``` export const category = pgTable('categories', { id: serial('id').primaryKey().notNull(), parentCategoryId: integer('parent_category_id').references((): AnyPgColumn => category.id)...

importing into schema.ts file

Hi, I am using turborepo and I have defined my schema in packages/schema/user.ts and in my main API application apps/api/schema.ts I import the user schema. I believe I have everything setup correctly in terms of package.json setup. My problem is that when using running migrations only tables explicitly defined in schema.ts seem to work. ...

What versions of MySQL are supported? I have JSON_ARRAYAGG issues with 5.7 and AWS Aurora Serverless

Can you confirm what versions of MySQL you intend on supporting? Relational queries with joins use JSON_ARRAYAGG which is not supported by earlier versions of 5.7 including AWS Aurora Serverless v1.

`$with` example in docs error "unsupported: with expression in select statement"

I have a user with id of 42, just like the docs https://orm.drizzle.team/docs/crud#with-clause but executing the same query throws an Error: unsupported: with expression in select statement ```ts const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)))...

Infer type for relational query

Is there anyway to infer the type of a relational queries result? For example if I have a user who makes posts which has comments. I have a relational query which gets me all my users, their posts and their comments nested. Is there a way to infer that type? Currently constructing the type myself from the tables in the schema.

in drizzle.config.ts: "Cannot use import statement outside a module"

happens when I try to push ```ts import type { Config } from "drizzle-kit"; import { env } from "~/env.mjs";...

Error when using Drizzle (Non-abstract class 'PgSelect<TTableName, TSelection, TSelectMode, [...])

I'm getting the following error when I try to use Drizzle: ```> graphql-server@1.0.0 start
npm run compile && node ./dist/index.js
...

Generate classes/interfaces from existing schemas?

Messing around with drizzle, and I was wondering if there was any way to generate a class or interface derived from an existing schema? My database is currently managed out-of-band (not by drizzle), by another service, so writing schemas by hand again, is not really preferred. I looked around and couldn't find anything related to doing such a task. This would really help a lot when using drizzle.