class Sequel::Postgres::PGRow::ArrayRow

Class for row-valued/composite types that are treated as arrays. By default, this is only used for generic PostgreSQL record types, as registered types use HashRow by default.

:nocov:

Attributes

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) click to toggle source

Create a subclass associated with a specific database type. This is done so that instances of this subclass are automatically casted to the database type when literalizing.

# File lib/sequel/extensions/pg_row.rb, line 113
def self.subclass(db_type)
  Class.new(self) do
    @db_type = db_type
  end
end

Public Instance Methods

db_type() click to toggle source

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

# File lib/sequel/extensions/pg_row.rb, line 125
def db_type
  @db_type || self.class.db_type
end
op() click to toggle source

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, line 167
def op
  Sequel.pg_row_op(self)
end
sequel_auto_param_type(ds) click to toggle source

Allow automatic parameterization if all values support it.

# File lib/sequel/extensions/pg_row.rb, line 140
def sequel_auto_param_type(ds)
  if db_type && all?{|v| nil == v || ds.send(:auto_param_type, v)}
    s = String.new << "::"
    ds.quote_schema_table_append(s, db_type)
    s
  end
end
sql_literal_append(ds, sql) click to toggle source

Append SQL fragment related to this object to the sql.

# File lib/sequel/extensions/pg_row.rb, line 130
def sql_literal_append(ds, sql)
  sql << 'ROW'
  ds.literal_append(sql, to_a)
  if db_type
    sql << '::'
    ds.quote_schema_table_append(sql, db_type)
  end
end