class ActiveFacts::Metamodel::DataType::DefaultContext

Public Instance Methods

boolean_type() click to toggle source
# File lib/activefacts/metamodel/datatypes.rb, line 120
def boolean_type
  'CHAR'
end
default_length(data_type, type_name) click to toggle source
# File lib/activefacts/metamodel/datatypes.rb, line 99
def default_length data_type, type_name
  case data_type
  when TYPE_Real
    53        # IEEE Double precision floating point
  when TYPE_Integer
    case type_name
    when /([a-z ]|\b)Tiny([a-z ]|\b)/i
      8
    when /([a-z ]|\b)Small([a-z ]|\b)/i,
      /([a-z ]|\b)Short([a-z ]|\b)/i
      16
    when /([a-z ]|\b)(Big|Long)([a-z ]|\b)/i
      64
    else
      32
    end
  else
    nil
  end
end
integer_ranges() click to toggle source
# File lib/activefacts/metamodel/datatypes.rb, line 90
def integer_ranges
  # A set suitable for Standard SQL:
  [
    ['SMALLINT', -2**15, 2**15-1, 16],  # The SQL standard says -10^5..10^5 (less than 16 bits)
    ['INTEGER', -2**31, 2**31-1, 32],   # The standard says -10^10..10^10 (more than 32 bits!)
    ['BIGINT', -2**63, 2**63-1, 64],    # The standard says -10^19..10^19 (less than 64 bits)
  ]
end
surrogate_type() click to toggle source
# File lib/activefacts/metamodel/datatypes.rb, line 124
def surrogate_type
  'BIGINT'
end