| Hello, Is it possible to add a COUNT() collumn in a mapper object? So with every product object I would like to have the number of related stockproducts added. But Instead of doing it with eagerload and returning len(orderproducts), I would like to have it done with the COUNT function in SQL for performance reasons. Thanks Koen Like this: products = Table('products', engine, Column('id', Integer, Sequence('products_id_seq',optional=False), primary_key=True), Column('code', Unicode(255), nullable=False), Column('price', Numeric, nullable=False)) stockproducts = Table('stockproducts', engine, Column('id', Integer, Sequence('stockproducts_id_seq',optional=False), primary_key=True), Column('product_id', Integer, ForeignKey("products.id"), nullable=False), Column('serial', Unicode(50), nullable=True)) class Product(object): pass assign_mapper(Product, products) class StockProduct(object): pass assign_mapper(StockProduct, stockproducts) |
- [SQLObject] COUNT() in Mapper Koen Bok
- Re: [SQLObject] COUNT() in Mapper Oleg Broytmann
