mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 18:34:32 +02:00
table.virtual_table_using property, closes #196
This commit is contained in:
parent
43eae8b193
commit
59d8689ed0
3 changed files with 81 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from sqlite_utils.db import Index, View
|
||||
from sqlite_utils.db import Index, View, Database
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
@ -142,3 +142,49 @@ def test_triggers(fresh_db):
|
|||
(t.name, t.table) for t in fresh_db["authors"].triggers
|
||||
}
|
||||
assert [] == fresh_db["other"].triggers
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sql,expected_name,expected_using",
|
||||
[
|
||||
(
|
||||
"""
|
||||
CREATE VIRTUAL TABLE foo USING FTS5(name)
|
||||
""",
|
||||
"foo",
|
||||
"FTS5",
|
||||
),
|
||||
(
|
||||
"""
|
||||
CREATE VIRTUAL TABLE "foo" USING FTS4(name)
|
||||
""",
|
||||
"foo",
|
||||
"FTS4",
|
||||
),
|
||||
(
|
||||
"""
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS `foo` USING FTS4(name)
|
||||
""",
|
||||
"foo",
|
||||
"FTS4",
|
||||
),
|
||||
(
|
||||
"""
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS `foo` USING fts5(name)
|
||||
""",
|
||||
"foo",
|
||||
"FTS5",
|
||||
),
|
||||
(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS `foo` (id integer primary key)
|
||||
""",
|
||||
"foo",
|
||||
None,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_virtual_table_using(sql, expected_name, expected_using):
|
||||
db = Database(memory=True)
|
||||
db.execute(sql)
|
||||
assert db[expected_name].virtual_table_using == expected_using
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue