[sqlalchemy] Re: Need help with update + select query

2016-02-25 Thread sector119
product_t = Product.__table__ product_flavor_t = ProductFlavor.__table__ product_t_a = product_t.alias() op.add_column(u'product', sa.Column('servings', sa.Integer(), nullable=True)) op.add_column(u'product', sa.Column('flavors_count', sa.Integer(), nullable=True)) servings = select([func.coal

[sqlalchemy] Re: Need help with update + select query

2016-02-25 Thread sector119
Postgresql doesn't support this yet, so I have to use separate query all aggregates (( SET (servings, flavors_count) = ( SELECT coalesce(avg(f.size), 0), count(f.id) FROM product p LEFT OUTER JOIN product_flavor f ON p.id = f.product_id WHERE product.id = p.id четверг, 2