Today I found if I have an id column in a table, and the autoincrement
attribute is True, when I created the table it's right, but when I print
the create statment is not right for autoincrement. The testing code is:
from sqlalchemy import *
from sqlalchemy.schema import CreateTable
engine = create_engine('mysql://root:root@localhost/test', echo=True)
metadata = MetaData()
t = Table('mytable', metadata,
Column('gid', Integer, primary_key=True, autoincrement=True),
Column('id', Integer, primary_key=True)
)
metadata.create_all(engine)
print CreateTable(t)
And the result is:
2013-10-05 12:59:54,523 INFO sqlalchemy.engine.base.Engine SELECT DATABASE()
2013-10-05 12:59:54,523 INFO sqlalchemy.engine.base.Engine ()
2013-10-05 12:59:54,526 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES
LIKE 'character_set%%'
2013-10-05 12:59:54,526 INFO sqlalchemy.engine.base.Engine ()
2013-10-05 12:59:54,526 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES
LIKE 'sql_mode'
2013-10-05 12:59:54,528 INFO sqlalchemy.engine.base.Engine ()
2013-10-05 12:59:54,538 INFO sqlalchemy.engine.base.Engine DESCRIBE
`mytable`
2013-10-05 12:59:54,538 INFO sqlalchemy.engine.base.Engine ()
2013-10-05 12:59:54,552 INFO sqlalchemy.engine.base.Engine ROLLBACK
2013-10-05 12:59:54,575 INFO sqlalchemy.engine.base.Engine
CREATE TABLE mytable (
gid INTEGER NOT NULL AUTO_INCREMENT,
id INTEGER NOT NULL,
PRIMARY KEY (gid, id)
)
2013-10-05 12:59:54,575 INFO sqlalchemy.engine.base.Engine ()
2013-10-05 12:59:55,332 INFO sqlalchemy.engine.base.Engine COMMIT
CREATE TABLE mytable (
gid INTEGER NOT NULL,
id INTEGER NOT NULL,
PRIMARY KEY (gid, id)
)
So the above is right, and it's gid INTEGER NOT NULL AUTO_INCREMENT, but
the next is not right, it losts AUTO_INCREMENT.
I tried to check the code and I found the implementation of
dialects/sql/mysql/base.py:get_column_specification(1408) is not like
sql/compiler.py:get_column_specification(2021). I think maybe is a bug.
BTW, my salalchemy version is 8.0.
--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users