mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-19 23:14:09 +02:00
Throw ExpandError for unknown in .extract_expand()
This commit is contained in:
parent
d1d780379c
commit
d39ac10c03
1 changed files with 7 additions and 0 deletions
|
|
@ -144,6 +144,10 @@ class InvalidColumns(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ExpandError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
_COUNTS_TABLE_CREATE_SQL = """
|
_COUNTS_TABLE_CREATE_SQL = """
|
||||||
CREATE TABLE IF NOT EXISTS [{}](
|
CREATE TABLE IF NOT EXISTS [{}](
|
||||||
[table] TEXT PRIMARY KEY,
|
[table] TEXT PRIMARY KEY,
|
||||||
|
|
@ -1168,6 +1172,9 @@ class Table(Queryable):
|
||||||
for new_row in expanded:
|
for new_row in expanded:
|
||||||
new_pk = self.db[table].insert(new_row, pk="id", replace=True).last_pk
|
new_pk = self.db[table].insert(new_row, pk="id", replace=True).last_pk
|
||||||
self.update(row_pk, {fk_column: new_pk})
|
self.update(row_pk, {fk_column: new_pk})
|
||||||
|
else:
|
||||||
|
raise ExpandError("expanded value needs to be list or dict")
|
||||||
|
|
||||||
# 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