Skip to content

grails/gorm-mongodb#77 Updated MultiTenantEventListener #1245

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

Closed
wants to merge 2 commits into from

Conversation

puneetbehl
Copy link
Contributor

Updated MultiTenantEventListener to not add the multi-tenant filter to the query in case of shared database and when tenantId is DEFAULT

puneetbehl added 2 commits May 6, 2019 15:40
…ntId filter

Updated MultiTenantEventListener to not add multi-tenant filter to the query in case of shared database and when `tenantId` is DEFAULT
@puneetbehl puneetbehl requested a review from graemerocher May 6, 2019 11:59
@@ -55,12 +55,13 @@ class MultiTenantEventListener implements PersistenceEventListener {
TenantId tenantId = entity.getTenantId();
if(tenantId != null) {
Serializable currentId = Tenants.currentId(datastoreClient.getClass());
query.eq(tenantId.getName(), currentId );
if (currentId != ConnectionSource.DEFAULT) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graemerocher The reason I decided to add this check here is that in case of non shared multi-tenant database (e.g. multi-tenancy across databases) we might be using that default data source in case tenantId is not specified and we do not know in Tenants.groovy that if it's a shared or nonshared multi-tenancy. However, I am not sure about the above logic so please suggest if we need to fix this some other way.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

2 participants