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,
}

Class Method Summary collapse

Class Method Details

.make_name(base_type, modifiers, properties) ⇒ Object



403
404
405
406
407
408
409
# File 'lib/innodb/data_type.rb', line 403

def self.make_name(base_type, modifiers, properties)
  name = base_type.to_s
  name << '(' + modifiers.join(',') + ')' if not modifiers.empty?
  name << " "
  name << properties.join(' ')
  name.strip
end

.new(base_type, modifiers, properties) ⇒ Object



411
412
413
414
# File 'lib/innodb/data_type.rb', line 411

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