Add support for .count() to Baked Queries

Issue #3897 resolved
Marcus Cobden
created an issue

The Baked Query API has support for all, first, get & one, to match the Query API, but no count method.

I could really use a count method right now! ;)

Comments (4)

  1. Michael Bayer repo owner

    here's how to do that:

        bq = self.bakery(lambda s: s.query(User))
        sess = Session()
        def count(q):
            col = func.count(literal_column('*'))
            return q.from_self(col)
        bq += count
        result = bq(session).first()[0]
  2. Log in to comment