Hi there,

On 6/14/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
> yeah i have a secret weapon for that sort of thing, called
> "post_update"...you might be the first to use it.

Cool.. :o) -- I saw post_update in the docs, figured I needed that.

> this is a paraphrased version of how it would look, you have to fix
> up the join conditions/backrefs to suit your tables:
>
> mapper(Page, pages, properties={
>      'job': relation(Job, backref=backref('pages', cascade="all,
> delete-orphan")),
>      'current_version' : relation(PageVersion,
> primaryjoin=pages.c.currentversion==pageversions.c.version,
> post_update=True),
>      'versions' : relation(PageVersion,
> primaryjoin=pages.c.pagename==pageversions.c.pagename)
> })
>
> the idea of "post_update" is that its going to insert/update the row
> on the "pages" table normally, then do the "versions", and then do a
> *second* update on the "pages" table to get the "current_version"
> foreign key in there.

Sounds good. I haven't tested it yet, but somehow the join conditions
above seem insufficient. The key on Pages is (job, pagename) and the
key on PageVersions is (job, pagename, version).  Anyways - I'll give
it a try and look at the generated SQL.

> ive had unit tests in place for this for quite some time now but lets
> see if it works in a more complex scenario (if it doesnt work, then
> your test cases will become new unit tests).

I'll let you know :o)

Arnar


_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to