Class: Innodb::DataType

Inherits:
Object
  • Object
show all
Defined in:
lib/innodb/data_type.rb

Defined Under Namespace

Classes: BinaryType, BitType, BlobType, CharacterType, DateType, DatetimeType, DecimalType, DoubleType, FloatType, IntegerType, RollPointerType, TimeType, TimestampType, TransactionIdType, VariableBinaryType, VariableCharacterType, YearType

Constant Summary collapse

TYPES =

Maps base type to data type class.

{
  BIT: BitType,
  BOOL: IntegerType,
  BOOLEAN: IntegerType,
  TINYINT: IntegerType,
  SMALLINT: IntegerType,
  MEDIUMINT: IntegerType,
  INT: IntegerType,
  INT6: IntegerType,
  BIGINT: IntegerType,
  FLOAT: FloatType,
  DOUBLE: DoubleType,
  DECIMAL: DecimalType,
  NUMERIC: DecimalType,
  CHAR: CharacterType,
  VARCHAR: VariableCharacterType,
  BINARY: BinaryType,
  VARBINARY: VariableBinaryType,
  TINYBLOB: BlobType,
  BLOB: BlobType,
  MEDIUMBLOB: BlobType,
  LONGBLOB: BlobType,
  TINYTEXT: BlobType,
  TEXT: BlobType,
  MEDIUMTEXT: BlobType,
  LONGTEXT: BlobType,
  YEAR: YearType,
  TIME: TimeType,
  DATE: DateType,
  DATETIME: DatetimeType,
  TIMESTAMP: TimestampType,
  TRX_ID: TransactionIdType,
  ROLL_PTR: RollPointerType,
}.freeze

Class Method Summary collapse

Class Method Details

.make_name(base_type, modifiers, properties) ⇒ Object



438
439
440
441
442
443
444
# File 'lib/innodb/data_type.rb', line 438

def self.make_name(base_type, modifiers, properties)
  name = base_type.to_s.dup
  name << "(#{modifiers.join(',')})" unless modifiers.empty?
  name << " "
  name << properties.join(" ")
  name.strip
end

.new(base_type, modifiers, properties) ⇒ Object



446
447
448
449
450
# File 'lib/innodb/data_type.rb', line 446

def self.new(base_type, modifiers, properties)
  raise "Data type '#{base_type}' is not supported" unless TYPES.key?(base_type)

  TYPES[base_type].new(base_type, modifiers, properties)
end