Exception: ActiveRecord::StatementInvalid

Inherits:
AdapterError show all
Defined in:
lib/active_record/errors.rb

Overview

Superclass for all database execution errors.

Wraps the underlying database error as cause.

Instance Attribute Summary collapse

Attributes inherited from AdapterError

#connection_pool

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, sql: nil, binds: nil, connection_pool: nil) ⇒ StatementInvalid

Returns a new instance of StatementInvalid.



192
193
194
195
196
# File 'lib/active_record/errors.rb', line 192

def initialize(message = nil, sql: nil, binds: nil, connection_pool: nil)
  super(message || $!&.message, connection_pool: connection_pool)
  @sql = sql
  @binds = binds
end

Instance Attribute Details

#bindsObject (readonly)

Returns the value of attribute binds.



198
199
200
# File 'lib/active_record/errors.rb', line 198

def binds
  @binds
end

#sqlObject (readonly)

Returns the value of attribute sql.



198
199
200
# File 'lib/active_record/errors.rb', line 198

def sql
  @sql
end

Instance Method Details

#set_query(sql, binds) ⇒ Object



200
201
202
203
204
205
206
207
# File 'lib/active_record/errors.rb', line 200

def set_query(sql, binds)
  unless @sql
    @sql = sql
    @binds = binds
  end

  self
end