Class: Lutaml::Qea::Models::EaDatatype

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/lutaml/qea/models/ea_datatype.rb

Overview

Represents a data type definition from t_datatypes table

This table stores database-specific type definitions and mappings. It maps database vendor types (e.g., “VARCHAR2” in Oracle) to generic types (e.g., “varchar”). This is metadata for database schema generation, not UML DataType instances.

Examples:

datatype = EaDatatype.new
datatype.type #=> "DDL"
datatype.product_name #=> "Oracle"
datatype.data_type #=> "VARCHAR2"
datatype.generic_type #=> "varchar"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

from_db_row, #primary_key

Class Method Details

.primary_key_columnObject



45
46
47
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 45

def self.primary_key_column
  :datatypeid
end

.table_nameObject



41
42
43
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 41

def self.table_name
  "t_datatypes"
end

Instance Method Details

#code_type?Boolean

Check if this is a Code type

Returns:

  • (Boolean)


57
58
59
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 57

def code_type?
  type == "Code"
end

#ddl_type?Boolean

Check if this is a DDL type

Returns:

  • (Boolean)


51
52
53
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 51

def ddl_type?
  type == "DDL"
end

#has_length?Boolean

Check if type has length parameter

Returns:

  • (Boolean)


69
70
71
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 69

def has_length?
  size == 1 || !haslength.nil?
end

#has_precision?Boolean

Check if type has precision parameter

Returns:

  • (Boolean)


75
76
77
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 75

def has_precision?
  size == 2
end

#type_signatureString

Get full type signature with size/precision

Returns:

  • (String)


81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 81

def type_signature
  case size
  when 0
    datatype
  when 1
    "#{datatype}(#{defaultlen})"
  when 2
    "#{datatype}(#{defaultprec},#{defaultscale})"
  else
    datatype
  end
end

#user_defined?Boolean

Check if this is a user-defined type

Returns:

  • (Boolean)


63
64
65
# File 'lib/lutaml/qea/models/ea_datatype.rb', line 63

def user_defined?
  user == 1
end