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.



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

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 could not analyze this Active Record relation: #{error.message}")
end

Instance Attribute Details

#model_nameObject (readonly)

Returns the value of attribute model_name.



10
11
12
# File 'lib/upkeep/active_record_query.rb', line 10

def model_name
  @model_name
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



10
11
12
# File 'lib/upkeep/active_record_query.rb', line 10

def reasons
  @reasons
end

#sqlObject (readonly)

Returns the value of attribute sql.



10
11
12
# File 'lib/upkeep/active_record_query.rb', line 10

def sql
  @sql
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



10
11
12
# File 'lib/upkeep/active_record_query.rb', line 10

def table_name
  @table_name
end

Instance Method Details

#suggestionsObject



23
24
25
26
27
28
29
# File 'lib/upkeep/active_record_query.rb', line 23

def suggestions
  [
    "Check that the relation emits valid SQL for the configured database adapter.",
    "Report unsupported SQL with the query, adapter, and SQLGlot version.",
    "Render this boundary outside Upkeep reactivity until the SQL is supported."
  ]
end