Class for row-valued/composite types that are treated as hashes. Types registered via Database#register_row_type will use this class by default.
:nocov:
Methods
Public Class
Public Instance
Included modules
- Sequel::SQL::AliasMethods
Attributes
columns | [RW] |
The columns associated with this class. |
db_type | [RW] |
The database type for this class. May be nil if this class done not have a specific database type. |
columns | [W] |
Sets the columns associated with this instance. This is used to override the class’s default columns. |
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
Create a new subclass of this class with the given database type and columns.
# File lib/sequel/extensions/pg_row.rb 162 def self.subclass(db_type, columns) 163 Class.new(self) do 164 @db_type = db_type 165 @columns = columns 166 end 167 end
Public Instance methods
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 195 def check_columns! 196 if columns.nil? || columns.empty? 197 raise Error, 'cannot literalize HashRow without columns' 198 end 199 end
Return the instance’s columns, or the class’s columns if the instance has not overridden it.
# File lib/sequel/extensions/pg_row.rb 182 def columns 183 @columns || self.class.columns 184 end
Return the instance’s database type, or the class’s columns if the instance has not overridden it.
# File lib/sequel/extensions/pg_row.rb 188 def db_type 189 @db_type || self.class.db_type 190 end
Wrap the PGRow::ArrayRow
instance in an PGRowOp
, allowing you to easily use the PostgreSQL row functions and operators with literal rows.
# File lib/sequel/extensions/pg_row_ops.rb 180 def op 181 Sequel.pg_row_op(self) 182 end
Append SQL
fragment related to this object to the sql.
# File lib/sequel/extensions/pg_row.rb 202 def sql_literal_append(ds, sql) 203 check_columns! 204 sql << 'ROW' 205 ds.literal_append(sql, values_at(*columns)) 206 if db_type 207 sql << '::' 208 ds.quote_schema_table_append(sql, db_type) 209 end 210 end