Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track alter-event in all the right places #57

Merged
merged 5 commits into from Feb 18, 2024
Merged

Track alter-event in all the right places #57

merged 5 commits into from Feb 18, 2024

Conversation

simonw
Copy link
Owner

@simonw simonw commented Feb 16, 2024

We are not supporting pre-Datasette 1.0a9 any more
@simonw simonw changed the title Track alter event Track alter events in all the right places Feb 16, 2024
@simonw
Copy link
Owner Author

simonw commented Feb 16, 2024

This is actually harder than I thought, because there are a bunch of functions that need to be tracked independently:

if formdata.get("action") == "update_foreign_keys":
return await update_foreign_keys(
request, datasette, database, table, formdata
)
elif formdata.get("action") == "update_primary_key":
return await update_primary_key(
request, datasette, database, table, formdata
)
elif "drop_table" in formdata:
return await drop_table(request, datasette, database, table)
elif "add_column" in formdata:
return await add_column(request, datasette, database, table, formdata)
elif "rename_table" in formdata:
return await rename_table(request, datasette, database, table, formdata)
elif "add_index" in formdata:
column = formdata.get("add_index_column") or ""
unique = formdata.get("add_index_unique")
return await add_index(request, datasette, database, table, column, unique)
elif any(key.startswith("drop_index_") for key in formdata.keys()):
return await drop_index(request, datasette, database, table, formdata)
else:
return Response.html("Unknown operation", status=400)

I think this will be easier if I do the trick where I check the schema before and after and record the event if the schema changed, no matter which code path was taken.

@simonw simonw changed the title Track alter events in all the right places Track alter-event in all the right places Feb 18, 2024
@simonw simonw merged commit e64e0b8 into main Feb 18, 2024
10 checks passed
@simonw simonw deleted the track-alter-event branch February 18, 2024 17:23
simonw added a commit that referenced this pull request Feb 18, 2024
Switch setup.py to pyproject.toml

Refs #22, #45, #46, #47, #49, #50, #51, #52, #53, #54, #55, #56, #57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant