Class: Relationize::PgRelationizer
- Inherits:
-
Relationizer
- Object
- Relationizer
- Relationize::PgRelationizer
- Defined in:
- lib/relationize/pg_relationizer.rb
Constant Summary collapse
- DEFAULT_TYPES =
{ Integer => :int8, Fixnum => :int8, Bignum => :decimal, BigDecimal => :decimal, Float => :float8, String => :text, TrueClass => :boolean, FalseClass => :boolean, Date => :date, Time => :timestamptz }
Instance Method Summary collapse
Methods inherited from Relationizer
Constructor Details
This class inherits a constructor from Relationize::Relationizer
Instance Method Details
#to_s ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/relationize/pg_relationizer.rb', line 20 def to_s types = oriented_types columns = @columns.map(&method(:identifer_quote)) tuples = @tuples.map { |tuple| "(#{tuple.map { |v| to_text_literal(v) }.join(', ')})"}.join(", ") expressions = columns.zip(types).map { |(col, type)| "#{col}::#{type}" }.join(', ') "SELECT #{expressions} FROM (VALUES#{tuples}) AS #{identifer_quote(@name)}(#{columns.join(', ')})" end |