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

Scoping fails on new objects #227

Closed
borisd opened this issue Feb 17, 2020 · 1 comment
Closed

Scoping fails on new objects #227

borisd opened this issue Feb 17, 2020 · 1 comment
Assignees
Labels

Comments

@borisd
Copy link

borisd commented Feb 17, 2020

If accidently scoping is done on an object with invalid id (null or non numeric) - scoping is ignored

ActsAsTenant.current_tenant = Account.new / OpenStruct.new(id: nil)

Project.all =>  # all projects instead of empty result
@excid3
Copy link
Collaborator

excid3 commented Nov 17, 2020

Definitely think this is a bug. I want to make sure I'm thinking through all the cases here.

has_global_records uses nil to find all the tenant's records and records unassociated with a tenant. That's effectively what is going on here.

I'm thinking we want:

If Account.id is nil and has_global_records: false we should return Project.where(account_id: [])
If Account.id is 1 and has_global_records: false we should return Project.where(account_id: [1])
If Account.id is nil and has_global_records: true we should return Project.where(account_id: [nil])
If Account.id is 1 and has_global_records: true we should return Project.where(account_id: [1, nil])

@excid3 excid3 self-assigned this Nov 17, 2020
@excid3 excid3 added the bug label Nov 17, 2020
@excid3 excid3 closed this as completed in 716e99a Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants