Autoincrement property of column is always set to true

Issue #1086 resolved
Former user created an issue

I am not sure why this is, but I tried it in versions: 0.4.0, 0.4.6, 0.5beta1 and they all produce the same results. Here is the test code:

#auto increment test
import sqlalchemy

url = "sqlite://"


e = sqlalchemy.create_engine(url)
m = sqlalchemy.MetaData()
m.bind = e


t = sqlalchemy.Table('test', m,
          sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
          sqlalchemy.Column('no_autoincremented', sqlalchemy.String(30))
          )

m.create_all()

print sqlalchemy.__version__
print [c.autoincrement) for c in t.c]((c.name,)

produces the output:

0.5.0beta1
[True), ('no_autoincremented', True)](('id',)

-percious

this is high priority for me as it breaks dbsprockets.

Comments (1)

  1. Mike Bayer repo owner

    this is the documented behavior of the "autoincrement" flag. It means SA should expect the column to create a new primary key value upon INSERT, if the col is an Integer/PK column. Don't use this flag to find out things about your database (theres plenty of introspection tools like FormAlchemy etc. that don't have this problem).

  2. Log in to comment