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

[Pg] Add missing support for vector, point types to drizzle-zod #2780

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

saevarb
Copy link

@saevarb saevarb commented Aug 10, 2024

Currently, drizzle-zod excepts any column that has a dataType as "array" to be an array that also has a baseColumn. This turns out to not be true for types such as vector and point, among others.. which results in passing an undefined where none is expected which leads to a runtime crash.

This PR adds a test that replicates the crash, and adds support for vector and point -- and there might be other types which could be supported similarly easily.

It also detects the case that was causing a runtime crash and now throws a more useful error message, which would easily flag future cases where the solution is probably just adding yet another is check. This is solely based on my own preference, however, so definitely not dying on a hill for that commit.

I also noticed that the resulting types for the schemas were wrong, which I attempted to fix. The result seems very clunky though.

Finally, as an additional optional and very benign improvement, I modified the expectSchemaShape to output the names of the keys that fail to match for easier debugging.

Fixes #2424

Copy link

@Harry-Ross Harry-Ross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love this to be fixed 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: drizzle-zod's createInsertSchema() can't handle column of type vector
2 participants