mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
parent
815b6a7d3d
commit
6225eba5c8
3 changed files with 35 additions and 0 deletions
|
|
@ -4229,6 +4229,24 @@ class Table(Queryable):
|
|||
if hash_id:
|
||||
pk = hash_id
|
||||
|
||||
if pk and not hash_id and self.exists():
|
||||
pk_cols = [pk] if isinstance(pk, str) else list(pk)
|
||||
existing_columns = self.columns_dict
|
||||
missing_pk_cols = [
|
||||
col
|
||||
for col in pk_cols
|
||||
if resolve_casing(col, existing_columns) not in existing_columns
|
||||
]
|
||||
if missing_pk_cols:
|
||||
raise InvalidColumns(
|
||||
"Invalid primary key column{} {} for table {} with columns {}".format(
|
||||
"s" if len(missing_pk_cols) > 1 else "",
|
||||
missing_pk_cols,
|
||||
self.name,
|
||||
list(existing_columns),
|
||||
)
|
||||
)
|
||||
|
||||
if ignore and replace:
|
||||
raise ValueError("Use either ignore=True or replace=True, not both")
|
||||
all_columns = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue