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

feat: create new CasbinRule instance every time sequelize Adapter opens connection #80

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

tsoultanopoulos
Copy link

@tsoultanopoulos tsoultanopoulos commented Jun 23, 2023

Fix: #78

Why?
Previously, the system utilized multiple adapters to establish connections with different databases based on their respective schemas. However, there was an unintended behavior where the last adapter defined in the configuration would override the previous ones, resulting in only a single database connection being used, regardless of the schema.it supposed that was solved with this PR but the issue still persists.
What was changed?
In the updated code, a new CasbinRule model is dynamically created for each Sequelize adapter instance with the createCasbinRule function. This function generates a custom CasbinRule model class with its own tableName and schema options. This ensures that different Sequelize adapters have isolated configurations, avoiding potential clashes when multiple adapters are opened with different table names or schemas.

@casbin-bot
Copy link

@nodece @Zxilly @Shivansh-yadav13 please review

@CLAassistant
Copy link

CLAassistant commented Jun 23, 2023

CLA assistant check
All committers have signed the CLA.

@hsluoyz
Copy link
Member

hsluoyz commented Jun 23, 2023

@nodece plz review

@hsluoyz
Copy link
Member

hsluoyz commented Jun 23, 2023

@tsoultanopoulos fix:

image

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5358173782

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 86.061%

Totals Coverage Status
Change from base Build 4439363605: 0.09%
Covered Lines: 117
Relevant Lines: 126

💛 - Coveralls

@hsluoyz hsluoyz changed the title fix: create new CasbinRule instance every time sequelize Adapter opens connection feat: create new CasbinRule instance every time sequelize Adapter opens connection Jun 23, 2023
@hsluoyz hsluoyz merged commit 4dccf8d into node-casbin:master Jun 23, 2023
@github-actions
Copy link

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Multiple adapter instance based on postgres schema(already opened before)
5 participants