Skip to content

✨ Allow deleting all rows from a table #1349

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jnewbery
Copy link

The sqlmodel docs explain how to delete a single row from a table.

It's also useful to be able to delete multiple rows (or even all rows) at the same time. See https://stackoverflow.com/questions/76648956/how-to-delete-all-rows-matching-a-condition-using-sqlmodel for example.

session.exec(delete(Table)) works fine, but triggers a type warning:

Pyright: Error: No overloads for "exec" match the provided arguments [reportCallIssue]
Pyright: Error: Argument of type "Delete" cannot be assigned to parameter "statement" of type "SelectOfScalar[_TSelectParam@exec]" in function "exec"
  "Delete" is not assignable to "SelectOfScalar[_TSelectParam@exec]" [reportArgumentType]

Adding an additional overload to Session.exec() allows this syntax to be used.

@svlandeg svlandeg changed the title Allow session.exec(delete(Table)) to delete all rows from a table ✨ Allow deleting all rows from a table Apr 28, 2025
@svlandeg svlandeg added the feature New feature or request label Apr 28, 2025
@svlandeg svlandeg marked this pull request as draft April 28, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants