Module: Sequel::Cubrid::DatabaseMethods

Extended by:
Database::ResetIdentifierMangling
Includes:
Database::SplitAlterTable
Included in:
Database, JDBC::Cubrid::DatabaseMethods
Defined in:
lib/sequel/adapters/shared/cubrid.rb

Constant Summary collapse

AUTOINCREMENT =
'AUTO_INCREMENT'.freeze
COLUMN_DEFINITION_ORDER =
[:auto_increment, :default, :null, :unique, :primary_key, :references]

Instance Method Summary collapse

Methods included from Database::ResetIdentifierMangling

extended

Instance Method Details

#database_typeObject



13
14
15
# File 'lib/sequel/adapters/shared/cubrid.rb', line 13

def database_type
  :cubrid
end

#indexes(table, opts = OPTS) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sequel/adapters/shared/cubrid.rb', line 17

def indexes(table, opts=OPTS)
  m = output_identifier_meth
  m2 = input_identifier_meth
  indexes = {}
  .
    from(:db_index___i).
    join(:db_index_key___k, :index_name=>:index_name, :class_name=>:class_name).
    where(:i__class_name=>m2.call(table), :is_primary_key=>'NO').
    order(:k__key_order).
    select(:i__index_name, :k__key_attr_name___column, :is_unique).
    each do |row|
      index = indexes[m.call(row[:index_name])] ||= {:columns=>[], :unique=>row[:is_unique]=='YES'}
      index[:columns] << m.call(row[:column])
    end
  indexes
end

#schema_parse_table(table_name, opts) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/sequel/adapters/shared/cubrid.rb', line 38

def schema_parse_table(table_name, opts)
  m = output_identifier_meth(opts[:dataset])
  m2 = input_identifier_meth(opts[:dataset])

  pks = .
    from(:db_index___i).
    join(:db_index_key___k, :index_name=>:index_name, :class_name=>:class_name).
    where(:i__class_name=>m2.call(table_name), :is_primary_key=>'YES').
    order(:k__key_order).
    select_map(:k__key_attr_name).
    map{|c| m.call(c)}

  .
    from(:db_attribute).
    where(:class_name=>m2.call(table_name)).
    order(:def_order).
    select(:attr_name, :data_type___db_type, :default_value___default, :is_nullable___allow_null, :prec).
    map do |row|
      name = m.call(row.delete(:attr_name))
      row[:allow_null] = row[:allow_null] == 'YES'
      row[:primary_key] = pks.include?(name)
      row[:type] = schema_column_type(row[:db_type])
      row[:max_length] = row[:prec] if row[:type] == :string
      [name, row]
    end
end

#supports_savepoints?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sequel/adapters/shared/cubrid.rb', line 34

def supports_savepoints?
  false
end

#tables(opts = OPTS) ⇒ Object



65
66
67
# File 'lib/sequel/adapters/shared/cubrid.rb', line 65

def tables(opts=OPTS)
  _tables('CLASS')
end

#views(opts = OPTS) ⇒ Object



69
70
71
# File 'lib/sequel/adapters/shared/cubrid.rb', line 69

def views(opts=OPTS)
  _tables('VCLASS')
end