lib/arjdbc/postgresql/adapter.rb
# Returns the list of all column definitions for a table.
Returns the list of all column definitions for a table.
Returns the list of all column definitions for a table .
def columns(table_name, name = nil)
      klass = ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn
      column_definitions(table_name).map do |row|
        name = row[0]; type = row[1]; default = row[2]
        notnull = row[3]; oid = row[4]; fmod = row[5]
        notnull = notnull == 't' if notnull.is_a?(String) 
        if default =~ /^nextval\(.*?\:\:regclass\)$/
          default = nil
        elsif default =~ /^\(([-+]?[\d\.]+)\)$/ 
          default = $1
        end
        klass.new(name, default, oid, type, ! notnull)
      end
    end
def columns ( table_name , name = nil ) klass = :: ActiveRecord :: ConnectionAdapters :: PostgreSQLColumn column_definitions ( table_name ) . map do | row | name = row [ 0 ] ; type = row [ 1 ] ; default = row [ 2 ] notnull = row [ 3 ] ; oid = row [ 4 ] ; fmod = row [ 5 ] notnull = notnull == 't' if notnull . is_a? ( String ) if default =~ / ^nextval \( .*? \: \: regclass \) $ / default = nil elsif default =~ / ^ \( ([-+]?[ \d \. ]+) \) $ / default = $1 end klass . new ( name , default , oid , type , ! notnull ) end end
Returns the list of all column definitions for a table.
Returns the list of all column definitions for a table .
# name, type, default, notnull, oid, fmod # oid = OID::TYPE_MAP.fetch(oid.to_i, fmod.to_i) { OID::Identity.new } # JDBC gets true/false # for ID columns we get a bit of non-sense default : # e.g. "nextval('mixed_cases_id_seq'::regclass" # e.g. "(-1)" for a negative default
table_name
name