Module: Sequel::Plugins::PgRow::DatabaseMethods

Defined in:
lib/sequel/plugins/pg_row.rb

Constant Summary collapse

ESCAPE_RE =
/("|\\)/.freeze
ESCAPE_REPLACEMENT =
'\\\\\1'.freeze
COMMA =
','

Instance Method Summary collapse

Instance Method Details

#bound_variable_arg(arg, conn) ⇒ Object

Handle Sequel::Model instances in bound variables.



70
71
72
73
74
75
76
77
# File 'lib/sequel/plugins/pg_row.rb', line 70

def bound_variable_arg(arg, conn)
  case arg
  when Sequel::Model
    "(#{arg.values.values_at(*arg.columns).map{|v| bound_variable_array(v)}.join(COMMA)})"
  else
    super
  end
end

#row_type(db_type, v) ⇒ Object

If a Sequel::Model instance is given, return it as-is instead of attempting to convert it.



81
82
83
84
85
86
87
# File 'lib/sequel/plugins/pg_row.rb', line 81

def row_type(db_type, v)
  if v.is_a?(Sequel::Model)
    v
  else
    super
  end
end