Revert "Support for generated columns, closes #1116" - it failed CI

This reverts commit 37f87b5e52.
This commit is contained in:
Simon Willison 2020-11-30 12:09:22 -08:00
commit dea3c508b3
3 changed files with 8 additions and 76 deletions

View file

@ -1,6 +1,5 @@
from datasette.app import Datasette
from datasette.plugins import DEFAULT_PLUGINS
from datasette.utils import detect_json1, sqlite3
from datasette.utils import detect_json1
from datasette.version import __version__
from .fixtures import ( # noqa
app_client,
@ -515,14 +514,7 @@ def test_database_page(app_client):
},
{
"name": "searchable_fts",
"columns": [
"text1",
"text2",
"name with . and spaces",
"searchable_fts",
"docid",
"__langid",
],
"columns": ["text1", "text2", "name with . and spaces"],
"primary_keys": [],
"count": 2,
"hidden": True,
@ -1921,46 +1913,3 @@ def test_paginate_using_link_header(app_client, qs):
else:
path = None
assert num_pages == 21
@pytest.mark.skipif(
tuple(
map(
int,
sqlite3.connect(":memory:")
.execute("select sqlite_version()")
.fetchone()[0]
.split("."),
)
)
< (3, 31, 0),
reason="generated columns were added in SQLite 3.31.0",
)
@pytest.mark.asyncio
async def test_generated_columns_are_visible_in_datasette(tmp_path_factory):
db_directory = tmp_path_factory.mktemp("dbs")
db_path = db_directory / "test.db"
conn = sqlite3.connect(str(db_path))
conn.executescript(
"""
CREATE TABLE deeds (
body TEXT,
id INT GENERATED ALWAYS AS (json_extract(body, '$.id')) STORED,
consideration INT GENERATED ALWAYS AS (json_extract(body, '$.consideration')) STORED
);
INSERT INTO deeds (body) VALUES ('{
"id": 1,
"consideration": "This is the consideration"
}');
"""
)
datasette = Datasette([db_path])
response = await datasette.client.get("/test/deeds.json?_shape=array")
assert response.json() == [
{
"rowid": 1,
"body": '{\n "id": 1,\n "consideration": "This is the consideration"\n }',
"id": 1,
"consideration": "This is the consideration",
}
]