mirror of
https://github.com/simonw/datasette.git
synced 2026-11-15 06:38:35 +01:00
test: keep WITHOUT ROWID readback within SQLite variable limits
Query inserted rows by each explicit primary key tuple to preserve request order and avoid a combined query exceeding older SQLite parameter limits.
This commit is contained in:
parent
35dc60041a
commit
ad20db2ef8
2 changed files with 32 additions and 9 deletions
|
|
@ -487,6 +487,30 @@ async def test_insert_rows_into_without_rowid_table_preserves_return_order(ds_wr
|
|||
assert response.json()["rows"] == rows
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skipif(
|
||||
not hasattr(sqlite3.Connection, "setlimit"),
|
||||
reason="SQLite variable limit controls require Python 3.11",
|
||||
)
|
||||
async def test_insert_rows_into_without_rowid_table_respects_variable_limit(ds_write):
|
||||
db = ds_write.get_database("data")
|
||||
await db.execute_write(
|
||||
"create table compound_without_rowid (a text, b text, "
|
||||
"primary key (a, b)) without rowid"
|
||||
)
|
||||
await db.execute_write_fn(
|
||||
lambda conn: conn.setlimit(sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER, 4)
|
||||
)
|
||||
rows = [{"a": str(i), "b": "value"} for i in range(3)]
|
||||
response = await ds_write.client.post(
|
||||
"/data/compound_without_rowid/-/insert",
|
||||
json={"rows": rows, "return": True},
|
||||
headers=_headers(write_token(ds_write)),
|
||||
)
|
||||
assert response.status_code == 201, response.json()
|
||||
assert response.json()["rows"] == rows
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_insert_row_alter(ds_write):
|
||||
token = write_token(ds_write)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue