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

NewAdapterWithClient won't work with local ent client #20

Closed
Jubilee101 opened this issue Feb 28, 2024 · 2 comments
Closed

NewAdapterWithClient won't work with local ent client #20

Jubilee101 opened this issue Feb 28, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@Jubilee101
Copy link

Hi,

I'm trying to use NewAdapterWithClient so that I can use the same client for the enforcer (i.e. for casbin_rules table) and for other tables of my project, it would be nice because I can then perhaps wrap the modification to casbin_rules and other tables in the same transaction. For example, when deleting a role, not only do I want to delete policies related to this role stored in casbin_rules, I want to delete info about this role stored in other tables. It's better if they can be done in a single transaction.

But, it's not letting me use my own ent client because it comes from my own ent package, instead of ent package from your repo.

I'm not exactly sure how to fix this, maybe instead of using the ent.client struct as the parameter of NewAdapterWithClient, we could use an interface instead?

I'm not sure wether this repo is still under maintenance or not. Though thank you for this anyway.

@casbin-bot casbin-bot added the question Further information is requested label Feb 28, 2024
@MuZhou233
Copy link
Contributor

Hi @Jubilee101 and any others looking for a solution on this issue. There is an idea showing in #25. It is generally working but may not be merged. You can customize your own adapter based on it and I will keep the fork available.

To test my fork, add this to your go.mod

replace github.com/casbin/ent-adapter latest => github.com/muzhou233/casbin-ent-adapter embed

@Jubilee101
Copy link
Author

Hey @MuZhou233 Thank you so much for this. I'm not doing a personal project so I'm not quite sure if the license allows me to use a fork this way. But this is great idea and really nice work. I do hope it gets merged in the next release... if there is one.

@hsluoyz hsluoyz closed this as completed Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants