Revision 3058
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
775 | 775 |
if in_place: |
776 | 776 |
assert len(changes) == 1 |
777 | 777 |
assert cond == None |
778 |
|
|
779 |
col, value = changes[0] |
|
780 |
type_ = db.col_info(sql_gen.with_default_table(col, table)).type |
|
781 |
|
|
782 |
query = ('ALTER TABLE '+table.to_str(db)+' ALTER COLUMN '+col.to_str(db) |
|
783 |
+' TYPE '+type_+'\nUSING '+value.to_str(db)) |
|
784 |
else: |
|
785 |
query = 'UPDATE '+table.to_str(db)+'\nSET\n' |
|
786 |
query += ',\n'.join((c.to_str(db)+' = '+v.to_str(db) |
|
787 |
for c, v in changes)) |
|
788 |
if cond != None: query += '\nWHERE\n'+cond.to_str(db) |
|
778 | 789 |
|
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)) |
|
781 |
if cond != None: query += '\nWHERE\n'+cond.to_str(db) |
|
782 |
|
|
783 | 790 |
return query |
784 | 791 |
|
785 | 792 |
def update(db, *args, **kw_args): |
Also available in: Unified diff
sql.py: mk_update(): Implemented in_place mode