Class: PgCanary::Rules::OrAcrossColumns
- Defined in:
- lib/pg_canary/rules/definitions/or_across_columns.rb
Overview
OR conditions spanning different columns. PostgreSQL can sometimes combine per-column indexes with a BitmapOr, so this is a warning-level hint rather than a certainty.
Instance Method Summary collapse
Methods inherited from Base
all, check, default_enabled, enabled?, #initialize, option, options, rule_name
Constructor Details
This class inherits a constructor from PgCanary::Rules::Base
Instance Method Details
#check ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pg_canary/rules/definitions/or_across_columns.rb', line 13 def check detections = [] each_scope do |scope| next unless scope.where_clause seen = [] scope.where_clause.walk_scope do |node| next unless node.is_a?(PgQuery::BoolExpr) && node.boolop == :OR_EXPR columns = predicate_columns(scope, node) next if columns.length < 2 next if seen.include?(columns) seen << columns detections << build(columns) end end detections end |