agateblue / lifter

A generic query engine, inspired by Django ORM
ISC License
449 stars 16 forks source link

Adds the functionality to allow nested lookups work within iterables. #6

Closed Ogreman closed 8 years ago

Ogreman commented 8 years ago

Added tests from example within issue #3.

Follows the EAFP pattern used in resolve_attr, and creates an object which is used to check whether a value is present in a given iterable.

agateblue commented 8 years ago

I'm glad to see someone working on this.

Your implementation seems pretty slick, but I'm not sure how it behaves with nested lookups on iterables. For example, what happens when you run lifter.load(companies); manager.filter(users__tags__name='nice', assuming both users and tags are iterables ?

(Cannot test this right now, this is why I ask, but I'll try it by myself as soon at possible)

EDIT: I've updated the issue with a more complete example.

Ogreman commented 8 years ago

Something like that?

agateblue commented 8 years ago

That's really impressive. I think the last minor issue remains with the test itself:

self.assertNotIn(users[1], manager.filter(employees__tags__name='friendly'))

# should be
self.assertNotIn(companies[1], manager.filter(employees__tags__name='friendly'))

Apart from that, I'm ready to merge.