diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-09 04:00:35 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-09 04:00:35 +0000 |
commit | f279e2b1f24bd6efc7542707707ea9724f679e65 (patch) | |
tree | 607fbadf483ba2652b41f4a9881bc0e6a1b55d4a /lib/sqlalchemy/schema.py | |
parent | d56a50eb7056cfe054c03b47db3d79dab03a5638 (diff) | |
download | sqlalchemy-f279e2b1f24bd6efc7542707707ea9724f679e65.tar.gz |
- added onupdate and ondelete keyword arguments to ForeignKey; propigate
to underlying ForeignKeyConstraint if present. (dont propigate in the
other direction, however)
- patched attribute speed enhancement [ticket:389] courtesy Sébastien Lelong
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r-- | lib/sqlalchemy/schema.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 8ebeaea27..93f4574bc 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -501,7 +501,7 @@ class ForeignKey(SchemaItem): One or more ForeignKey objects are used within a ForeignKeyConstraint object which represents the table-level constraint definition.""" - def __init__(self, column, constraint=None, use_alter=False, name=None): + def __init__(self, column, constraint=None, use_alter=False, name=None, onupdate=None, ondelete=None): """Construct a new ForeignKey object. "column" can be a schema.Column object representing the relationship, @@ -518,6 +518,8 @@ class ForeignKey(SchemaItem): self.constraint = constraint self.use_alter = use_alter self.name = name + self.onupdate = onupdate + self.ondelete = ondelete def __repr__(self): return "ForeignKey(%s)" % repr(self._get_colspec()) @@ -588,7 +590,7 @@ class ForeignKey(SchemaItem): self.parent = column if self.constraint is None and isinstance(self.parent.table, Table): - self.constraint = ForeignKeyConstraint([],[], use_alter=self.use_alter, name=self.name) + self.constraint = ForeignKeyConstraint([],[], use_alter=self.use_alter, name=self.name, onupdate=self.onupdate, ondelete=self.ondelete) self.parent.table.append_constraint(self.constraint) self.constraint._append_fk(self) |