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
- #database_type ⇒ Object
- #indexes(table, opts = OPTS) ⇒ Object
- #schema_parse_table(table_name, opts) ⇒ Object
- #supports_savepoints? ⇒ Boolean
- #tables(opts = OPTS) ⇒ Object
- #views(opts = OPTS) ⇒ Object
Methods included from Database::ResetIdentifierMangling
Instance Method Details
#database_type ⇒ Object
15 16 17 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 15 def database_type :cubrid end |
#indexes(table, opts = OPTS) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 19 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 40 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
36 37 38 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 36 def supports_savepoints? false end |
#tables(opts = OPTS) ⇒ Object
67 68 69 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 67 def tables(opts=OPTS) _tables('CLASS') end |
#views(opts = OPTS) ⇒ Object
71 72 73 |
# File 'lib/sequel/adapters/shared/cubrid.rb', line 71 def views(opts=OPTS) _tables('VCLASS') end |