oh, forgot to mention:

* this occurs even with a filter that's supposed to bring one register only (at the database level it works); * in the database level, a count *without* the where clause brings the result i mentioned earlier.


thanks,
richard.


On 07/15/2015 03:11 PM, Richard Gerd Kuesters wrote:
hello!

i'm encountering a weird behaviur with session.count() when using a custom mapper that implements a where condition to every session.

first, what is happening:

>>> len(session.query(Entity).all()) == 1
>>> session.query(Entity).count() == 2

"Entity" is a base polymorphic entity, inherited by other classes.

my custom mapper:

class DeletedOption(MapperOption):
    propagate_to_loaders = True

    def process_query(self, query):
        mzo = query._mapper_zero()
        if hasattr(mzo, 'class_'):
            parent_cls = mzo.class_
            filter_crit = parent_cls.rm_timestamp == 0

        if query._criterion is None:
            query._criterion = filter_crit
        else:
            query._criterion = query._criterion & filter_crit


i remember getting this custom mapper option in a recipe ... i'm running sqla 1.0.6. if there's any information i can provide to enlighten this out, please let me know.

best regards,
richard.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

<<attachment: richard.vcf>>

Reply via email to