mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Add more STRICT table support (#604)
* Add more STRICT table support per https://github.com/simonw/sqlite-utils/issues/344#issuecomment-982014776. * Make `table.transform()` preserve STRICT mode. * Fix mypy failures in PR #604 * Link to SQLITE strict page in a few places
This commit is contained in:
parent
88bd372205
commit
1500c19bd0
9 changed files with 182 additions and 5 deletions
|
|
@ -909,6 +909,12 @@ def insert_upsert_options(*, require_pk=False):
|
|||
),
|
||||
load_extension_option,
|
||||
click.option("--silent", is_flag=True, help="Do not show progress bar"),
|
||||
click.option(
|
||||
"--strict",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Apply STRICT mode to created table",
|
||||
),
|
||||
)
|
||||
):
|
||||
fn = decorator(fn)
|
||||
|
|
@ -951,6 +957,7 @@ def insert_upsert_implementation(
|
|||
silent=False,
|
||||
bulk_sql=None,
|
||||
functions=None,
|
||||
strict=False,
|
||||
):
|
||||
db = sqlite_utils.Database(path)
|
||||
_load_extensions(db, load_extension)
|
||||
|
|
@ -1066,6 +1073,7 @@ def insert_upsert_implementation(
|
|||
"replace": replace,
|
||||
"truncate": truncate,
|
||||
"analyze": analyze,
|
||||
"strict": strict,
|
||||
}
|
||||
if not_null:
|
||||
extra_kwargs["not_null"] = set(not_null)
|
||||
|
|
@ -1186,6 +1194,7 @@ def insert(
|
|||
truncate,
|
||||
not_null,
|
||||
default,
|
||||
strict,
|
||||
):
|
||||
"""
|
||||
Insert records from FILE into a table, creating the table if it
|
||||
|
|
@ -1264,6 +1273,7 @@ def insert(
|
|||
silent=silent,
|
||||
not_null=not_null,
|
||||
default=default,
|
||||
strict=strict,
|
||||
)
|
||||
except UnicodeDecodeError as ex:
|
||||
raise click.ClickException(UNICODE_ERROR.format(ex))
|
||||
|
|
@ -1299,6 +1309,7 @@ def upsert(
|
|||
analyze,
|
||||
load_extension,
|
||||
silent,
|
||||
strict,
|
||||
):
|
||||
"""
|
||||
Upsert records based on their primary key. Works like 'insert' but if
|
||||
|
|
@ -1343,6 +1354,7 @@ def upsert(
|
|||
analyze=analyze,
|
||||
load_extension=load_extension,
|
||||
silent=silent,
|
||||
strict=strict,
|
||||
)
|
||||
except UnicodeDecodeError as ex:
|
||||
raise click.ClickException(UNICODE_ERROR.format(ex))
|
||||
|
|
@ -1511,6 +1523,11 @@ def create_database(path, enable_wal, init_spatialite, load_extension):
|
|||
help="If table already exists, try to transform the schema",
|
||||
)
|
||||
@load_extension_option
|
||||
@click.option(
|
||||
"--strict",
|
||||
is_flag=True,
|
||||
help="Apply STRICT mode to created table",
|
||||
)
|
||||
def create_table(
|
||||
path,
|
||||
table,
|
||||
|
|
@ -1523,6 +1540,7 @@ def create_table(
|
|||
replace,
|
||||
transform,
|
||||
load_extension,
|
||||
strict,
|
||||
):
|
||||
"""
|
||||
Add a table with the specified columns. Columns should be specified using
|
||||
|
|
@ -1570,6 +1588,7 @@ def create_table(
|
|||
ignore=ignore,
|
||||
replace=replace,
|
||||
transform=transform,
|
||||
strict=strict,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue