On 27 май, 18:22, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On May 27, 2009, at 4:25 AM, Denis S. Otkidach wrote:
> >> class LimitingQuery(Query):
> >>     def get(self, ident):
> >>         return Query.get(self.populate_existing(), ident)
>
> >>     def __iter__(self):
> >>         return Query.__iter__(self.private())
>
> >>     @_generative()
> >>     def private(self):
> >>         crit = (self._entities[0].mapper.class_.public == True)
> >>         if self._criterion:
> >>             self._criterion &= crit
> >>         else:
> >>             self._criterion = crit
>
> >> full test case attached.
>
> > Thanks a lot! But the test doesn't cover all use-cases. Here is one
> > that fails:
>
> > count1 = sess.query(Address).count()
> > count2 = len(sess.query(Address).all())
> > assert count1==count2, '%d!=%d' % (count1, count2)
>
> you'd have to hack .count() as well in a similar fashion.

Probably I have to hack something to insure proper subqueries
construction. I believe this is wrong way. Hacked .get()
and .from_statement() method guarantee that if missed something I'll
get an exception, while in this case I have to come over hard to
detect bug first (and even seeing the bug doesn't point me to yet
another method I have to fix).

I'll try to use my query with get() and from_statement() hacked and
fallback to filtering everything manually if it won't work.
--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to