module Sequel::Cubrid::DatabaseMethods

  1. lib/sequel/adapters/shared/cubrid.rb
Parent: Cubrid

Constants

AUTOINCREMENT = 'AUTO_INCREMENT'.freeze  
COLUMN_DEFINITION_ORDER = [:auto_increment, :default, :null, :unique, :primary_key, :references]  
DATABASE_ERROR_REGEXPS = { /Operation would have caused one or more unique constraint violations/ => UniqueConstraintViolation, /The constraint of the foreign key .+ is invalid|Update\/Delete operations are restricted by the foreign key/ => ForeignKeyConstraintViolation, /cannot be made NULL/ => NotNullConstraintViolation, /Your transaction .+ has been unilaterally aborted by the system/ => SerializationFailure, }.freeze  

Public Instance methods

database_type ()
[show source]
# File lib/sequel/adapters/shared/cubrid.rb, line 13
def database_type
  :cubrid
end
indexes (table, opts=OPTS)
[show source]
# File lib/sequel/adapters/shared/cubrid.rb, line 17
def indexes(table, opts=OPTS)
  m = output_identifier_meth
  m2 = input_identifier_meth
  indexes = {}
  metadata_dataset.
    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)
[show source]
# 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 = metadata_dataset.
    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)}

  metadata_dataset.
    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).
    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])
      [name, row]
    end
end
supports_savepoints? ()
[show source]
# File lib/sequel/adapters/shared/cubrid.rb, line 34
def supports_savepoints?
  false
end
tables (opts=OPTS)
[show source]
# File lib/sequel/adapters/shared/cubrid.rb, line 64
def tables(opts=OPTS)
  _tables('CLASS')
end
views (opts=OPTS)
[show source]
# File lib/sequel/adapters/shared/cubrid.rb, line 68
def views(opts=OPTS)
  _tables('VCLASS')
end