-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add support for AddPoliciesEx #10
Comments
This package is to implement the interfaces for Casbin adapter like
From your description, have you check the test cases like https://github.com/Blank-Xu/sql-adapter/blob/master/test/e2e/adapter_test.go#L118 and https://github.com/Blank-Xu/sql-adapter/blob/master/test/e2e/adapter_test.go#L152 ? |
I did take a look at this. They don't seem to convey the use of the However, I ended up here after finding this issue in casbin main: casbin/casbin#1423 - they seem to think it's up to the adapter layer to handle this. |
I got all your points now. Actually I had thought to add But I thought it may have issues like if For this simple solution maybe you could execute the SQL like We need consider more about this and maybe Casbin could fix this. @hsluoyz |
Good callouts. Adding the unique key and handling the duplicate check in the adapter would go a long way towards being safe as well as handling races. I have added the unique index to my casbin_rule table for my use cases. However, I can't use the But it definitely does seem like this is a bug in casbin and shouldn't really be cause for concern at the adapter layer. I took a cursory look at the Of course, having a unique index on the table seems like a sure-fire way to handle the duplicates regardless (to better handle races too). So I'm thinking there might be multiple improvements that could be made. |
Not sure if it is a good to add |
I've seen the mention of adding that index in various places, don't have immediate refs on hand though. |
https://casbin.org/docs/management-api#addpoliciesex
I tried using this method with this adapter and it results in duplicate rows being inserted.
My model file:
Policies:
When calling this function it always seems to insert duplicates.
This method does fail if I add a unique constraint to my table.
Postgres v15
The text was updated successfully, but these errors were encountered: