Class: Sequel::ADO::Access::AdoSchema::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/adapters/ado/access.rb

Constant Summary collapse

DATA_TYPE =
{
  2   => "SMALLINT",
  3   => "INTEGER",
  4   => "REAL",
  5   => "DOUBLE",
  6   => "MONEY",
  7   => "DATETIME",
  11  => "BIT",
  14  => "DECIMAL",
  16  => "TINYINT",
  17  => "BYTE",
  72  => "GUID",
  128 => "BINARY",
  130 => "TEXT",
  131 => "DECIMAL",
  201 => "TEXT",
  205 => "IMAGE"
}

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Column

Returns a new instance of Column.



45
46
47
# File 'lib/sequel/adapters/ado/access.rb', line 45

def initialize(row)
  @row = row
end

Instance Method Details

#[](col) ⇒ Object



49
50
51
# File 'lib/sequel/adapters/ado/access.rb', line 49

def [](col)
  @row[col]
end

#allow_nullObject



53
54
55
# File 'lib/sequel/adapters/ado/access.rb', line 53

def allow_null
  self["IS_NULLABLE"]
end

#db_typeObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/sequel/adapters/ado/access.rb', line 61

def db_type
  t = DATA_TYPE[self["DATA_TYPE"]]
  if t == "DECIMAL" && precision
    t + "(#{precision.to_i},#{(scale || 0).to_i})"
  elsif t == "TEXT" && maximum_length && maximum_length > 0
    t + "(#{maximum_length.to_i})"
  else
    t
  end
end

#defaultObject



57
58
59
# File 'lib/sequel/adapters/ado/access.rb', line 57

def default
  self["COLUMN_DEFAULT"]
end

#maximum_lengthObject



80
81
82
# File 'lib/sequel/adapters/ado/access.rb', line 80

def maximum_length
  self["CHARACTER_MAXIMUM_LENGTH"]
end

#precisionObject



72
73
74
# File 'lib/sequel/adapters/ado/access.rb', line 72

def precision
  self["NUMERIC_PRECISION"]
end

#scaleObject



76
77
78
# File 'lib/sequel/adapters/ado/access.rb', line 76

def scale
  self["NUMERIC_SCALE"]
end