From 7ebcd26f741ea6e3c8bfc470529626f547a04ba8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 6 Dec 2011 20:59:04 -0500 Subject: - doc updates per [ticket:2251] - [feature] Added new value for Column autoincrement called "ignore_fk", can be used to force autoincrement on a column that's still part of a ForeignKeyConstraint. New example in the relationship docs illustrates its use. --- lib/sqlalchemy/schema.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/schema.py') diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 496d8e652..5754a294a 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -433,7 +433,7 @@ class Table(SchemaItem, expression.TableClause): if col.autoincrement and \ col.type._type_affinity is not None and \ issubclass(col.type._type_affinity, sqltypes.Integer) and \ - not col.foreign_keys and \ + (not col.foreign_keys or col.autoincrement=='ignore_fk') and \ isinstance(col.default, (type(None), Sequence)) and \ (col.server_default is None or col.server_default.reflected): return col @@ -700,7 +700,8 @@ class Column(SchemaItem, expression.ColumnClause): * Part of the primary key - * Are not referenced by any foreign keys + * Are not referenced by any foreign keys, unless + the value is specified as ``'ignore_fk'`` (new in 0.7.4) * have no server side or client side defaults (with the exception of Postgresql SERIAL). @@ -724,6 +725,12 @@ class Column(SchemaItem, expression.ColumnClause): any effect in this regard for databases that use sequences to generate primary key identifiers (i.e. Firebird, Postgresql, Oracle). + + As of 0.7.4, ``autoincrement`` accepts a special value ``'ignore_fk'`` + to indicate that autoincrementing status regardless of foreign key + references. This applies to certain composite foreign key + setups, such as the one demonstrated in the ORM documentation + at :ref:`post_update`. :param default: A scalar, Python callable, or :class:`~sqlalchemy.sql.expression.ClauseElement` representing the -- cgit v1.2.1