I don't quite understand why SQLA generates this query. For some reason it 
wraps the union part into a separate select. How can I avoid this?

b_id = 2
s_id = 3
id = product.c.id
sel = select(
    [b_id, product.c.id],
).union(
    select([b_id, s_id])
)

ins = insert(product).from_select([
    product.c.id, product.c.other_id
    ],
    sel
)
print ins
# produces:
# INSERT INTO product (id, other_id) SELECT 2, id 
# FROM (SELECT 2, product.id AS id 
# FROM product UNION SELECT 2, 3)

# I would expect:
# INSERT INTO product (id, other_id) FROM 
#   SELECT 2, product.id AS id FROM product 
#   UNION 
#   SELECT 2, 3

Where is the additional `SELECT 2, id` coming from?

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

Reply via email to