Repository navigation
fix!: Fix SQLAlchemy ARRAY dimensions and Enum labels, support TypeDecorator - #147
Merged
Merged
Conversation
…n explicit `ARRAY` branch
…the enum class values
…d of a fixed-shape `Array`
…INET`, `CIDR`, `MACADDR` types
…Decorator` mapping
…`Never` narrowing on pyrefly 1.5
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.
Summary
Fixes two wrong mappings in
SQLAlchemyTypeStepand adds support for types that used to raise.ARRAY(dimensions=N):dimensionsis the nesting depth, not a length.ARRAY(Integer, dimensions=2)now givesList(List(Int32))instead ofArray(Int32, shape=(2,)).Enum: categories now come fromEnum.enums, the labels SQLAlchemy stores. By default those are the member names; withvalues_callablethey are the member values. Before, an enum class always gave its member values, which didn't match what is stored in the table.TypeDecorator: parsed as its implementation type (impl), so custom types andPickleTypeno longer raise. Column metadata still applies, e.g. a precision override on a decorator overNumeric.INTERVALmaps toDuration;INET,CIDRandMACADDRmap toString.SupportedSQLAlchemyType,_SUPPORTED_SQLALCHEMY_TYPESand_is_supported_sqlalchemy_type. They repeated theisinstancechain only so the last line could assume "by exclusion it isARRAY".ARRAYnow has its own branch andparseends withreturn None.is_sequence_ofandis_sequence_but_not_strin_utils.pyhad no other users and are deleted.ARRAY(Integer, dimensions=2)Array(Int32, shape=(2,))List(List(Int32))Enum(Color)withColor.RED = "r"Enum(categories=['r', ...])Enum(categories=['RED', ...])TypeDecoratorwithimpl = String(20)NotImplementedErrorStringPickleType()NotImplementedErrorBinarypostgresql.INTERVAL()NotImplementedErrorDurationpostgresql.INET()/CIDR()/MACADDR()NotImplementedErrorStringBreaking changes
ARRAYcolumns withdimensionsset now give nestedLists. Columns withoutdimensionsare unchanged (List).Enumcolumns built from an enum class whose member names differ from their values now give the names. Plain string enums (Enum("a", "b")) and classes that usevalues_callableare unchanged.