Thank you very much. This fixes my problem. So it's not a bug?

On Sat, Oct 5, 2013 at 2:17 PM, Michael Bayer <[email protected]>wrote:

>
> On Oct 5, 2013, at 1:58 AM, limodou <[email protected]> wrote:
>
> 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)
>
>
> do the create table like this:
>
> print CreateTable(t).compile(dialect=engine.dialect)
>
>
>
>
> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
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

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to