s = select([func.coalesce(func.avg(product_flavor_t.c.size), 0).label('f1'),
            func.count(product_flavor_t.c.id).label('f2')]).\
    select_from(product_t.outerjoin(product_flavor_t))
op.execute(product_t.update().values(servings=s.c.f1, flavors_count=s.c.f2))


I tried that, but it doesn't work as expected ((


I got UPDATE without SELECT :

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column "f1" does 
not exist
LINE 1: UPDATE product SET servings=f1, flavors_count=f2



And PostgreSQL log file contains:


statement: ALTER TABLE product ADD COLUMN servings INTEGER
statement: ALTER TABLE product ADD COLUMN flavors_count INTEGER


statement: UPDATE product SET servings=f1, flavors_count=f2
ERROR:  column "f1" does not exist at character 29
STATEMENT:  UPDATE product SET servings=f1, flavors_count=f2

statement: ROLLBACK


-- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to