Repository navigation
feat: type overrides, Postgres enum shared types, and unmapped-type crash fix (#93) - #94
Merged
Merged
Conversation
…tors data types (#93)
Bump in-range deps via npm update and apply npm audit fix (no --force), raising transitive moment to 2.31.0 and brace-expansion to 5.0.12 to clear the high-severity brace-expansion advisory and the moment advisory. npm 11 also converts the lockfile from v2 to v3.
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.
Implements #93 (13.2.0): unmapped types no longer crash, Postgres user-defined types are detected, and users can declare type overrides. Includes review fixes and a dependency refresh. All codegen uses the TypeScript compiler API.
Closes #93.
Unmapped types (
a169ef9)mapDbTypeToJsnow returnsstring | undefinedin the dialect contract and in all five dialects.unknowninstead of crashing increateTypeNodeFromName. Decorators keepanyuntil the next major.warnUnmappedTypespass inModelBuilder.build(). It namesschema.table.column, says which type the column received, and points to--type-overrides-file. Columns covered by an override get no warning.Type overrides (
7c69e89,5e2074d,7386af7)--type-overrides-file/-y, or fromIConfig.metadata.typeOverridesFile/metadata.typeOverrides. Setting both is a validation error.types:<type>or<schema>.<type>columns:<table>.<column>or<schema>.<table>.<column>tsType,dataType, or both.tsTypeis parsed with the compiler API into a type node. Unions, object types andimport('pkg').Typeall work, and no imports are generated.dataTypeis parsed into the structured{key, args}form. Only identifiers, calls and string or number literals are accepted, with an optionalDataTypes.prefix. Each key must be a real column data type, so dialect namespaces andABSTRACTare rejected. Raw user text is never emitted as code.tsTypeanddataTypeindependently:[ValidationError]and names the entry. Entries that matched no column produce one combined warning.ITypeOverride,ITypeOverridesandIColumnTypeOverrideare exported.Jsonshared type is emitted only while some column still uses it.Postgres user-defined types (
219dd7e,46d0e00)pg_type,pg_enumandpg_namespace, with one cached query per schema. Lookup uses the column's UDT schema and name, so enum arrays and enums from other schemas resolve.PlanTier = 'free' | 'pro', in a generatedenums.ts. Both formats import it type-only.DataTypes.ENUM(...)with labels in database order. Enum arrays emit an ARRAY of ENUM and are typedPlanTier[].enums.tsis generated only when a column still uses an enum after overrides.Enumsuffix;citextmaps tostring/CITEXT. Domains already resolve to their underlying type; a test now covers this.',\,"or a newline now render as valid TypeScript string literals in decorators data types. This also fixes MySQL/MariaDB enums with such labels.Docs (
5e8a2d0,c0e4fd7)sync()and enum OIDs.--helpnow matches the real output.CONTEXT.mdgains a "Types" glossary section.Dependencies (
44bf442,d91f65a,55b1557)npm updatebrought packages to their newest versions within the existing ranges.npm audit fix, without--force, raisedmomentandbrace-expansion. Runtime advisories went from 4 (1 high) to 2 moderate.@types/yargsstays at 17.uuidviasequelize; npm's only suggested fix is a downgrade to sequelize 3;js-yaml/sprintf-jsadvisories via jest and tedious; their only suggested fixes are downgrades too.@types/nodemajor.Tests
Through
ModelBuilder.build()with a stub dialect (typeOverrides.test.ts,sharedEnumTypes.test.ts,modelBuilder.test.ts):CLI config tests check that
-yreaches the config.Integration:
typeOverridesscenario runs in all five dialects;userDefinedTypesscenario covers an enum, an enum array, a cross-schema enum, a domain,citext, and an enum shared by two tables, and round-trips their values.Results, run locally:
MariaDB was not rerun after the final dependency commits.