Hi All -
I'm currently trying to use sql.union() to construct a union of
sql.select() instances. My problem is that one of the columns in one of
the selects is an expression that takes a bind parameter, which is causing
an error.
I initially tried to code things as follows ...
from sqlalchemy.sql import *
s1 = select([text("(:value || c3) as c1").bindparams(value='foo'),
column("c2")], from_obj=table("t1"))
s2 = select([column("c1"), column("c2")], from_obj=table("t2"))
u1 = union(s1, s2)
... however, union() throws* 'Argument Error: All selectables passed to
CompoundSelect must have identical numbers of columns'.*
Tracking this down, the problem seems to be that the first column of s1 is
a text() object, which doesn't get counted as a column when union() tries
to compare the column counts of the two select() clauses.
I've tried using literal_column(), but it doesn't support passing in a
text() element as it's value, nor does it have a bindparams() method.
I've run out of ideas for how to provide something "column-like" for
union(), while at the same time safely use bindparams() to pass in a
value.
I'm not sure if this is a bug, or if there's another construction I should
be using.
- Eli Collins
(P.S. I'm using SQLAlchemy 1.0.6; Python 2.7)
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.