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

Resolution for Issue #1, added SQLAlchemy ORM dialect types for MySQL #2

Merged
merged 2 commits into from
May 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 30 additions & 1 deletion marshmallow_sqlalchemy/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import marshmallow as ma
from marshmallow import validate, fields
from marshmallow.compat import text_type
from sqlalchemy.dialects import postgresql
from sqlalchemy.dialects import postgresql, mysql
from sqlalchemy.orm.util import identity_key
import sqlalchemy as sa

Expand Down Expand Up @@ -37,9 +37,38 @@ class ModelConverter(object):
sa.Numeric: fields.Decimal,
sa.Float: fields.Decimal,
sa.Date: fields.Date,

postgresql.UUID: fields.UUID,
postgresql.MACADDR: fields.String,
postgresql.INET: fields.String,

mysql.BIT: fields.Integer,
mysql.TINYINT: fields.Integer,
mysql.SMALLINT: fields.Integer,
mysql.INTEGER: fields.Integer,
mysql.BIGINT: fields.Integer,

mysql.NUMERIC: fields.Decimal,
mysql.DECIMAL: fields.Decimal,

mysql.DATETIME: fields.DateTime,
mysql.DATE: fields.Date,
mysql.TIME: fields.Time,
mysql.YEAR: fields.Integer,

mysql.TEXT: fields.String,
mysql.TINYTEXT: fields.String,
mysql.MEDIUMTEXT: fields.String,
mysql.LONGTEXT: fields.String,

mysql.BLOB: fields.String,
mysql.TINYBLOB: fields.String,
mysql.MEDIUMBLOB: fields.String,
mysql.LONGBLOB: fields.String,

mysql.SET: fields.List,
mysql.ENUM: fields.Enum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Enum field is now deprecated in favor of using the validate.OneOf validator. I will change this to fields.Field when I merge.


}

DIRECTION_MAPPING = {
Expand Down