- removed version
MySQL column types incorrect for MSLongText, MSMediumText etc
Issue #269
resolved
Certain special column types do not appear to be generated correctly with MySQL. The following program demonstrates this:
########################################################################
#
# SQLAlchemy + MySQL - test of special column types
#
########################################################################
import sqlalchemy
import sqlalchemy.databases.mysql
# please substitute appropriate local user:password values
database_url = 'mysql://user:password@localhost:3306/test'
db = sqlalchemy.create_engine(database_url)
db.echo = True
metadata = sqlalchemy.BoundMetaData(db)
# acquire the MS* names from the sqlalchemy.databases.mysql module
msnames = [for name in dir(sqlalchemy.databases.mysql) if name.startswith('MS')](name)
msclasses = [name) for name in msnames](getattr(sqlalchemy.databases.mysql,)
msinstances = [for msclass in msclasses](msclass())
# report the expected column types]
for msinstance in msinstances :
print 'For class', msinstance.__class__.__name__, 'expected SQL type is', msinstance.get_col_spec()
# generate the column arguments
arguments = [msinstance)
for msinstance in msinstances](sqlalchemy.Column(msinstance.__class__.__name__,)
# create the table
emails_table = \
sqlalchemy.Table('emails', metadata,
sqlalchemy.Column('email_id', sqlalchemy.Integer, primary_key=True),
*arguments
)
emails_table.drop(checkfirst = True)
emails_table.create(checkfirst = True)
# visually compare expected and actual column types
# discrepancies are detected for:
# MSBigInteger
# MSDecimal
# MSDouble
# MSEnum
# MSLongText
# MSMediumText
#-----------------------------------
Comments (7)
-
repo owner -
repo owner - changed milestone to next micropoint release
-
repo owner - changed status to resolved
this is fixed in changeset:1790
-
Account Deleted - removed status
- changed status to open
The fix 1790 works for types MSDecimal, MSLongText, and MSMediumText. However, it does not work for types MSBigInteger, MSDouble, or MSEnum. Here is the diff to reflection.py (rev 1799) to add the neccessary additional unit test entries:
104a105,109 > Column('num2', mysql.MSBigInteger), > Column('num3', mysql.MSBigInteger()), > Column('num4', mysql.MSDouble), > Column('num5', mysql.MSDouble()), > Column('enum1', mysql.MSEnum('black', 'white')), 113a119,123 > assert isinstance(t2.c.num2.type, mysql.MSBigInteger) > assert isinstance(t2.c.num3.type, mysql.MSBigInteger) > assert isinstance(t2.c.num4.type, mysql.MSDouble) > assert isinstance(t2.c.num5.type, mysql.MSDouble) > assert isinstance(t2.c.enum1.type, mysql.MSEnum)
All these new tests do not pass at present.
-
repo owner - changed status to resolved
yeah, the basic pattern is, if the type is not in the colspecs dictionary, then it has to be a subclass of another mysql type. so i did the latest for this in changeset:1806 including your unit test, thanks.
-
repo owner - changed milestone to 0.4.0
Milestone next micropoint release deleted
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment