| Class | Sequel::Postgres::PGRow::HashRow |
| In: |
lib/sequel/extensions/pg_row.rb
|
| Parent: | DelegateClass(Hash) |
Class for row-valued/composite types that are treated as hashes. Types registered via Database#register_row_type will use this class by default.
| new | -> | call |
| Alias new to call, so that the class itself can be used directly as a converter. | ||
| __getobj__ | -> | to_hash |
| Return the underlying hash for this delegate object. | ||
| columns | [RW] | The columns associated with this class. |
| columns | [W] | Sets the columns associated with this instance. This is used to override the class‘s default columns. |
| db_type | [RW] | The database type for this class. May be nil if this class done not have a specific database type. |
| db_type | [W] | Sets the database type associated with this instance. This is used to override the class‘s default database type. |
Check that the HashRow has valid columns. This should be used before all attempts to literalize the object, since literalization depends on the columns to get the column order.
# File lib/sequel/extensions/pg_row.rb, line 193
193: def check_columns!
194: if columns.nil? || columns.empty?
195: raise Error, 'cannot literalize HashRow without columns'
196: end
197: end
Append SQL fragment related to this object to the sql.
# File lib/sequel/extensions/pg_row.rb, line 200
200: def sql_literal_append(ds, sql)
201: check_columns!
202: sql << ROW
203: ds.literal_append(sql, values_at(*columns))
204: if db_type
205: sql << CAST
206: ds.quote_schema_table_append(sql, db_type)
207: end
208: end