Revision 3057
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
768 | 768 |
* cond must be None |
769 | 769 |
@return str query |
770 | 770 |
''' |
771 |
table = sql_gen.as_Table(table) |
|
772 |
changes = [(sql_gen.to_name_only_col(c, table), sql_gen.as_Value(v)) |
|
773 |
for c, v in changes] |
|
774 |
|
|
771 | 775 |
if in_place: |
772 | 776 |
assert len(changes) == 1 |
773 | 777 |
assert cond == None |
774 | 778 |
|
775 |
query = 'UPDATE '+sql_gen.as_Table(table).to_str(db)+'\nSET\n' |
|
776 |
query += ',\n'.join((sql_gen.to_name_only_col(col, table).to_str(db)+' = ' |
|
777 |
+sql_gen.as_Value(new_value).to_str(db) for col, new_value in changes)) |
|
779 |
query = 'UPDATE '+table.to_str(db)+'\nSET\n' |
|
780 |
query += ',\n'.join((c.to_str(db)+' = '+v.to_str(db) for c, v in changes)) |
|
778 | 781 |
if cond != None: query += '\nWHERE\n'+cond.to_str(db) |
779 | 782 |
|
780 | 783 |
return query |
Also available in: Unified diff
sql.py: mk_update(): Factored out filtering of input values so only `.to_str(db)` is used inline in the creation of the query