DT
Drizzle TeamJustKira
Circular Reference Error when Using Self-Reference in Table Definition with Drizzle-ORM
I encountered an error while defining a PostgreSQL table using Drizzle-ORM. The issue arises when attempting to create a self-referencing array column that references the primary key of its own table. The error message suggests that there is an issue with type inference possibly due to the self-reference.
Expected Behavior:
I expect to define a self-referencing column (dependencies_courses) that can store an array of course IDs, referencing the id column of the same course table without causing a type inference issue.
J
JustKira•20d ago
found this on Drizzle docs https://orm.drizzle.team/docs/indexes-constraints
which solved my problem
Drizzle ORM - Indexes & Constraints
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
7.4KMembers
View on DiscordWant results from more Discord servers?
More PostsSQL many statements?Any ideas on how to debug this?
```Task migrations deno run -A src/lib/db/migrations.ts
error: UncaQuerying a materialized view: relation does not existI define a materialized view as such:
```
export const usersMv = pgMaterializedView("users_mv").as(
default to empty object for sqlite text field with JSON modeHow can I default a `mode: 'json'` text type to an empty object in sqlite?
The following in a `sqliConverting a field from X type to Serial causes errorsI'm attempting to convert a field from type `text` to type `serial`.
Here's the error I'm seeing:
`