Class: Dumbo::RangeType
Instance Attribute Summary collapse
-
#canonical ⇒ Object
Returns the value of attribute canonical.
-
#collation ⇒ Object
Returns the value of attribute collation.
-
#subtype ⇒ Object
Returns the value of attribute subtype.
-
#subtype_diff ⇒ Object
Returns the value of attribute subtype_diff.
-
#subtype_opclass ⇒ Object
Returns the value of attribute subtype_opclass.
Attributes inherited from Type
Attributes inherited from PgObject
Instance Method Summary collapse
Methods inherited from Type
Methods inherited from PgObject
#downgrade, #execute, #get, identfied_by, #identify, #initialize, #upgrade
Constructor Details
This class inherits a constructor from Dumbo::PgObject
Instance Attribute Details
#canonical ⇒ Object
Returns the value of attribute canonical.
3 4 5 |
# File 'lib/dumbo/range_type.rb', line 3 def canonical @canonical end |
#collation ⇒ Object
Returns the value of attribute collation.
3 4 5 |
# File 'lib/dumbo/range_type.rb', line 3 def collation @collation end |
#subtype ⇒ Object
Returns the value of attribute subtype.
3 4 5 |
# File 'lib/dumbo/range_type.rb', line 3 def subtype @subtype end |
#subtype_diff ⇒ Object
Returns the value of attribute subtype_diff.
3 4 5 |
# File 'lib/dumbo/range_type.rb', line 3 def subtype_diff @subtype_diff end |
#subtype_opclass ⇒ Object
Returns the value of attribute subtype_opclass.
3 4 5 |
# File 'lib/dumbo/range_type.rb', line 3 def subtype_opclass @subtype_opclass end |
Instance Method Details
#load_attributes ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dumbo/range_type.rb', line 6 def load_attributes super result = execute <<-SQL SELECT st.typname AS subtype, opc.opcname AS subtype_opclass, col.collname AS collation, rngcanonical AS canonical, rngsubdiff AS subtype_diff FROM pg_range LEFT JOIN pg_type st ON st.oid=rngsubtype LEFT JOIN pg_collation col ON col.oid=rngcollation LEFT JOIN pg_opclass opc ON opc.oid=rngsubopc WHERE rngtypid=#{oid} SQL result.first.each do |k, v| send("#{k}=", v) rescue nil end result.first end |
#to_sql ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dumbo/range_type.rb', line 28 def to_sql attr_str = [:subtype, :subtype_opclass, :collation, :canonical, :subtype_diff].map do |a| [a, public_send(a)] end.select { |k, v| v && v != '-' }.map { |k, v| "#{k.upcase}=#{v}" }.join(",\n ") <<-SQL.gsub(/^ {6}/, '') CREATE TYPE #{name} AS RANGE ( #{attr_str} ); SQL end |