-
Notifications
You must be signed in to change notification settings - Fork 13
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
Models that don't inherit from the mixin class also have results filtered #22
Comments
That is actually a pretty cool find, thank you for uncovering this! We'll need to think about a way to flag this inheritance somehow as metadata that is contained/passed to the Table object, because the internal "query rewriter" only sees Tables, and not the Declarative Classes themselves. Honestly I don't even know if it is possible, but I'll do some research. |
@spr Thanks for reporting this! I've created a new argument for the Mixin creator that will allow you to ignore certain tables by table name! Example: If you're using a schema-less database (e.g.: SQLite), # Create a Class that inherits from our class builder
class SoftDeleteMixin(generate_soft_delete_mixin_class(
# This table will be ignored by the hook
# even if the table has the soft-delete column
ignored_tables=[
IgnoredTable(table_schema="public", name="cars"),
IgnoredTable(table_schema="public", name="stores"),
IgnoredTable(table_schema="public", name="employees"),
])):
# type hint for autocomplete IDE support
deleted_at: datetime |
That's great, thank you for the quick response! |
@spr if possible, I'm interested in following up with you if it suits your use case/works well. Please lmk what you find! |
Yep, it works for our project just fine, replaces the old hand-rolled mixin we had with sqlalchemy 1.3. |
That's great to hear. Thank you @spr! |
Description
On models that don't inherit from the generated
SoftDeleteMixin
class, but also have a field of the same name (so adeleted_at
field in this case), select results are still filtered without providing the execution option.I can work around this, but it'd be nice if the filtering only applied to models inheriting from the mixin.
What I Did
The text was updated successfully, but these errors were encountered: