drizzle-team / drizzle-team/drizzle-orm

[BUG]: Sharing Schema/Types

Open
#3,028 22 comments 17 reactions 0 assignees View on GitHub
bug monorepo priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.33.0

### What version of `drizzle-kit` are you using?

0.23.1

### Describe the Bug

Hello ! Overall wonderful library, you really helped me understand SQL, and databases.

------------

## Context 💭

- I'm running a `Sveltekit` Application (named : `app`)
- I have extracted the schema into a different project (named: `package-schema`) that i consume inside `App` by doing `npm link Package`

## Configuration 🛞

### App

`drizzle-orm` : `0.33.0`
`typescript` : `5.6.2"`

```json
//tsconfig.json
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
}
```

### package-schema

`drizzle-orm` : `0.33.0`
`drizzle-zod` : `0.5.1`
`typescript` : `5.6.2`

```json
{
//package.json
//...
"devDependencies": {
"typescript": "^5.5.4"
},
"dependencies": {
"drizzle-orm": "^0.33.0",
"drizzle-zod": "^0.5.1",
"zod": "^3.23.8"
}
}
```

```json
//tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "Bundler",
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"sourceMap": true,
"declarationMap": true
},
"include": ["src/**/*"],
"exclude": ["dist", "node_modules"]
}
```

## The ERROR (maybe BUG) 🐛

The error from typescript

```ts

// catToMaster come from `package-schema`

const allCatToMaster = await db
.select()
// The typescript error is on the line below
.from(catToMaster)

```

```
Argument of type 'PgTableWithColumns<{ name: "catToMaster"; schema: undefined; columns: { catId: PgColumn<{ name: "cat_id"; tableName: "catToMaster"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; ... 6 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; createdAt: PgCol...' is not assignable to parameter of type 'SQL | PgTable | Subquery> | PgViewBase'.
Type 'PgTableWithColumns<{ name: "catToMaster"; schema: undefined; columns: { catId: PgColumn<{ name: "cat_id"; tableName: "catToMaster"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; ... 6 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; createdAt: PgCol...' is not assignable to type 'PgTable'.
The types of '_.config.columns' are incompatible between these types.
Type '{ catId: PgColumn<{ name: "cat_id"; tableName: "catToMaster"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}...' is not assignable to type 'Record, {}, {}>>'.
Property 'catId' is incompatible with index signature.
Type 'PgColumn<{ name: "cat_id"; tableName: "catToMaster"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to type 'PgColumn, {}, {}>'.
The types of 'table._.config.columns' are incompatible between these types.
Type 'Record

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.