summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-12-06 20:59:04 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-12-06 20:59:04 -0500
commit7ebcd26f741ea6e3c8bfc470529626f547a04ba8 (patch)
treefa6748784fc293da9d125610c8047b0c47468d94 /lib/sqlalchemy/schema.py
parent58e692d76bbea84667609a4ceb828dcf43571f6e (diff)
downloadsqlalchemy-7ebcd26f741ea6e3c8bfc470529626f547a04ba8.tar.gz
- 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.
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py11
1 files changed, 9 insertions, 2 deletions
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