Exception: ActiveRecord::StatementInvalid
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::StatementInvalid
- Defined in:
- activerecord/lib/active_record/errors.rb
Overview
Superclass for all database execution errors.
Wraps the underlying database error as cause
.
Direct Known Subclasses
DatabaseAlreadyExists, LockWaitTimeout, MismatchedForeignKey, NoDatabaseError, NotNullViolation, PreparedStatementCacheExpired, QueryAborted, RangeError, TransactionRollbackError, ValueTooLong, WrappedDatabaseException
Instance Attribute Summary collapse
-
#binds ⇒ Object
readonly
Returns the value of attribute binds.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
Instance Method Summary collapse
-
#initialize(message = nil, sql: nil, binds: nil) ⇒ StatementInvalid
constructor
A new instance of StatementInvalid.
- #set_query(sql, binds) ⇒ Object
Constructor Details
#initialize(message = nil, sql: nil, binds: nil) ⇒ StatementInvalid
Returns a new instance of StatementInvalid.
163 164 165 166 167 |
# File 'activerecord/lib/active_record/errors.rb', line 163 def initialize( = nil, sql: nil, binds: nil) super( || $!&.) @sql = sql @binds = binds end |
Instance Attribute Details
#binds ⇒ Object (readonly)
Returns the value of attribute binds
169 170 171 |
# File 'activerecord/lib/active_record/errors.rb', line 169 def binds @binds end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql
169 170 171 |
# File 'activerecord/lib/active_record/errors.rb', line 169 def sql @sql end |
Instance Method Details
#set_query(sql, binds) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'activerecord/lib/active_record/errors.rb', line 171 def set_query(sql, binds) unless @sql @sql = sql @binds = binds end self end |