Skip to content

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

Merged
hsluoyz merged 2 commits intoapache:masterfrom
tsoultanopoulos:master
Jun 23, 2023
Merged

feat: create new CasbinRule instance every time sequelize Adapter opens connection#80
hsluoyz merged 2 commits intoapache:masterfrom
tsoultanopoulos:master

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 apache: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