Revision 2768
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1136 | 1136 |
@return sql_gen.Col Where the output pkeys are made available |
1137 | 1137 |
''' |
1138 | 1138 |
out_table = sql_gen.as_Table(out_table) |
1139 |
assert mapping != {} |
|
1140 | 1139 |
|
1141 | 1140 |
def log_debug(msg): db.log_debug(msg, level=1.5) |
1142 | 1141 |
def col_ustr(str_): |
1143 | 1142 |
return strings.repr_no_u(sql_gen.remove_col_rename(str_)) |
1144 | 1143 |
|
1144 |
out_pkey = pkey(db, out_table, recover=True) |
|
1145 |
out_pkey_col = sql_gen.as_Col(out_pkey, out_table) |
|
1146 |
|
|
1147 |
if mapping == {}: # need at least one column for INSERT SELECT |
|
1148 |
mapping = {out_pkey: None} # ColDict will replace with default value |
|
1149 |
|
|
1145 | 1150 |
log_debug('********** New iteration **********') |
1146 | 1151 |
log_debug('Inserting these input columns into '+strings.as_tt( |
1147 | 1152 |
out_table.to_str(db))+':\n'+strings.as_table(mapping, ustr=col_ustr)) |
... | ... | |
1184 | 1189 |
+' does not exist in mapping, falling back to None', level=2.1) |
1185 | 1190 |
default = None |
1186 | 1191 |
|
1187 |
out_pkey = pkey(db, out_table, recover=True) |
|
1188 |
out_pkey_col = sql_gen.as_Col(out_pkey, out_table) |
|
1189 |
|
|
1190 | 1192 |
pkeys_names = [in_pkey, out_pkey] |
1191 | 1193 |
pkeys_cols = [in_pkey_col, out_pkey_col] |
1192 | 1194 |
|
Also available in: Unified diff
sql.py: put_table(): Support inserting tables with all default values, by providing the pkey's default value for all rows so that the SELECT query has at least one column