Class: Sequel::Postgres::PGRow::HashRow
- Includes:
- SQL::AliasMethods
- Defined in:
- lib/sequel/extensions/pg_row.rb,
lib/sequel/extensions/pg_row_ops.rb more...
Overview
:nocov:
Class Attribute Summary collapse
-
.columns ⇒ Object
The columns associated with this class.
-
.db_type ⇒ Object
The database type for this class.
Instance Attribute Summary collapse
-
#columns ⇒ Object
Return the instance’s columns, or the class’s columns if the instance has not overridden it.
-
#db_type ⇒ Object
Return the instance’s database type, or the class’s columns if the instance has not overridden it.
Class Method Summary collapse
-
.subclass(db_type, columns) ⇒ Object
Create a new subclass of this class with the given database type and columns.
Instance Method Summary collapse
-
#check_columns! ⇒ Object
Check that the HashRow has valid columns.
-
#op ⇒ Object
Wrap the PGRow::ArrayRow instance in an PGRowOp, allowing you to easily use the PostgreSQL row functions and operators with literal rows.
-
#sequel_auto_param_type(ds) ⇒ Object
Allow automatic parameterization if all values support it.
-
#sql_literal_append(ds, sql) ⇒ Object
Append SQL fragment related to this object to the sql.
Methods included from SQL::AliasMethods
Methods inherited from Hash
#&, #case, #hstore, #pg_json, #pg_jsonb, #sql_expr, #sql_negate, #sql_or, #|, #~
Class Attribute Details
Instance Attribute Details
Class Method Details
permalink .subclass(db_type, columns) ⇒ Object
Create a new subclass of this class with the given database type and columns.
172 173 174 175 176 177 178 |
# File 'lib/sequel/extensions/pg_row.rb', line 172 def self.subclass(db_type, columns) Class.new(self) do Sequel.set_temp_name(self){"Sequel::Postgres::PGRow::HashRow::_Subclass(#{db_type})"} @db_type = db_type @columns = columns end end |
Instance Method Details
permalink #check_columns! ⇒ Object
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.
206 207 208 209 210 |
# File 'lib/sequel/extensions/pg_row.rb', line 206 def check_columns! if columns.nil? || columns.empty? raise Error, 'cannot literalize HashRow without columns' end end |
permalink #op ⇒ Object
Wrap the PGRow::ArrayRow instance in an PGRowOp, allowing you to easily use the PostgreSQL row functions and operators with literal rows.
180 181 182 |
# File 'lib/sequel/extensions/pg_row_ops.rb', line 180 def op Sequel.pg_row_op(self) end |
permalink #sequel_auto_param_type(ds) ⇒ Object
Allow automatic parameterization if all values support it.
224 225 226 227 228 229 230 |
# File 'lib/sequel/extensions/pg_row.rb', line 224 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 |
permalink #sql_literal_append(ds, sql) ⇒ Object
Append SQL fragment related to this object to the sql.
213 214 215 216 217 218 219 220 221 |
# File 'lib/sequel/extensions/pg_row.rb', line 213 def sql_literal_append(ds, sql) check_columns! sql << 'ROW' ds.literal_append(sql, values_at(*columns)) if db_type sql << '::' ds.quote_schema_table_append(sql, db_type) end end |