Class: ActiveFacts::Metamodel::DataType::DefaultContext

Inherits:
Context
  • Object
show all
Defined in:
lib/activefacts/metamodel/datatypes.rb

Direct Known Subclasses

ModContext

Instance Method Summary collapse

Methods inherited from Context

#choose_integer_range, #initialize

Constructor Details

This class inherits a constructor from ActiveFacts::Metamodel::DataType::Context

Instance Method Details

#boolean_typeObject



120
121
122
# File 'lib/activefacts/metamodel/datatypes.rb', line 120

def boolean_type
  'CHAR'
end

#default_length(data_type, type_name) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# 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_rangesObject



90
91
92
93
94
95
96
97
# 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_typeObject



124
125
126
# File 'lib/activefacts/metamodel/datatypes.rb', line 124

def surrogate_type
  'BIGINT'
end