Hello all,
I'm wondering why the integer primary keys for MySQL are marked
as AUTO_INCREMENT by default, while they're not marked SERIAL for
Postgres for example.
I'm referring to this fragment of code in databases\mysql.py:
class MySQLSchemaGenerator(ansisql.ANSISchemaGenerator):
def get_column_specification(self, column, override_pk=False,
first_pk=False):
colspec = column.name + " " +
column.type.engine_impl(self.engine).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
if not column.nullable:
colspec += " NOT NULL"
if column.primary_key:
if not override_pk:
colspec += " PRIMARY KEY"
if not column.foreign_key and first_pk and isinstance(column.type,
sqltypes.Integer):
colspec += " AUTO_INCREMENT"
if column.foreign_key:
colspec += ", FOREIGN KEY (%s) REFERENCES %s(%s)" % (column.name,
column.foreign_key.column.table.name, column.foreign_key.column.name)
return colspec
Could someone explain the reasoning behind it to me?
(If this is not a bug, could someone please tell me how can I switch this
behaviour off? I do not
want my primary key columns to be auto increment).
Maciej Szumocki
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users