Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Incorrect type inference with multidimensional array field PostgreSQL #1028

Open
Tracked by #3649
Senbonzakura1234 opened this issue Aug 12, 2023 · 4 comments
Assignees
Labels
bug Something isn't working db/postgres priority Will be worked on next

Comments

@Senbonzakura1234
Copy link

Senbonzakura1234 commented Aug 12, 2023

What version of drizzle-orm are you using?

0.28.2

What version of drizzle-kit are you using?

0.19.12

Describe the Bug

I have a PostgreSQL table with shape roughly like this:

export type HyperLinkRecord = { id: string; name: string; table: ModuleIdEnum };

export const traits = pgTable('traits', {
  mergeFrom: jsonb('merge_from').$type<HyperLinkRecord>().array(2).array().notNull(),
});

Try update drizzle-orm@0.27.2 to drizzle-orm@0.28.2.

and the type of mergeFrom turn to unknown[][]
The schema returned correct type with drizzle-orm@0.27.2 though

Expected behavior

type of mergeFrom properties should be HyperLinkRecord[][]

Environment & setup

full package.json of my project

@Senbonzakura1234 Senbonzakura1234 added the bug Something isn't working label Aug 12, 2023
@Senbonzakura1234 Senbonzakura1234 changed the title [BUG]: Incorrect type inference with multidimensional array field [BUG]: Incorrect type inference with multidimensional array field PostgreSQL Aug 12, 2023
@dankochetov
Copy link
Contributor

Side question: why do you want to store an array column of json items instead of a json column with a json array inside?

@dankochetov
Copy link
Contributor

i.e. mergeFrom: jsonb('merge_from').$type<HyperLinkRecord[][]>().notNull()

@Senbonzakura1234
Copy link
Author

Senbonzakura1234 commented Aug 12, 2023

@dankochetov maybe i was try to make drizzle return infer type [HyperLinkRecord, HyperLinkRecord][], but then it did not work and just return HyperLinkRecord[][]. It was quite long ago. Anyway leme test if mergeFrom: jsonb('merge_from').$type<HyperLinkRecord[][]>().notNull() also has this bug or not

@Senbonzakura1234
Copy link
Author

Senbonzakura1234 commented Aug 12, 2023

@dankochetov maybe i was try to make drizzle return infer type [HyperLinkRecord, HyperLinkRecord][], but then it did not work and just return HyperLinkRecord[][]. It was quite long ago. Anyway leme test if mergeFrom: jsonb('merge_from').$type<HyperLinkRecord[][]>().notNull() also has this bug or not

@dankochetov as i test mergeFrom: jsonb('merge_from').$type<HyperLinkRecord[][]>().notNull() didn't produce wrong infer type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working db/postgres priority Will be worked on next
Projects
Status: Todo
Development

No branches or pull requests

3 participants