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.

### Methods

check_columns! columns db_type sql_literal_append subclass

### External Aliases

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.

### Attributes

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.

### Public Class methods

subclass(db_type, columns)

Create a new subclass of this class with the given database type and columns.

[Source]

         # File lib/sequel/extensions/pg_row.rb, line 143
    143:         def self.subclass(db_type, columns)
    144:           sc = Class.new(self) do
    145:             @db_type = db_type
    146:             @columns = columns
    147:           end
    148:         end

### Public Instance methods

check_columns!()

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.

[Source]

         # File lib/sequel/extensions/pg_row.rb, line 176
    176:         def check_columns!
    177:           if columns.nil? || columns.empty?
    178:             raise Error, 'cannot literalize HashRow without columns'
    179:           end
    180:         end

columns()

Return the instance‘s columns, or the class‘s columns if the instance has not overridden it.

[Source]

         # File lib/sequel/extensions/pg_row.rb, line 163
    163:         def columns
    164:           @columns || self.class.columns
    165:         end

db_type()

Return the instance‘s database type, or the class‘s columns if the instance has not overridden it.

[Source]

         # File lib/sequel/extensions/pg_row.rb, line 169
    169:         def db_type
    170:           @db_type || self.class.db_type
    171:         end

sql_literal_append(ds, sql)

Append SQL fragment related to this object to the sql.

[Source]

         # File lib/sequel/extensions/pg_row.rb, line 183
    183:         def sql_literal_append(ds, sql)
    184:           check_columns!
    185:           sql << ROW
    186:           ds.literal_append(sql, values_at(*columns))
    187:           if db_type
    188:             sql << CAST
    189:             ds.quote_schema_table_append(sql, db_type)
    190:           end
    191:         end

[Validate]