implement 'use_update' flag for relations

Issue #67 resolved
Mike Bayer repo owner created an issue

the final glitch in committing every kind of relationship is the two rows that are dependent on each other issue (or maybe even a single row...).

a flag has been added already 'use_update' to relation:

m = mapper(cls, table, properties = {
      'items':relation(cls2, table2, use_update=True)
     })

which means, dont take cls and cls2 to be dependent on each other in the usual sense. instead , save cls and cls2 in whatever order. then, assign the dependent values between cls and cls2 instances, and perform a second UPDATE on the cls2 items. this flag currently can only be placed on a "many to one" relationship, and also an object with several "use_update" flags on it will result in several UPDATE statements, when this could be distilled into just one by adding another step to the UOWTask execute sequence.

this way, even if a cls and cls2 object are dependent on each other, the data can still get in the database.

ideally, the 'use_update' flag would be determined on the back end when things are all worked out, but trying to start slow. Basically, if your objectstore tells you "circular dependency between obj1 and obj2 detected", then you need to put "use_update" in there to work it out.

Comments (4)

  1. Mike Bayer reporter

    this flag is actually committed now mostly in changeset:1011 and there is a unit test, but I would like to add assertions to the unit test to insure the UPDATE is taking place (maybe even use a mock object to detect the internal state of the commit), since it silently passes on sqlite even if it doenst work.

  2. Log in to comment