Exception: Upkeep::ActiveRecordQuery::OpaqueRelationError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/upkeep/active_record_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation, reasons:) ⇒ OpaqueRelationError

Returns a new instance of OpaqueRelationError.



10
11
12
13
14
15
16
17
18
19
# File 'lib/upkeep/active_record_query.rb', line 10

def initialize(relation, reasons:)
  @model_name = relation.klass.name
  @table_name = relation.klass.table_name
  @sql = relation.to_sql
  @reasons = reasons

  super(build_message)
rescue StandardError => error
  super("Upkeep cannot prove this Active Record relation's structural dependencies: #{error.message}")
end

Instance Attribute Details

#model_nameObject (readonly)

Returns the value of attribute model_name.



8
9
10
# File 'lib/upkeep/active_record_query.rb', line 8

def model_name
  @model_name
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



8
9
10
# File 'lib/upkeep/active_record_query.rb', line 8

def reasons
  @reasons
end

#sqlObject (readonly)

Returns the value of attribute sql.



8
9
10
# File 'lib/upkeep/active_record_query.rb', line 8

def sql
  @sql
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



8
9
10
# File 'lib/upkeep/active_record_query.rb', line 8

def table_name
  @table_name
end

Instance Method Details

#suggestionsObject



45
46
47
48
49
50
51
# File 'lib/upkeep/active_record_query.rb', line 45

def suggestions
  [
    "Rewrite raw SQL predicates with structural Active Record hash or Arel predicates.",
    "Rewrite raw SQL joins or FROM sources with structural Active Record/Arel joins.",
    "Render this boundary outside Upkeep reactivity when the query cannot expose its sources."
  ]
end