mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-28 04:44:26 +02:00
Support lists in .extract_expand()
This commit is contained in:
parent
8d641ab08a
commit
d1d780379c
1 changed files with 4 additions and 0 deletions
|
|
@ -1164,6 +1164,10 @@ class Table(Queryable):
|
||||||
if isinstance(expanded, dict):
|
if isinstance(expanded, dict):
|
||||||
new_pk = self.db[table].insert(expanded, pk="id", replace=True).last_pk
|
new_pk = self.db[table].insert(expanded, pk="id", replace=True).last_pk
|
||||||
self.update(row_pk, {fk_column: new_pk})
|
self.update(row_pk, {fk_column: new_pk})
|
||||||
|
elif isinstance(expanded, list):
|
||||||
|
for new_row in expanded:
|
||||||
|
new_pk = self.db[table].insert(new_row, pk="id", replace=True).last_pk
|
||||||
|
self.update(row_pk, {fk_column: new_pk})
|
||||||
# Can drop the original column now
|
# Can drop the original column now
|
||||||
self.transform(drop=[column])
|
self.transform(drop=[column])
|
||||||
# And add that foreign key
|
# And add that foreign key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue