Something I noticed while testing this: the lambda doesn't appear to
use the InstrumentedAttributes at all -- it uses the real column names
instead.  Thus, the example below will fail with an AttributeError
unless you change 'parent' to 'parent_id' in the lambda.  Please
document this.

from elixir import *

class Belonger(Entity):
  parent = ManyToOne('Belonger')
  haver = ManyToOne('Haver')

class Haver(Entity):
  all_belongers = OneToMany('Belonger')
  root_belongers = OneToMany('Belonger', filter=lambda c: c.parent !=
None)

setup_all()


On Oct 25, 1:13 pm, Gaetan de Menten <[email protected]> wrote:
> On Sun, Oct 25, 2009 at 20:31, Nick Retallack <[email protected]> wrote:
> >>>> class Haver(Entity):
> > ...   all_belongings = OneToMany('Belonger')
> > ...   some_belongings = OneToMany('Belonger', filter='Belonger.stuff !
> > = None')
>
> use:
>
> some_belongings = OneToMany('Belonger', filter=lambda c: c.stuff != None)
>
> When you are stuck like this, it usually helps to look at the tests of
> Elixir, which also serve as examples. I know that more visible
> examples would be nicer, but I just don't have time for that. In your
> case, see:
>
> http://elixir.ematia.de/trac/browser/elixir/tags/0.7.0/tests/test_o2m...
>
> --
> Gaëtan de Mentenhttp://openhex.org
--~--~---------~--~----~------------~-------~--~----~
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