mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-11 02:54:23 +02:00
Disallow square braces in column names, closes #86
This commit is contained in:
parent
685e6a1bb3
commit
b0ca657f49
2 changed files with 10 additions and 0 deletions
|
|
@ -245,6 +245,11 @@ class Database:
|
||||||
), "defaults set {} includes items not in columns {}".format(
|
), "defaults set {} includes items not in columns {}".format(
|
||||||
repr(set(defaults)), repr(set(columns.keys()))
|
repr(set(defaults)), repr(set(columns.keys()))
|
||||||
)
|
)
|
||||||
|
# Validate no columns contain '[' or ']' - #86
|
||||||
|
for column in columns.keys():
|
||||||
|
assert (
|
||||||
|
"[" not in column and "]" not in column
|
||||||
|
), "'[' and ']' cannot be used in column names"
|
||||||
column_items = list(columns.items())
|
column_items = list(columns.items())
|
||||||
if column_order is not None:
|
if column_order is not None:
|
||||||
column_items.sort(
|
column_items.sort(
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,11 @@ def test_create_table_with_bad_defaults(fresh_db):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_table_with_invalid_column_charactters(fresh_db):
|
||||||
|
with pytest.raises(AssertionError):
|
||||||
|
fresh_db.create_table("players", {"name[foo]": str})
|
||||||
|
|
||||||
|
|
||||||
def test_create_table_with_defaults(fresh_db):
|
def test_create_table_with_defaults(fresh_db):
|
||||||
table = fresh_db.create_table(
|
table = fresh_db.create_table(
|
||||||
"players",
|
"players",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue