class Oraora::Meta::Column

Constants

CHAR_USED_MAP

Attributes

id[R]
name[R]

Public Class Methods

new(schema, relation, name, attributes = {}) click to toggle source
# File lib/oraora/meta/column.rb, line 7
def initialize(schema, relation, name, attributes = {})
  @schema = schema
  @relation = relation
  @name = name
  attributes.each { |k, v| instance_variable_set("@#{k}".to_sym, v) }
end

Public Instance Methods

describe(options = {}) click to toggle source
# File lib/oraora/meta/column.rb, line 14
      def describe(options = {})
        <<-HERE.reset_indentation
          Column #{@schema}.#{@relation}.#{@name}
          Id:           #{@id}
          Type:         #{display_type}
        HERE
      end
display_type() click to toggle source
# File lib/oraora/meta/column.rb, line 26
def display_type
  case @type
    when 'NUMBER'
      case
        when !@precision && !@scale then "NUMBER"
        when !@precision && @scale == 0 then "INTEGER"
        when @scale == 0 then "NUMBER(#{@precision})"
        else "NUMBER(#{@precision},#{@scale})"
      end
    when 'CHAR', 'NCHAR'
      @char_length == 1 ? 'CHAR' : "CHAR(#{@char_length} #{@char_used})"
    when 'VARCHAR', 'VARCHAR2', 'NVARCHAR2'
      "#{@type}(#{@char_length} #{CHAR_USED_MAP[@char_used]})"
    else
      @type
  end
end
list(options = {}, filter = nil) click to toggle source
# File lib/oraora/meta/column.rb, line 22
def list(options = {}, filter = nil)
  raise NotApplicable, "Nothing to list for column"
end