Revision 3152
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
810 | 810 |
|
811 | 811 |
return insert_select(db, table, cols, query, *args, **kw_args) |
812 | 812 |
|
813 |
def mk_update(db, table, changes=None, cond=None, in_place=False): |
|
813 |
def mk_update(db, table, changes=None, cond=None, in_place=False, |
|
814 |
cacheable=True): |
|
814 | 815 |
''' |
815 | 816 |
@param changes [(col, new_value),...] |
816 | 817 |
* container can be any iterable type |
... | ... | |
820 | 821 |
@param in_place If set, locks the table and updates rows in place. |
821 | 822 |
This avoids creating dead rows in PostgreSQL. |
822 | 823 |
* cond must be None |
824 |
@param cacheable Whether column structure information used to generate the |
|
825 |
query can be cached |
|
823 | 826 |
@return str query |
824 | 827 |
''' |
825 | 828 |
table = sql_gen.as_Table(table) |
... | ... | |
831 | 834 |
|
832 | 835 |
query = 'ALTER TABLE '+table.to_str(db)+'\n' |
833 | 836 |
query += ',\n'.join(('ALTER COLUMN '+c.to_str(db)+' TYPE ' |
834 |
+db.col_info(sql_gen.with_default_table(c, table)).type |
|
837 |
+db.col_info(sql_gen.with_default_table(c, table), cacheable).type
|
|
835 | 838 |
+'\nUSING '+v.to_str(db) for c, v in changes)) |
836 | 839 |
else: |
837 | 840 |
query = 'UPDATE '+table.to_str(db)+'\nSET\n' |
Also available in: Unified diff
sql.py: mk_update(): Added cacheable param to set whether column structure information used to generate the query can be cached