acts_as_tenant
acts_as_tenant copied to clipboard
Fix global record validations with existing scope
Due to how the args
object was being (man)handled, we were leaking
the tenant scope into the global scope validation where it shouldn't
have been. This only happened when there was a scope argument supplied
to validates_uniquness_to_tenant.
to expand on this a little; the # if tenant is set (instance is not global) and records can be global - validating within records with blank tenant
validation query was:
SELECT 1 AS one
FROM "projects"
WHERE "projects"."name" = ?
AND "projects"."user_defined_scope" = ?
AND "projects"."account_id" = ?
AND "projects"."account_id" IS NULL
LIMIT ?
the account_id = <tenant_id>
portion of the query doesn't belong there, and was leaking into args[:scope]
from how validation_args
was being built for the main validation.