Enum array column
Hey there,
anyone got an idea why doesn't this work:
the error:
PostgresError: type "productmodule[]" does not existbut... why?
26 Replies
trying to push this to my db
👋 Hey
This is because your productModuleEnum has to be part of your schema. It has to be exported with your tables
+ you will have an error on your default, it should be cast as
Ex:
https://drizzle.run/oc2vp22i5bz5dke8y7oailgv
Drizzle Run
Enum array with default - Drizzle Run
hey there, thanks. what do you mean by "has to be part of your schema"? it'S within my schema.ts file
Oh, sorry, wrong guess on my part 😅
there's also a proper productModule enum in my database
I can’t reproduce in the link i shared. I wonder if it is because I used an other name in my schema
It is late for me but if you’re still in trouble I will retry tomorrow
what's very confusing is that the error
productmodule
is all lowercase
while the enum in the db (and the schema) are camelCaseoh, yes it's the reason
name is lowercased
but why?
there's nothing lowercased 😮
I guess it is because camelCase is not allowed for type name
when the new type (the enum) is used here
changed it to
product_module
- it works now. that's some weird issueI think it's a bug honestly
feels a lot like it
unfortunately I can't make out where in the code that happens, because - regarding the stack trace - it's in bin.cjs on line 81060
maybe it's an issue with pg, but maybe drizzle lowercases the input somewhere (which would be very weird)
would you mind just open an issue with your example? https://github.com/drizzle-team/drizzle-kit-mirror/issues?q=
I will make a standalone repo because I can't open source the project I'm working on. will try to do so asap
thanks for your time
Oh you can just describe + the error (with your first ex) and link this thread
Don't worry about a repro, it can easly be reproduce with Drizzle Run
unfortunately I'm facing a lot of weird issues with drizzle, like https://github.com/drizzle-team/drizzle-orm/issues/2418 or things like this. I get it that it's not 1.0 yet, but there's a voice in my head screaming "why not just use prisma again" pretty often 😦
repro: https://drizzle.run/n5dbm1kdp1bbub4ulnaqhi5w
Really surprising for this
I will look at your repro linked in the issue tomorrow
I think it is a turbo repo issue but I will look at that
you mean the 2418 type thing?
the typing error. I also wonder why it happen for the OP of this issue. Will look at your https://github.com/nehalist/drizzle-turborepo-type-error
GitHub
GitHub - nehalist/drizzle-turborepo-type-error
Contribute to nehalist/drizzle-turborepo-type-error development by creating an account on GitHub.
thanks a lot
should fix the issue (in your base.json or in the
compilerOptions
of your database
package's tsconfig
)
https://www.totaltypescript.com/tsconfig-cheat-sheet#quickstart
You can also have one tsconfig for packages.
Then "module": "preserve",
is enought (without moduleResolution
)