node-casbin / sequelize-adapter

Sequelize adapter for Casbin
https://github.com/casbin/node-casbin
Apache License 2.0
64 stars 34 forks source link

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

Closed tsoultanopoulos closed 1 year ago

tsoultanopoulos commented 1 year ago

Fix: https://github.com/node-casbin/sequelize-adapter/issues/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 commented 1 year ago

@nodece @Zxilly @Shivansh-yadav13 please review

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

hsluoyz commented 1 year ago

@nodece plz review

hsluoyz commented 1 year ago

@tsoultanopoulos fix:

image

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 5358173782


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

💛 - Coveralls
github-actions[bot] commented 1 year ago

:tada: This PR is included in version 2.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: