Skip to content

Commit

Permalink
dont attempt to optimise joins
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Nov 14, 2024
1 parent 3595256 commit 7f31dda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/cancan/rules_compressor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def simplify(rules)
# e.g contact_id = 1, contact_id = [2, 3] => contact_id = [1, 2, 3]
potentially_simplify_singular = rules.size > 1 && rules.all? do |rule|
if rule.conditions.is_a?(Hash)
rule.conditions.size == 1
# If there is only one column in the expressions, we can simplify it
# A hash of size one e.g { contact_id: [1,2] } or { contact_id: 1 } but not { contact: {id: 1}}
if rule.conditions.size == 1
!rule.conditions.values.first.is_a?(Hash)
end
else
false
end
Expand All @@ -39,6 +43,7 @@ def simplify(rules)
potentially_simplify_singular = rules.map do |rule|
rule.conditions.keys.first
end.uniq

if potentially_simplify_singular.size == 1
new_valid_values = rules.map do |rule|
r = rule.conditions.values
Expand Down

0 comments on commit 7f31dda

Please sign in to comment.