Skip to content

Commit

Permalink
Allow column names to be reserved words
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 25, 2019
1 parent 6ad9037 commit 228d595
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlite_utils/db.py
Expand Up @@ -318,7 +318,7 @@ def insert_all(
""".format(
upsert="OR REPLACE" if upsert else "",
table=self.name,
columns=", ".join(all_columns),
columns=", ".join("[{}]".format(c) for c in all_columns),
rows=", ".join(
"""
({placeholders})
Expand Down
4 changes: 4 additions & 0 deletions tests/test_create.py
Expand Up @@ -36,6 +36,10 @@ def test_create_table(fresh_db):
{"name": "Ravi", "age": 63},
[{"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):
Expand Down

0 comments on commit 228d595

Please sign in to comment.