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

Handle postgres arrays #6

Merged
merged 3 commits into from Jun 1, 2015

Conversation

@jmcarp
Copy link
Contributor

commented May 31, 2015

The current behavior for postgres.ARRAY sort of works. SQLAlchemy knows
that the python_type of ARRAY columns is list, so we convert them
to List fields. But we currently ignore the nested types:
ARRAY(Integer) should convert to List(Int), and ARRAY(String)
should convert to List(Str). This patch inspects the nested type of
the ARRAY to build the appropriate List.

jmcarp added some commits May 31, 2015

Remove redundant type mappings.
SQLAlchemy types with `python_type` values present in
`Schema.TYPE_MAPPING` don't need to be included in `SQLA_TYPE_MAPPING`.
Handle postgres arrays correctly.
The current behavior for postgres.ARRAY sort of works. SQLAlchemy knows
that the `python_type` of `ARRAY` columns is `list`, so we convert them
to `List` fields. But we currently ignore the nested types:
`ARRAY(Integer)` should convert to `List(Int)`, and `ARRAY(String)`
should convert to `List(Str)`. This patch inspects the nested type of
the `ARRAY` to build the appropriate `List`.

mysql.BIT: fields.Integer,
mysql.TINYINT: fields.Integer,

This comment has been minimized.

Copy link
@sloria

sloria Jun 1, 2015

Member

Why were these removed?

This comment has been minimized.

Copy link
@jmcarp

jmcarp Jun 1, 2015

Author Contributor

I probably should've put this into its own PR, but the mappings that I deleted aren't necessary. Because mysql.TINYINT().python_type is int, the mappings in Schema.TYPE_MAPPING already handle this case. I think mappings are only needed here for columns that either don't define python_type or that need special logic, like postgres.UUID or postgres.ARRAY.

Semi-documented in commit message at jmcarp@67b2eb7.

This comment has been minimized.

Copy link
@sloria

sloria Jun 1, 2015

Member

I see. Thanks for the clarification.

sloria added a commit that referenced this pull request Jun 1, 2015

@sloria sloria merged commit 40d11bf into marshmallow-code:dev Jun 1, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.