@@ -37,13 +37,20 @@ def __repr__(self):
3737 label = getattr (self , 'label' , '' ))
3838
3939
40- def reference_col (tablename , nullable = False , pk_name = 'id' , ** kwargs ):
40+ def reference_col (tablename , nullable = False , pk_name = 'id' ,
41+ onupdate = None , ondelete = None , ** kwargs ):
4142 """Column that adds primary key foreign key reference.
4243
4344 Args:
4445 tablename (str): Model.__table_name__.
4546 nullable (bool): Default is False.
4647 pk_name (str): Primary column's name.
48+ onupdate (str): If Set, emit ON UPDATE <value> when
49+ issuing DDL for this constraint. Typical values include CASCADE,
50+ DELETE and RESTRICT.
51+ ondelete (str): If set, emit ON DELETE <value> when
52+ issuing DDL for this constraint. Typical values include CASCADE,
53+ DELETE and RESTRICT.
4754
4855 Others:
4956
@@ -58,7 +65,8 @@ def reference_col(tablename, nullable=False, pk_name='id', **kwargs):
5865 """
5966
6067 return Column (
61- ForeignKey ('{0}.{1}' .format (tablename , pk_name )),
68+ ForeignKey ('{0}.{1}' .format (tablename , pk_name ),
69+ onupdate = onupdate , ondelete = ondelete ),
6270 nullable = nullable , ** kwargs )
6371
6472
0 commit comments