# File lib/jdbc_adapter/jdbc_postgre.rb, line 52 def cast_to_boolean(value) return nil if value.nil? if value == true || value == false value else %(true t 1).include?(value.to_s.downcase) end end
Post process default value from JDBC into a Rails-friendly format (columns{-internal})
# File lib/jdbc_adapter/jdbc_postgre.rb, line 62 def default_value(value) # Boolean types return "t" if value =~ /true/ return "f" if value =~ /false/ # Char/String/Bytea type values return $1 if value =~ /^'(.*)'::(bpchar|text|character varying|bytea)$/ # Numeric values return value if value =~ /^-?[0-9]+(\.[0-9]*)?/ # Fixed dates / timestamp return $1 if value =~ /^'(.+)'::(date|timestamp)/ # Anything else is blank, some user type, or some function # and we can't know the value of that, so return nil. return nil end
# File lib/jdbc_adapter/jdbc_postgre.rb, line 41 def simplified_type(field_type) return :integer if field_type =~ /^serial/ return :string if field_type =~ /\[\]$/ || field_type =~ /^interval/ return :string if field_type =~ /^(?:point|lseg|box|"?path"?|polygon|circle)/ return :datetime if field_type =~ /^timestamp/ return :float if field_type =~ /^real|^money/ return :binary if field_type =~ /^bytea/ return :boolean if field_type =~ /^bool/ super end
Generated with the Darkfish Rdoc Generator 2.