mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New JSON design for query views (#2118)
* Refs #2111, closes #2110 * New Context dataclass/subclass mechanism, refs #2127 * Define QueryContext and extract get_tables() method, refs #2127 * Fix OPTIONS bug by porting DaatbaseView to be a View subclass * Expose async_view_for_class.view_class for test_routes test * Error/truncated aruments for renderers, closes #2130
This commit is contained in:
parent
5139c0886a
commit
1377a290cd
15 changed files with 579 additions and 112 deletions
|
|
@ -638,22 +638,21 @@ def test_database_page_for_database_with_dot_in_name(app_client_with_dot):
|
|||
@pytest.mark.asyncio
|
||||
async def test_custom_sql(ds_client):
|
||||
response = await ds_client.get(
|
||||
"/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects"
|
||||
"/fixtures.json?sql=select+content+from+simple_primary_key"
|
||||
)
|
||||
data = response.json()
|
||||
assert {"sql": "select content from simple_primary_key", "params": {}} == data[
|
||||
"query"
|
||||
]
|
||||
assert [
|
||||
{"content": "hello"},
|
||||
{"content": "world"},
|
||||
{"content": ""},
|
||||
{"content": "RENDER_CELL_DEMO"},
|
||||
{"content": "RENDER_CELL_ASYNC"},
|
||||
] == data["rows"]
|
||||
assert ["content"] == data["columns"]
|
||||
assert "fixtures" == data["database"]
|
||||
assert not data["truncated"]
|
||||
assert data == {
|
||||
"rows": [
|
||||
{"content": "hello"},
|
||||
{"content": "world"},
|
||||
{"content": ""},
|
||||
{"content": "RENDER_CELL_DEMO"},
|
||||
{"content": "RENDER_CELL_ASYNC"},
|
||||
],
|
||||
"columns": ["content"],
|
||||
"ok": True,
|
||||
"truncated": False,
|
||||
}
|
||||
|
||||
|
||||
def test_sql_time_limit(app_client_shorter_time_limit):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue