On Monday 06 July 2009 16:37:37 Diez B. Roggisch wrote:
> Hi,
>
> I'm faced with a situation where I have
>
>  - a 1:n-relationship between Document and DocumentRevision-objects
>  - want to delegate most properties of Document to DocumentRevison, which
> means I need an "active" revision.
>
> Modelling that active_revision as "normal" ManyToOne-relationship on the
> document gets me (understandably) into circular-dependency-hell.
>
> Now I know that you can create deferred constraints in some databases
> as "deferrable" which means you can create circular dependencies that must
> only be valid at commit-time, not while inserting.
>
> See e.g.
>
> http://www.network-theory.co.uk/docs/postgresql/vol1/CREATETABLE.html
>
> for PG doing this.
>
> Is there any way to exploit this kind of foreign key reference via elixir,
> or maybe SA itself?

Ok, found it - whyever it skipped my attention at the first look:


    active_revision = ManyToOne("DocumentRevision",
                                use_alter=True,
                                #constraint_kwargs=dict(deferrable=True,
                                #initially="deferred")
    )

Uncomment the two bottom lines to modify the deferrable-state.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to