Hi Michael,

As expected the trunk works perfectly.
I am also looking into the comparator example you pointed to as this
looks like it will help with a couple of other implementation details
as well.

Thanks again,


Martin

On Feb 20, 10:25 pm, Martin Pengelly-Phillips
<[EMAIL PROTECTED]> wrote:
> Thank you Michael - it's always good to get some validation when
> pushing your own knowledge of a system.
> I'll check out the trunk tomorrow, give it a whirl and report any
> findings then.
>
> Thanks again for the quick response,
>
> Martin
>
> On Feb 20, 6:31 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> > On Feb 20, 2008, at 1:01 PM, Martin Pengelly-Phillips wrote:
>
> > > I have attempted to solve this by using the concept of
> > > 'forwardAssociations' with a backref of 'backwardAssociations' and
> > > then a custom property 'associations' that retrieves and sets the real
> > > attributes accordingly (let me know if you would like to see this code
> > > as well). However, even with this set up I find it hard to figure out
> > > how to then perform a query such as:
>
> > > # Get all entities that are in some way associated with entity 2
> > > (without using entity2.associations property)
> > > session.query(Entity).filter(or_(
> > >    Entity.forwardAssociations.any(Entity.id==2),
> > >    Entity.backwardAssociations.any(Entity.id==2)
> > > )).all()
>
> > > The query this generates though uses the same id for both sides of the
> > > association table which cannot therefore result in a match:
> > > entities.id = "entitiesEntities".entity1_id AND
> > > "entitiesEntities".entity2_id = entities.id AND entities.id = ?
>
> > well i think everything you're doing is on the right track.  The any()
> > operator and its friends have just been repaired in the latest trunk
> > to recognize a self-referential relation and apply the appropriate
> > aliasing to half of the join condition.  I haven't tested it with a
> > many-to-many self referential yet but I think it should work.  give it
> > a try and let me know what you get; I can add some m2m tests for it
> > and ensure that its working if its not already.
>
> > we also are working on getting better support for user-defined custom
> > properties going such that they can be seamlessly used within Queries,
> > so that you could also construct your query using your "associations"
> > property, if you can define how comparison operations should be done.
> > There is a way to do this right now using a slight bit of "non-public"
> > API, where you can see an example of such 
> > inhttp://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/vert...
> >   ; the "comparable_property" allows the injection of a Comparator
> > object from where you can define things like __eq__(), any(), etc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to