mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-17 14:04:11 +02:00
Ability to list just FTS4 or FTS5 table names
This commit is contained in:
parent
231224ba1a
commit
66fd63b119
8 changed files with 53 additions and 22 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from sqlite_utils import cli
|
||||
from sqlite_utils import cli, Database
|
||||
from click.testing import CliRunner
|
||||
import pytest
|
||||
import sqlite3
|
||||
|
|
@ -23,6 +23,18 @@ def test_table_names(db_path):
|
|||
assert "Gosh\nGosh2" == result.output.strip()
|
||||
|
||||
|
||||
def test_table_names_fts4(db_path):
|
||||
Database(db_path)["Gosh"].enable_fts(["c2"], fts_version="FTS4")
|
||||
result = CliRunner().invoke(cli.cli, ["table_names", "--fts4", db_path])
|
||||
assert "Gosh_fts" == result.output.strip()
|
||||
|
||||
|
||||
def test_table_names_fts5(db_path):
|
||||
Database(db_path)["Gosh"].enable_fts(["c2"], fts_version="FTS5")
|
||||
result = CliRunner().invoke(cli.cli, ["table_names", "--fts5", db_path])
|
||||
assert "Gosh_fts" == result.output.strip()
|
||||
|
||||
|
||||
def test_vacuum(db_path):
|
||||
result = CliRunner().invoke(cli.cli, ["vacuum", db_path])
|
||||
assert 0 == result.exit_code
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import json
|
|||
|
||||
|
||||
def test_create_table(fresh_db):
|
||||
assert [] == fresh_db.table_names
|
||||
assert [] == fresh_db.table_names()
|
||||
table = fresh_db.create_table(
|
||||
"test_table",
|
||||
{
|
||||
|
|
@ -18,7 +18,7 @@ def test_create_table(fresh_db):
|
|||
"datetime_col": datetime.datetime,
|
||||
},
|
||||
)
|
||||
assert ["test_table"] == fresh_db.table_names
|
||||
assert ["test_table"] == fresh_db.table_names()
|
||||
assert [
|
||||
{"name": "text_col", "type": "TEXT"},
|
||||
{"name": "float_col", "type": "FLOAT"},
|
||||
|
|
@ -44,7 +44,7 @@ def test_create_table(fresh_db):
|
|||
)
|
||||
def test_create_table_from_example(fresh_db, example, expected_columns):
|
||||
fresh_db["people"].insert(example)
|
||||
assert ["people"] == fresh_db.table_names
|
||||
assert ["people"] == fresh_db.table_names()
|
||||
assert expected_columns == [
|
||||
{"name": col.name, "type": col.type} for col in fresh_db["people"].columns
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ search_records = [
|
|||
def test_enable_fts(fresh_db):
|
||||
table = fresh_db["searchable"]
|
||||
table.insert_all(search_records)
|
||||
assert ["searchable"] == fresh_db.table_names
|
||||
assert ["searchable"] == fresh_db.table_names()
|
||||
table.enable_fts(["text", "country"], fts_version="FTS4")
|
||||
assert [
|
||||
"searchable",
|
||||
|
|
@ -16,7 +16,7 @@ def test_enable_fts(fresh_db):
|
|||
"searchable_fts_segdir",
|
||||
"searchable_fts_docsize",
|
||||
"searchable_fts_stat",
|
||||
] == fresh_db.table_names
|
||||
] == fresh_db.table_names()
|
||||
assert [("tanuki are tricksters", "Japan", "foo")] == table.search("tanuki")
|
||||
assert [("racoons are trash pandas", "USA", "bar")] == table.search("usa")
|
||||
assert [] == table.search("bar")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,13 @@ from sqlite_utils.db import Index
|
|||
|
||||
|
||||
def test_table_names(existing_db):
|
||||
assert ["foo"] == existing_db.table_names
|
||||
assert ["foo"] == existing_db.table_names()
|
||||
|
||||
|
||||
def test_table_names_fts4(existing_db):
|
||||
existing_db["woo"].insert({"title": "Hello"})
|
||||
existing_db["woo"].enable_fts(["title"], fts_version="FTS4")
|
||||
assert ["woo_fts"] == existing_db.table_names(fts4=True)
|
||||
|
||||
|
||||
def test_tables(existing_db):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue