[Pg] Add missing support for vector
, point
types to drizzle-zod
#2780
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently,
drizzle-zod
excepts any column that has adataType
as"array"
to be an array that also has abaseColumn
. This turns out to not be true for types such asvector
andpoint
, among others.. which results in passing anundefined
where none is expected which leads to a runtime crash.This PR adds a test that replicates the crash, and adds support for
vector
andpoint
-- 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