Class: ActiveRecord::ConnectionAdapters::AbstractCubrid2Adapter

Inherits:
AbstractAdapter
  • Object
show all
Includes:
Cubrid2::Quoting, Cubrid2::SchemaStatements
Defined in:
lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb

Direct Known Subclasses

Cubrid2Adapter

Defined Under Namespace

Classes: CubridString, StatementPool

Constant Summary collapse

NATIVE_DATABASE_TYPES =
{
  primary_key: 'bigint auto_increment PRIMARY KEY',
  string: { name: 'varchar', limit: 255 }, # 1_073_741_823
  text: { name: 'text' },
  integer: { name: 'int', limit: 4 },
  float: { name: 'float', limit: 24 },
  decimal: { name: 'decimal' },
  datetime: { name: 'datetime' },
  timestamp: { name: 'timestamp' },
  time: { name: 'time' },
  date: { name: 'date' },
  binary: { name: 'blob' },
  blob: { name: 'blob' },
  boolean: { name: 'smallint' },
  json: { name: 'json' }
}

Instance Method Summary collapse

Methods included from Cubrid2::SchemaStatements

#create_schema_dumper, #create_table, #indexes, #internal_string_options_for_primary_key, #remove_column, #table_alias_length, #type_to_sql, #update_table_definition

Methods included from Cubrid2::Quoting

#column_name_matcher, #column_name_with_order_matcher, #quote, #quote_column_name, #quote_schema_name, #quote_table_name, #quote_table_name_for_assignment, #quoted_binary, #quoted_date, #unquoted_false, #unquoted_true

Constructor Details

#initialize(connection, logger, _connection_options, config) ⇒ AbstractCubrid2Adapter

Returns a new instance of AbstractCubrid2Adapter.



56
57
58
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 56

def initialize(connection, logger, _connection_options, config)
  super(connection, logger, config)
end

Instance Method Details

#_strip_key_str(str) ⇒ Object



438
439
440
441
442
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 438

def _strip_key_str(str)
  str.gsub(/[\[\]]/, '')
     .gsub(/[()]/, '')
     .gsub(/^\s+/, '').gsub(/\s+$/, '')
end

#_strip_left_str(str) ⇒ Object



444
445
446
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 444

def _strip_left_str(str)
  str.gsub(/([;,)].*)$/, '')
end

#add_index(table_name, column_name, options = {}) ⇒ Object

:nodoc:



383
384
385
386
387
388
389
390
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 383

def add_index(table_name, column_name, options = {}) # :nodoc:
  index, algorithm, if_not_exists = add_index_options(table_name, column_name, **options)

  return if if_not_exists && index_exists?(table_name, column_name, name: index.name)

  create_index = CreateIndexDefinition.new(index, algorithm)
  execute schema_creation.accept(create_index)
end

#add_sql_comment!(sql, comment) ⇒ Object

:nodoc:



392
393
394
395
396
397
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 392

def add_sql_comment!(sql, comment) # :nodoc:
  return sql unless supports_comments?

  sql << " COMMENT #{quote(comment)}" if comment.present?
  sql
end

#begin_db_transactionObject



220
221
222
223
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 220

def begin_db_transaction
  # NOTE: no begin statement in cubrid
  # execute "BEGIN"
end

#begin_isolated_db_transaction(isolation) ⇒ Object



225
226
227
228
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 225

def begin_isolated_db_transaction(isolation)
  execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}"
  begin_db_transaction
end

#build_insert_sql(insert) ⇒ Object

:nodoc:



541
542
543
544
545
546
547
548
549
550
551
552
553
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 541

def build_insert_sql(insert) # :nodoc:
  sql = +"INSERT #{insert.into} #{insert.values_list}"

  if insert.skip_duplicates?
    no_op_column = quote_column_name(insert.keys.first)
    sql << " ON DUPLICATE KEY UPDATE #{no_op_column}=#{no_op_column}"
  elsif insert.update_duplicates?
    sql << ' ON DUPLICATE KEY UPDATE '
    sql << insert.updatable_columns.map { |column| "#{column}=VALUES(#{column})" }.join(',')
  end

  sql
end

#case_sensitive_comparison(attribute, value) ⇒ Object

:nodoc:



507
508
509
510
511
512
513
514
515
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 507

def case_sensitive_comparison(attribute, value) # :nodoc:
  column = column_for_attribute(attribute)

  if column.collation && !column.case_sensitive?
    attribute.eq(Arel::Nodes::Bin.new(value))
  else
    super
  end
end

#change_column(table_name, column_name, type, options = {}) ⇒ Object

:nodoc:



372
373
374
375
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 372

def change_column(table_name, column_name, type, options = {}) # :nodoc:
  execute("ALTER TABLE #{quote_table_name(table_name)} #{change_column_for_alter(table_name, column_name, type,
                                                                                 **options)}")
end

#change_column_comment(table_name, column_name, comment_or_changes) ⇒ Object

:nodoc:



367
368
369
370
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 367

def change_column_comment(table_name, column_name, comment_or_changes) # :nodoc:
  comment = extract_new_comment_value(comment_or_changes)
  change_column table_name, column_name, nil, comment: comment
end

#change_column_default(table_name, column_name, default_or_changes) ⇒ Object

:nodoc:



354
355
356
357
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 354

def change_column_default(table_name, column_name, default_or_changes) # :nodoc:
  default = extract_new_default_value(default_or_changes)
  change_column table_name, column_name, nil, default: default
end

#change_column_null(table_name, column_name, null, default = nil) ⇒ Object

:nodoc:



359
360
361
362
363
364
365
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 359

def change_column_null(table_name, column_name, null, default = nil) # :nodoc:
  unless null || default.nil?
    execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL")
  end

  change_column table_name, column_name, nil, null: null
end

#change_table_comment(table_name, comment_or_changes) ⇒ Object

:nodoc:



303
304
305
306
307
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 303

def change_table_comment(table_name, comment_or_changes) # :nodoc:
  comment = extract_new_comment_value(comment_or_changes)
  comment = '' if comment.nil?
  execute("ALTER TABLE #{quote_table_name(table_name)} COMMENT=#{quote(comment)}")
end

#charsetObject

Returns the database character set.



277
278
279
280
281
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 277

def charset
  # check character set:
  # See: https://www.cubrid.com/qna/3802763
  @charset ||= query_value("select charset('ABC')", 'SCHEMA')
end

#check_versionObject

:nodoc:



555
556
557
558
559
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 555

def check_version # :nodoc:
  return unless database_version < '9.0'

  raise "Your version of Cubrid (#{database_version}) is too old. Active Record supports Cubrid >= 9.0."
end

#collationObject

Returns the database collation strategy.



284
285
286
287
288
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 284

def collation
  # check collation set:
  # See: https://www.cubrid.com/qna/3802763
  @collation ||= query_value("select collation('ABC')", 'SCHEMA')
end

#columns_for_distinct(columns, orders) ⇒ Object

:nodoc:



522
523
524
525
526
527
528
529
530
531
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 522

def columns_for_distinct(columns, orders) # :nodoc:
  order_columns = orders.reject(&:blank?).map do |s|
    # Convert Arel node to string
    s = visitor.compile(s) unless s.is_a?(String)
    # Remove any ASC/DESC modifiers
    s.gsub(/\s+(?:ASC|DESC)\b/i, '')
  end.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" }

  (order_columns << super).join(', ')
end

#commit_db_transactionObject

:nodoc:



230
231
232
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 230

def commit_db_transaction # :nodoc:
  execute 'COMMIT'
end

#create_database(name, options = {}) ⇒ Object

Create a new Cubrid database TODO: not workign with rake db:create



252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 252

def create_database(name, options = {})
  options[:db_volume_size] ||= '20' # megabytes
  options[:log_volume_size] ||= '20' # megabytes
  options[:encoding] ||= 'en_US.utf8'

  Kernel.exec 'cubrid createdb ' +
       "--db-volume-size=#{options[:db_volume_size]}M " +
       "--log-volume-size=#{options[:log_volume_size]}M #{name} " +
       "#{options[:encoding]}"
  
  Kernel.exec "cubrid service start #{name}"
end

#current_databaseObject



272
273
274
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 272

def current_database
  query_value('SELECT database()', 'SCHEMA')
end

#default_index_type?(index) ⇒ Boolean

def strict_mode?

self.class.type_cast_config_to_boolean(@config.fetch(:strict, true))

end

Returns:

  • (Boolean)


537
538
539
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 537

def default_index_type?(index) # :nodoc:
  index.using == :btree || super
end

#default_uniqueness_comparison(attribute, value) ⇒ Object

:nodoc:



481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 481

def default_uniqueness_comparison(attribute, value, klass = nil) # :nodoc:
  column = column_for_attribute(attribute)

  if column.collation && !column.case_sensitive? && !value.nil?
    ActiveSupport::Deprecation.warn(<<~MSG.squish)
      Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
      To continue case sensitive comparison on the :#{attribute.name} attribute in #{klass} model,
      pass `case_sensitive: true` option explicitly to the uniqueness validator.
    MSG
    attribute.eq(Arel::Nodes::Bin.new(value))
  else
    super
  end
end

#drop_database(name) ⇒ Object

Drops a Cubrid database TODO: not workign with rake db:drop



267
268
269
270
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 267

def drop_database(name)
  Kernel.exec "cubrid service stop #{name}"
  Kernel.exec "cubrid deletedb #{name}"        
end

#drop_table(table_name, options = {}) ⇒ Object

Drops a table from the database.

:force

Set to :cascade to drop dependent objects as well. Defaults to false.

:if_exists

Set to true to only drop the table if it exists. Defaults to false.

:temporary

Set to true to drop temporary table. Defaults to false.

Although this command ignores most options and the block if one is given, it can be helpful to provide these in a migration’s change method so it can be reverted. In that case, options and the block will be used by create_table.



333
334
335
336
337
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 333

def drop_table(table_name, options = {})
  if_exists = (options[:if_exists] ? 'IF EXISTS' : '')
  cascade = (options[:force] == :cascade ? 'CASCADE CONSTRAINTS' : '')
  execute "DROP TABLE #{if_exists} #{quote_table_name(table_name)} #{cascade}"
end

#each_hash(result) ⇒ Object

The two drivers have slightly different ways of yielding hashes of results, so this method must be implemented to provide a uniform interface.

Raises:

  • (NotImplementedError)


154
155
156
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 154

def each_hash(result) # :nodoc:
  raise NotImplementedError
end

#empty_insert_statement_value(_primary_key = nil) ⇒ Object



238
239
240
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 238

def empty_insert_statement_value(_primary_key = nil)
  'VALUES ()'
end

#emulate_booleansObject

:singleton-method: By default, the CubridAdapter will consider all columns of type tinyint(1) as boolean. If you wish to disable this emulation you can add the following line to your application.rb file:

ActiveRecord::ConnectionAdapters::CubridAdapter.emulate_booleans = false


29
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 29

class_attribute :emulate_booleans, default: true

#error_number(exception) ⇒ Object

Must return the Cubrid error number from the exception, if the exception has an error number.

Raises:

  • (NotImplementedError)


160
161
162
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 160

def error_number(exception) # :nodoc:
  raise NotImplementedError
end

#exec_rollback_db_transactionObject

:nodoc:



234
235
236
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 234

def exec_rollback_db_transaction # :nodoc:
  execute 'ROLLBACK'
end

#execute(sql, name = nil) ⇒ Object

Executes the SQL statement in the context of this connection.



198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 198

def execute(sql, name = nil)
  materialize_transactions

  stmt = nil

  # pp "######### #{sql}"
  log(sql, name) do
    ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
      stmt = @connection.query(sql)
    end
  end

  stmt
end

#execute_and_free(sql, name = nil) {|execute(sql, name)| ... } ⇒ Object

CubridAdapter doesn’t have to free a result after using it, but we use this method to write stuff in an abstract way without concerning ourselves about whether it needs to be explicitly freed or not.

Yields:



216
217
218
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 216

def execute_and_free(sql, name = nil) # :nodoc:
  yield execute(sql, name)
end

#explain(arel, binds = []) ⇒ Object

– DATABASE STATEMENTS ====================================== ++



188
189
190
191
192
193
194
195
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 188

def explain(arel, binds = [])
  sql     = "EXPLAIN #{to_sql(arel, binds)}"
  start   = Concurrent.monotonic_time
  result  = exec_query(sql, 'EXPLAIN', binds)
  elapsed = Concurrent.monotonic_time - start

  Cubrid2::ExplainPrettyPrinter.new.pp(result, elapsed)
end

#foreign_keys(table_name) ⇒ Object

Raises:

  • (ArgumentError)


399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 399

def foreign_keys(table_name)
  raise ArgumentError unless table_name.present?

  # In Cubrid, we cannot know referencing table that foreign key indicates from the system catalog.
  # See: https://www.cubrid.com/qna/3822484
  # So we use the raw sql generated by 'SHOW CREATE TABLE ...'

  tableinfo = create_table_info(table_name)
  lines = tableinfo.gsub('CONSTRAINT', "\nCONSTRAINT").split('CONSTRAINT')

  fkeys = []
  lines.each do |line|
    fk_matches = line.match(/(.*) FOREIGN KEY (.*)/)
    next if fk_matches.nil?

    name = _strip_key_str(fk_matches[1])
    detail_match = fk_matches[2].match(/(.*) REFERENCES (.*) ON DELETE (.*) ON UPDATE (.*)\s*/)

    column = _strip_key_str(detail_match[1])
    to_table_match = detail_match[2]&.match(/(.*)\s+\((.*)\)/)

    to_table = _strip_key_str(to_table_match[1])
    primary_key = _strip_key_str(to_table_match[2])

    options = {
      name: name,
      column: column,
      primary_key: primary_key
    }

    options[:on_update] = extract_foreign_key_action(_strip_left_str(detail_match[3]))
    options[:on_delete] = extract_foreign_key_action(_strip_left_str(detail_match[4]))

    fkeys << ForeignKeyDefinition.new(table_name, to_table, options)
  end

  fkeys
end

#get_advisory_lock(_lock_name, _timeout = 0) ⇒ Object

In cubrid: locking is done automatically See: www.cubrid.org/manual/en/11.2/sql/transaction.html#id13



132
133
134
135
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 132

def get_advisory_lock(_lock_name, _timeout = 0) # :nodoc:
  # query_value("SELECT GET_LOCK(#{quote(lock_name.to_s)}, #{timeout})") == 1
  true
end

#get_database_versionObject

:nodoc:



60
61
62
63
64
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 60

def get_database_version # :nodoc:
  full_version_string = get_full_version
  version_string = version_string(full_version_string)
  Version.new(version_string, full_version_string)
end

#index_algorithmsObject



146
147
148
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 146

def index_algorithms
  {}
end

#native_database_typesObject



142
143
144
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 142

def native_database_types
  NATIVE_DATABASE_TYPES
end

#primary_keys(table_name) ⇒ Object

:nodoc:

Raises:

  • (ArgumentError)


470
471
472
473
474
475
476
477
478
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 470

def primary_keys(table_name) # :nodoc:
  raise ArgumentError unless table_name.present?

  prikeys = []
  column_definitions(table_name).each do |col|
    prikeys << col[:Field] if col[:Key] == 'PRI'
  end
  prikeys
end

#recreate_database(name, options = {}) ⇒ Object

Recreate database



245
246
247
248
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 245

def recreate_database(name, options = {})
  drop_database(name)
  create_database(name, options)
end

#release_advisory_lock(_lock_name) ⇒ Object

:nodoc:



137
138
139
140
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 137

def release_advisory_lock(_lock_name) # :nodoc:
  # query_value("SELECT RELEASE_LOCK(#{quote(lock_name.to_s)})") == 1
  true
end

#rename_column(table_name, column_name, new_column_name) ⇒ Object

:nodoc:



377
378
379
380
381
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 377

def rename_column(table_name, column_name, new_column_name) # :nodoc:
  execute("ALTER TABLE #{quote_table_name(table_name)} #{rename_column_for_alter(table_name, column_name,
                                                                                 new_column_name)}")
  rename_column_indexes(table_name, column_name, new_column_name)
end

#rename_index(table_name, old_name, new_name) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 339

def rename_index(table_name, old_name, new_name)
  if supports_rename_index?
    validate_index_length!(table_name, new_name)

    # NOTE: Renaming table index SQL would not work.
    # See: https://www.cubrid.org/manual/ko/10.2/sql/schema/index_stmt.html#alter-index
    #      https://www.cubrid.com/index.php?mid=qna&document_srl=3802148
    _query = "ALTER INDEX #{quote_table_name(old_name)} ON #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}"
    puts "Warning: renaming index not work as manual. Ignoring: #{_query}"
    # execute _query
  else
    super
  end
end

#rename_table(table_name, new_name) ⇒ Object

Renames a table.

Example:

rename_table('octopuses', 'octopi')


313
314
315
316
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 313

def rename_table(table_name, new_name)
  execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}"
  rename_table_indexes(table_name, new_name)
end

#show_variable(_name) ⇒ Object

SHOW VARIABLES LIKE ‘name’



466
467
468
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 466

def show_variable(_name)
  raise 'Not supported'
end

#supports_advisory_locks?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 114

def supports_advisory_locks?
  false
end

#supports_bulk_alter?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 66

def supports_bulk_alter?
  true
end

#supports_common_table_expressions?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 110

def supports_common_table_expressions?
  database_version >= '10.2'
end

#supports_datetime_with_precision?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 98

def supports_datetime_with_precision?
  false
end

#supports_explain?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 82

def supports_explain?
  true
end

#supports_expression_index?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 74

def supports_expression_index?
  false
end

#supports_foreign_keys?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 90

def supports_foreign_keys?
  true
end

#supports_index_sort_order?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 70

def supports_index_sort_order?
  false
end

#supports_indexes_in_create?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 86

def supports_indexes_in_create?
  true
end

#supports_insert_on_duplicate_skip?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 118

def supports_insert_on_duplicate_skip?
  true
end

#supports_insert_on_duplicate_update?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 122

def supports_insert_on_duplicate_update?
  true
end

#supports_optimizer_hints?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 106

def supports_optimizer_hints?
  false
end

#supports_rename_column?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 126

def supports_rename_column?
  true
end

#supports_transaction_isolation?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 78

def supports_transaction_isolation?
  true
end

#supports_views?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 94

def supports_views?
  true
end

#supports_virtual_columns?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 102

def supports_virtual_columns?
  true
end

#table_comment(table_name) ⇒ Object

:nodoc:



290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 290

def table_comment(table_name) # :nodoc:
  raise 'table comment not supported' unless supports_comments?

  query_value(<<~SQL, 'SCHEMA').presence
    SELECT comment
    FROM db_class
    WHERE owner_name = 'PUBLIC'
      AND class_type = 'CLASS'
      AND is_system_class = 'NO'
      AND class_name = #{quote(table_name)}
  SQL
end

#table_options(table_name) ⇒ Object

:nodoc:



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 448

def table_options(table_name) # :nodoc:
  table_options = {}

  tableinfo = create_table_info(table_name)

  # strip create_definitions and partition_options
  # Be aware that `create_table_info` might not include any table options due to `NO_TABLE_OPTIONS` sql mode.
  raw_table_options = tableinfo.sub(/\A.*\n\) ?/m, '').sub(%r{\n/\*!.*\*/\n\z}m, '').strip

  table_options[:options] = raw_table_options unless raw_table_options.blank?

  # strip COMMENT
  table_options[:comment] = table_comment(table_name) if raw_table_options.sub!(/ COMMENT='.+'/, '')

  table_options
end