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
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