mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Introduce new /$DB/-/query endpoint, soft replaces /$DB?sql=... (#2363)
* Introduce new default /$DB/-/query endpoint * Fix a lot of tests * Update pyodide test to use query endpoint * Link to /fixtures/-/query in a few places * Documentation for QueryView --------- Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
parent
56adfff8d2
commit
a23c2aee00
21 changed files with 148 additions and 83 deletions
|
|
@ -637,7 +637,9 @@ async def test_delete_row(ds_write, table, row_for_create, pks, delete_path):
|
|||
# Should be a single row
|
||||
assert (
|
||||
await ds_write.client.get(
|
||||
"/data.json?_shape=arrayfirst&sql=select+count(*)+from+{}".format(table)
|
||||
"/data/-/query.json?_shape=arrayfirst&sql=select+count(*)+from+{}".format(
|
||||
table
|
||||
)
|
||||
)
|
||||
).json() == [1]
|
||||
# Now delete the row
|
||||
|
|
@ -645,7 +647,9 @@ async def test_delete_row(ds_write, table, row_for_create, pks, delete_path):
|
|||
# Special case for that rowid table
|
||||
delete_path = (
|
||||
await ds_write.client.get(
|
||||
"/data.json?_shape=arrayfirst&sql=select+rowid+from+{}".format(table)
|
||||
"/data/-/query.json?_shape=arrayfirst&sql=select+rowid+from+{}".format(
|
||||
table
|
||||
)
|
||||
)
|
||||
).json()[0]
|
||||
|
||||
|
|
@ -663,7 +667,9 @@ async def test_delete_row(ds_write, table, row_for_create, pks, delete_path):
|
|||
assert event.pks == str(delete_path).split(",")
|
||||
assert (
|
||||
await ds_write.client.get(
|
||||
"/data.json?_shape=arrayfirst&sql=select+count(*)+from+{}".format(table)
|
||||
"/data/-/query.json?_shape=arrayfirst&sql=select+count(*)+from+{}".format(
|
||||
table
|
||||
)
|
||||
)
|
||||
).json() == [0]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue