Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: softdelete rule model #72

Merged
merged 19 commits into from
Jul 8, 2024
Merged

feat: softdelete rule model #72

merged 19 commits into from
Jul 8, 2024

Conversation

trbtm
Copy link
Contributor

@trbtm trbtm commented Jul 6, 2024

I would like to have the option for having soft delete rules in the database to be able to possibly track fields like

  • deleted_by, deleted_at
  • updated_by, updated_at

etc.

@trbtm trbtm changed the title feat: Add the option for softdelete feat: softdelete rule model Jul 6, 2024
@leeqvip
Copy link
Contributor

leeqvip commented Jul 7, 2024

@trbtm Hi,

  1. Can the database operations be separated? The Adapter only needs to call the corresponding query or modification method.
  2. Regarding soft deletion, some fields are marked as true or false, while others set the deleted_at time.
  3. The updated_at you mentioned is not shown here.

@trbtm
Copy link
Contributor Author

trbtm commented Jul 7, 2024

@leeqvip Hi,

I added an example demonstrating my approach. To your points:

  1. I think that would be difficult since deleted rules need to be filtered when the adapter is querying the database e.g. in Adapter.remove_policies you want to make sure that only non deleted rules get affected
  2. I think this gets clear when you look the the example I provided
  3. Same as above.

Best
Thore

self,
engine,
db_class=None,
db_class_softdelete_attribute=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can judge according to the is_deleted attribute of db_class, the default value is None

CasbinSoftDeleteRule.is_deleted,
)
# Create the Enforcer, etc.
e = casbin.Enforcer("path/to/model.conf", adapter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write it directly in the readme, in a separate section

@leeqvip leeqvip merged commit 8911c16 into pycasbin:master Jul 8, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 8, 2024
# [1.4.0](v1.3.0...v1.4.0) (2024-07-08)

### Features

* support for soft deletion of casbin rules ([#72](#72)) ([8911c16](8911c16))
Copy link

github-actions bot commented Jul 8, 2024

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants