mirror of
https://github.com/simonw/datasette.git
synced 2026-06-23 09:14:34 +02:00
Removed the alter table dry run feature
It works by doing conn.backup(memory_conn) which could use a lot of memory for a large database.
This commit is contained in:
parent
c4aead65ee
commit
084df1fba2
3 changed files with 12 additions and 47 deletions
|
|
@ -898,34 +898,6 @@ async def test_alter_table_operations(ds_write):
|
|||
assert event.after_schema == data["schema"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_alter_table_dry_run(ds_write):
|
||||
token = write_token(ds_write, permissions=["at"])
|
||||
db = ds_write.get_database("data")
|
||||
response = await ds_write.client.post(
|
||||
"/data/docs/-/alter",
|
||||
json={
|
||||
"dry_run": True,
|
||||
"operations": [
|
||||
{"op": "add_column", "args": {"name": "slug", "type": "text"}}
|
||||
],
|
||||
},
|
||||
headers=_headers(token),
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
data = response.json()
|
||||
assert data["ok"] is True
|
||||
assert data["dry_run"] is True
|
||||
assert data["altered"] is True
|
||||
assert data["operations_applied"] == 0
|
||||
assert "slug" in data["schema"]
|
||||
columns = (
|
||||
await db.execute("select name from pragma_table_info('docs') order by cid")
|
||||
).dicts()
|
||||
assert [column["name"] for column in columns] == ["id", "title", "score", "age"]
|
||||
assert last_event(ds_write) is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_alter_table_foreign_key_operations(ds_write):
|
||||
token = write_token(ds_write, permissions=["at"])
|
||||
|
|
@ -1246,6 +1218,15 @@ async def test_alter_table_permission_denied(ds_write):
|
|||
@pytest.mark.parametrize(
|
||||
"body,expected_error",
|
||||
(
|
||||
(
|
||||
{
|
||||
"dry_run": True,
|
||||
"operations": [
|
||||
{"op": "add_column", "args": {"name": "slug", "type": "text"}}
|
||||
],
|
||||
},
|
||||
"dry_run: Extra inputs are not permitted",
|
||||
),
|
||||
(
|
||||
{"operations": [{"op": "add_column", "args": {"type": "text"}}]},
|
||||
"operations.0.add_column.args.name: Field required",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue