I have a situation where I need to produce a select object, and then later,
one of the fields needs to be "zeroed" out conditionally.
so something like:
def select_ab(param):
from_obj = join(A, B, A.c.b == B.c.b)
return select([A.c.a, B.c.b, B.c.d], from_obj=from_obj).where(A.c.a ==
param)
...
sql_query = select_ab(34)
# Would like to do something like this:
if some_condition:
sql_query = sql_query.replace_column(B.c.d, literal(0))
engine.execute(sql_query)
I tried to hack together a "replace_column" function using
Select.with_only_columns, but as the documentation indicates, I need the
original list of columns in order to really do what I want to do, I can't
take the select's columns. And in my case, the original select's columns
are trapped inside the function select_ab. I'd like to be able to replace a
column on any arbitrary select if the column exists in the select.
Is there a way to do what I'm trying to do? Or do I just need to keep the
original columns around?
--
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.