mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-11-22 01:49:54 +01:00
Allow column names to be reserved words
This commit is contained in:
parent
6ad9037c96
commit
228d595f7d
2 changed files with 5 additions and 1 deletions
|
|
@ -318,7 +318,7 @@ class Table:
|
||||||
""".format(
|
""".format(
|
||||||
upsert="OR REPLACE" if upsert else "",
|
upsert="OR REPLACE" if upsert else "",
|
||||||
table=self.name,
|
table=self.name,
|
||||||
columns=", ".join(all_columns),
|
columns=", ".join("[{}]".format(c) for c in all_columns),
|
||||||
rows=", ".join(
|
rows=", ".join(
|
||||||
"""
|
"""
|
||||||
({placeholders})
|
({placeholders})
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ def test_create_table(fresh_db):
|
||||||
{"name": "Ravi", "age": 63},
|
{"name": "Ravi", "age": 63},
|
||||||
[{"name": "name", "type": "TEXT"}, {"name": "age", "type": "INTEGER"}],
|
[{"name": "name", "type": "TEXT"}, {"name": "age", "type": "INTEGER"}],
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{"create": "Reserved word", "table": "Another"},
|
||||||
|
[{"name": "create", "type": "TEXT"}, {"name": "table", "type": "TEXT"}],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_create_table_from_example(fresh_db, example, expected_columns):
|
def test_create_table_from_example(fresh_db, example, expected_columns):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue