fix(pg): prevent enum names with native type prefixes from losing schema prefix#5628
Open
CalvinMagezi wants to merge 1 commit into
Open
fix(pg): prevent enum names with native type prefixes from losing schema prefix#5628CalvinMagezi wants to merge 1 commit into
CalvinMagezi wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #5609
Problem
parseType()indrizzle-kit/src/sqlgenerator.tsusedtype.startsWith(nativeType)to decide whether a PostgreSQL type is a native type or a user-defined type (enum/domain). This caused a false positive when an enum name begins with a native type name.Example:
Other affected enum names: anything starting with
text,bit,time,date,real,json,uuid,integer,interval,numeric,decimal,vector,boolean,varchar,geometry, etc.Fix
The original check used
type.startsWith(it)against the raw type string. The fix switches towithoutArrayDefinition(array brackets already stripped two lines above) and tightens the match with three precise conditions:Each condition covers a distinct case:
=== ittext,integer,booleanstartsWith(it + '(')varchar(255),char(10),numeric(10,2)startsWith(it + ' ')timestamp with time zone,double precision,time without time zonechar_typedoes not satisfy any of these for the native typechar, so it correctly gets the schema prefix.char(10)still matches via the(condition.Impact
parseType()is changed — one expression, no logic restructuring.