propagation of two levels like that isn’t intrinsic to SQLAlchemy’s 
capabilities.  For cascading primary key -> foreign key changes in that way, 
you’d need to use ON UPDATE CASCADE on your foreign keys, only supported by 
some target backends.  There are possibly ways to get event listeners at the 
SQLAlchemy level to do this also. 

However, in the bigger picture, it probably is not a good idea to use 
non-surrogate (e.g. meaningful, which therefore must accommodate changes in 
value) primary keys on a database that does not support ON UPDATE CASCADE 
functionality.  The databases’s behavior is much more comprehensive in this 
case.



On Aug 4, 2014, at 1:33 PM, Mario Žic <[email protected]> wrote:

> I have also tried adding onupdate="cascade" to all foreign keys. (I have also 
> disabled passive updates to avoid conflict during update. I think that 
> relationship altered values before sqlite got the chance to do it.) I 
> enforced referential integrity using proposed event listener method. This 
> worked fine within the DB, the updates propagated nicely, but still didn't do 
> the job when PK was altered in Sqlalchemy. I think that understanding of this 
> behaviour is out of my league for time being :)
> 
> On Monday, August 4, 2014 11:24:52 AM UTC+2, Mario Žic wrote:
> Hi,
> 
> I have a problem where three tables are linked via relationships A -> B -> C, 
> and all the relationships refer to the same property i.e. the primary key 
> (PK) of table A is a foreign key (FK) in the table B, and the same FK (table 
> B) is a FK in the table C. The example is artificial since I am trying to 
> simplify the schema. However, when I modify the PK of A only B sees the 
> change after flush. I would expect  table C to get updated as well.
> 
> The problem and the code is already posted here.
> 
> I have a feeling this should be sth simple and documented but I had no luck 
> so far.
> 
> Thanks for the help!
> 
> 
> * I tested the code using SQLAlchemy 0.7.7 and 0.9.7; the DB is SQLite
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to