Files

Class Index [+]

Quicksearch

ActiveRecord::ConnectionAdapters::PostgreSQLColumn

PostgreSQL-specific extensions to column definitions in a table.

Private Class Methods

extract_value_from_default(default) click to toggle source

Extracts the value from a PostgreSQL column default definition.

     # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 134
134:         def self.extract_value_from_default(default)
135:           case default
136:             # This is a performance optimization for Ruby 1.9.2 in development.
137:             # If the value is nil, we return nil straight away without checking
138:             # the regular expressions. If we check each regular expression,
139:             # Regexp#=== will call NilClass#to_str, which will trigger
140:             # method_missing (defined by whiny nil in ActiveSupport) which
141:             # makes this method very very slow.
142:             when NilClass
143:               nil
144:             # Numeric types
145:             when /\A\(?(-?\d+(\.\d*)?\)?)\z/
146:               $1
147:             # Character types
148:             when /\A'(.*)'::(?:character varying|bpchar|text)\z/
149:               $1
150:             # Character types (8.1 formatting)
151:             when /\AE'(.*)'::(?:character varying|bpchar|text)\z/
152:               $1.gsub(/\\(\d\d\d)/) { $1.oct.chr }
153:             # Binary data types
154:             when /\A'(.*)'::bytea\z/
155:               $1
156:             # Date/time types
157:             when /\A'(.+)'::(?:time(?:stamp)? with(?:out)? time zone|date)\z/
158:               $1
159:             when /\A'(.*)'::interval\z/
160:               $1
161:             # Boolean type
162:             when 'true'
163:               true
164:             when 'false'
165:               false
166:             # Geometric types
167:             when /\A'(.*)'::(?:point|line|lseg|box|"?path"?|polygon|circle)\z/
168:               $1
169:             # Network address types
170:             when /\A'(.*)'::(?:cidr|inet|macaddr)\z/
171:               $1
172:             # Bit string types
173:             when /\AB'(.*)'::"?bit(?: varying)?"?\z/
174:               $1
175:             # XML type
176:             when /\A'(.*)'::xml\z/
177:               $1
178:             # Arrays
179:             when /\A'(.*)'::"?\D+"?\[\]\z/
180:               $1
181:             # Object identifier types
182:             when /\A-?\d+\z/
183:               $1
184:             else
185:               # Anything else is blank, some user type, or some function
186:               # and we can't know the value of that, so return nil.
187:               nil
188:           end
189:         end

Private Instance Methods

extract_limit(sql_type) click to toggle source
    # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 57
57:         def extract_limit(sql_type)
58:           case sql_type
59:           when /^bigint/;    8
60:           when /^smallint/;  2
61:           else super
62:           end
63:         end
extract_precision(sql_type) click to toggle source

Extracts the precision from PostgreSQL-specific data types.

    # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 72
72:         def extract_precision(sql_type)
73:           if sql_type == 'money'
74:             self.class.money_precision
75:           else
76:             super
77:           end
78:         end
extract_scale(sql_type) click to toggle source

Extracts the scale from PostgreSQL-specific data types.

    # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 66
66:         def extract_scale(sql_type)
67:           # Money type has a fixed scale of 2.
68:           sql_type =~ /^money/ ? 2 : super
69:         end
simplified_type(field_type) click to toggle source

Maps PostgreSQL-specific data types to logical Rails types.

     # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 81
 81:         def simplified_type(field_type)
 82:           case field_type
 83:             # Numeric and monetary types
 84:             when /^(?:real|double precision)$/
 85:               :float
 86:             # Monetary types
 87:             when 'money'
 88:               :decimal
 89:             # Character types
 90:             when /^(?:character varying|bpchar)(?:\(\d+\))?$/
 91:               :string
 92:             # Binary data types
 93:             when 'bytea'
 94:               :binary
 95:             # Date/time types
 96:             when /^timestamp with(?:out)? time zone$/
 97:               :datetime
 98:             when 'interval'
 99:               :string
100:             # Geometric types
101:             when /^(?:point|line|lseg|box|"?path"?|polygon|circle)$/
102:               :string
103:             # Network address types
104:             when /^(?:cidr|inet|macaddr)$/
105:               :string
106:             # Bit strings
107:             when /^bit(?: varying)?(?:\(\d+\))?$/
108:               :string
109:             # XML type
110:             when 'xml'
111:               :xml
112:             # tsvector type
113:             when 'tsvector'
114:               :tsvector
115:             # Arrays
116:             when /^\D+\[\]$/
117:               :string
118:             # Object identifier types
119:             when 'oid'
120:               :integer
121:             # UUID type
122:             when 'uuid'
123:               :string
124:             # Small and big integer types
125:             when /^(?:small|big)int$/
126:               :integer
127:             # Pass through all types that are not specific to PostgreSQL.
128:             else
129:               super
130:           end
131:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.