Class: PgCanary::Rules::OrAcrossColumns
- Defined in:
- lib/pg_canary/rules/definitions/or_across_columns.rb
Overview
Tier 2 (opt-in): 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.
Constant Summary
Constants included from PgQuerySupport
PgQuerySupport::COMPARISON_OPS
Instance Method Summary collapse
Methods inherited from Base
all, #enabled?, options, rule_name
Instance Method Details
#check(query) ⇒ 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(query) detections = [] query.each_scope do |scope| next unless scope.where_clause seen = [] walk_within_scope(scope.where_clause) do |node| next unless node.is_a?(PgQuery::BoolExpr) && node.boolop == :OR_EXPR columns = predicate_columns(query, scope, node) next if columns.length < 2 next if seen.include?(columns) seen << columns detections << build(query, columns) end end detections end |
#default_enabled ⇒ Object
9 10 11 |
# File 'lib/pg_canary/rules/definitions/or_across_columns.rb', line 9 def default_enabled false end |