Class: Dumbo::BaseType
Instance Attribute Summary collapse
-
#alignment ⇒ Object
Returns the value of attribute alignment.
-
#analyze_function ⇒ Object
Returns the value of attribute analyze_function.
-
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
-
#category ⇒ Object
Returns the value of attribute category.
-
#default ⇒ Object
Returns the value of attribute default.
-
#input_function ⇒ Object
Returns the value of attribute input_function.
-
#internallength ⇒ Object
Returns the value of attribute internallength.
-
#output_function ⇒ Object
Returns the value of attribute output_function.
-
#receive_function ⇒ Object
Returns the value of attribute receive_function.
-
#send_function ⇒ Object
Returns the value of attribute send_function.
-
#storage ⇒ Object
Returns the value of attribute storage.
-
#type ⇒ Object
Returns the value of attribute type.
-
#typrelid ⇒ Object
Returns the value of attribute typrelid.
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
#alignment ⇒ Object
Returns the value of attribute alignment.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def alignment @alignment end |
#analyze_function ⇒ Object
Returns the value of attribute analyze_function.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def analyze_function @analyze_function end |
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def attribute_name @attribute_name end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def category @category end |
#default ⇒ Object
Returns the value of attribute default.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def default @default end |
#input_function ⇒ Object
Returns the value of attribute input_function.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def input_function @input_function end |
#internallength ⇒ Object
Returns the value of attribute internallength.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def internallength @internallength end |
#output_function ⇒ Object
Returns the value of attribute output_function.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def output_function @output_function end |
#receive_function ⇒ Object
Returns the value of attribute receive_function.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def receive_function @receive_function end |
#send_function ⇒ Object
Returns the value of attribute send_function.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def send_function @send_function end |
#storage ⇒ Object
Returns the value of attribute storage.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def storage @storage end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def type @type end |
#typrelid ⇒ Object
Returns the value of attribute typrelid.
3 4 5 |
# File 'lib/dumbo/base_type.rb', line 3 def typrelid @typrelid end |
Instance Method Details
#load_attributes ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dumbo/base_type.rb', line 17 def load_attributes sql = <<-SQL SELECT t.typname AS name, t.typinput AS input_function, t.typoutput AS output_function, t.typreceive AS receive_function, t.typsend AS send_function, t.typanalyze AS analyze_function, t.typcategory AS category, t.typdefault AS default, t.typrelid, CASE WHEN t.typalign = 'i' THEN 'int' WHEN t.typalign = 'c' THEN 'char' WHEN t.typalign = 's' THEN 'short' WHEN t.typalign = 'd' THEN 'double' ELSE NULL END AS alignment, CASE WHEN t.typstorage = 'p' THEN 'PLAIN' WHEN t.typstorage = 'e' THEN 'EXTENDED' WHEN t.typstorage = 'm' THEN 'MAIN' WHEN t.typstorage = 'x' THEN 'EXTENDED' ELSE NULL END AS storage, t.typtype AS type, t.typlen AS internallength, format_type(t.oid, null) AS alias, e.typname as element, description, ct.oid AS taboid, (SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=t.oid) AS labels, (SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=t.oid) AS providers FROM pg_type t LEFT OUTER JOIN pg_type e ON e.oid=t.typelem LEFT OUTER JOIN pg_class ct ON ct.oid = t.typrelid AND ct.relkind <> 'c' LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_type'::regclass) WHERE t.typtype != 'd' AND t.typnamespace = 2200::oid AND ct.oid IS NULL AND t.oid = #{oid} SQL result = execute sql result.first.each do |k, v| send("#{k}=", v) rescue nil end result.first end |
#to_sql ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dumbo/base_type.rb', line 54 def to_sql <<-SQL.gsub(/^ {8}/, '') CREATE TYPE #{name}( INPUT=#{input_function}, OUTPUT=#{output_function}, RECEIVE=#{receive_function}, SEND=#{send_function}, ANALYZE=#{analyze_function}, CATEGORY='#{category}', DEFAULT='#{default}', INTERNALLENGTH=#{internallength}, ALIGNMENT=#{alignment}, STORAGE=#{storage} ); SQL end |