mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-14 13:24:11 +02:00
Preserve AUTOINCREMENT through transforms
This commit is contained in:
parent
fcfccea813
commit
2b52b5ed6f
5 changed files with 139 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ from sqlite_utils.create_table_parser import (
|
|||
Check,
|
||||
ColumnComments,
|
||||
ParseError,
|
||||
parse_autoincrement,
|
||||
parse_checks,
|
||||
parse_column_comments,
|
||||
)
|
||||
|
|
@ -117,6 +118,36 @@ def test_virtual_table_has_no_checks():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sql,expected",
|
||||
[
|
||||
(
|
||||
"CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)",
|
||||
"id",
|
||||
),
|
||||
(
|
||||
'CREATE TABLE t("quoted id" INTEGER PRIMARY KEY AUTOINCREMENT)',
|
||||
"quoted id",
|
||||
),
|
||||
(
|
||||
'CREATE TABLE t("autoincrement" INTEGER PRIMARY KEY, value TEXT)',
|
||||
None,
|
||||
),
|
||||
(
|
||||
"CREATE TABLE t(id INTEGER PRIMARY KEY /* AUTOINCREMENT */, value TEXT)",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"CREATE TABLE t(id INTEGER PRIMARY KEY, value TEXT CHECK(value != 'AUTOINCREMENT'))",
|
||||
None,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_autoincrement(sql, expected):
|
||||
sqlite3.connect(":memory:").execute(sql)
|
||||
assert parse_autoincrement(sql) == expected
|
||||
|
||||
|
||||
comment_or_space = st.sampled_from(
|
||||
[
|
||||
" ",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue