Class: ActiveRecord::ConnectionAdapters::AbstractCubrid2Adapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::AbstractCubrid2Adapter
- Includes:
- Cubrid2::Quoting, Cubrid2::SchemaStatements
- Defined in:
- lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb
Direct Known Subclasses
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
- #_strip_key_str(str) ⇒ Object
- #_strip_left_str(str) ⇒ Object
-
#add_index(table_name, column_name, options = {}) ⇒ Object
:nodoc:.
-
#add_sql_comment!(sql, comment) ⇒ Object
:nodoc:.
- #begin_db_transaction ⇒ Object
- #begin_isolated_db_transaction(isolation) ⇒ Object
-
#build_insert_sql(insert) ⇒ Object
:nodoc:.
-
#case_sensitive_comparison(attribute, value) ⇒ Object
:nodoc:.
-
#change_column(table_name, column_name, type, options = {}) ⇒ Object
:nodoc:.
-
#change_column_comment(table_name, column_name, comment_or_changes) ⇒ Object
:nodoc:.
-
#change_column_default(table_name, column_name, default_or_changes) ⇒ Object
:nodoc:.
-
#change_column_null(table_name, column_name, null, default = nil) ⇒ Object
:nodoc:.
-
#change_table_comment(table_name, comment_or_changes) ⇒ Object
:nodoc:.
-
#charset ⇒ Object
Returns the database character set.
-
#check_version ⇒ Object
:nodoc:.
-
#collation ⇒ Object
Returns the database collation strategy.
-
#columns_for_distinct(columns, orders) ⇒ Object
:nodoc:.
-
#commit_db_transaction ⇒ Object
:nodoc:.
-
#create_database(_name, _options = {}) ⇒ Object
Create a new Cubrid database: not supported now.
- #current_database ⇒ Object
-
#default_index_type?(index) ⇒ Boolean
def strict_mode? self.class.type_cast_config_to_boolean(@config.fetch(:strict, true)) end.
-
#default_uniqueness_comparison(attribute, value, klass) ⇒ Object
:nodoc:.
-
#drop_database(_name) ⇒ Object
Drops a Cubrid database: not supported now.
-
#drop_table(table_name, options = {}) ⇒ Object
Drops a table from the database.
-
#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.
- #empty_insert_statement_value(_primary_key = nil) ⇒ Object
-
#emulate_booleans ⇒ Object
:singleton-method: By default, the CubridAdapter will consider all columns of type
tinyint(1)as boolean. -
#error_number(exception) ⇒ Object
Must return the Cubrid error number from the exception, if the exception has an error number.
-
#exec_rollback_db_transaction ⇒ Object
:nodoc:.
-
#execute(sql, name = nil) ⇒ Object
Executes the SQL statement in the context of this connection.
-
#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.
-
#explain(arel, binds = []) ⇒ Object
– DATABASE STATEMENTS ====================================== ++.
- #foreign_keys(table_name) ⇒ Object
-
#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.
-
#get_database_version ⇒ Object
:nodoc:.
- #index_algorithms ⇒ Object
-
#initialize(connection, logger, _connection_options, config) ⇒ AbstractCubrid2Adapter
constructor
A new instance of AbstractCubrid2Adapter.
- #native_database_types ⇒ Object
-
#primary_keys(table_name) ⇒ Object
:nodoc:.
-
#recreate_database(_name, _options = {}) ⇒ Object
Drops the database: not supported now.
-
#release_advisory_lock(_lock_name) ⇒ Object
:nodoc:.
-
#rename_column(table_name, column_name, new_column_name) ⇒ Object
:nodoc:.
- #rename_index(table_name, old_name, new_name) ⇒ Object
-
#rename_table(table_name, new_name) ⇒ Object
Renames a table.
-
#show_variable(_name) ⇒ Object
SHOW VARIABLES LIKE ‘name’.
- #supports_advisory_locks? ⇒ Boolean
- #supports_bulk_alter? ⇒ Boolean
- #supports_common_table_expressions? ⇒ Boolean
- #supports_datetime_with_precision? ⇒ Boolean
- #supports_explain? ⇒ Boolean
- #supports_expression_index? ⇒ Boolean
- #supports_foreign_keys? ⇒ Boolean
- #supports_index_sort_order? ⇒ Boolean
- #supports_indexes_in_create? ⇒ Boolean
- #supports_insert_on_duplicate_skip? ⇒ Boolean
- #supports_insert_on_duplicate_update? ⇒ Boolean
- #supports_optimizer_hints? ⇒ Boolean
- #supports_rename_column? ⇒ Boolean
- #supports_transaction_isolation? ⇒ Boolean
- #supports_views? ⇒ Boolean
- #supports_virtual_columns? ⇒ Boolean
-
#table_comment(table_name) ⇒ Object
:nodoc:.
-
#table_options(table_name) ⇒ Object
:nodoc:.
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, , config) super(connection, logger, config) end |
Instance Method Details
#_strip_key_str(str) ⇒ Object
425 426 427 428 429 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 425 def _strip_key_str(str) str.gsub(/[\[\]]/, '') .gsub(/[()]/, '') .gsub(/^\s+/, '').gsub(/\s+$/, '') end |
#_strip_left_str(str) ⇒ Object
431 432 433 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 431 def _strip_left_str(str) str.gsub(/([;,)].*)$/, '') end |
#add_index(table_name, column_name, options = {}) ⇒ Object
:nodoc:
370 371 372 373 374 375 376 377 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 370 def add_index(table_name, column_name, = {}) # :nodoc: index, algorithm, if_not_exists = (table_name, column_name, **) 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:
379 380 381 382 383 384 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 379 def add_sql_comment!(sql, comment) # :nodoc: return sql unless supports_comments? sql << " COMMENT #{quote(comment)}" if comment.present? sql end |
#begin_db_transaction ⇒ Object
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:
516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 516 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:
482 483 484 485 486 487 488 489 490 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 482 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:
359 360 361 362 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 359 def change_column(table_name, column_name, type, = {}) # :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:
354 355 356 357 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 354 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:
341 342 343 344 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 341 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:
346 347 348 349 350 351 352 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 346 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:
290 291 292 293 294 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 290 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 |
#charset ⇒ Object
Returns the database character set.
264 265 266 267 268 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 264 def charset # check character set: # See: https://www.cubrid.com/qna/3802763 @charset ||= query_value("select charset('ABC')", 'SCHEMA') end |
#check_version ⇒ Object
:nodoc:
530 531 532 533 534 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 530 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 |
#collation ⇒ Object
Returns the database collation strategy.
271 272 273 274 275 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 271 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:
497 498 499 500 501 502 503 504 505 506 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 497 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_transaction ⇒ Object
: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: not supported now
250 251 252 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 250 def create_database(_name, = {}) raise 'In Cubrid create/drop database not supported' end |
#current_database ⇒ Object
259 260 261 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 259 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
512 513 514 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 512 def default_index_type?(index) # :nodoc: index.using == :btree || super end |
#default_uniqueness_comparison(attribute, value, klass) ⇒ Object
:nodoc:
467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 467 def default_uniqueness_comparison(attribute, value, klass) # :nodoc: column = column_for_attribute(attribute) if column.collation && !column.case_sensitive? && !value.nil? ActiveSupport::Deprecation.warn(" Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.\n To continue case sensitive comparison on the :\#{attribute.name} attribute in \#{klass} model,\n pass `case_sensitive: true` option explicitly to the uniqueness validator.\n MSG\n attribute.eq(Arel::Nodes::Bin.new(value))\n else\n super\n end\nend\n".squish) |
#drop_database(_name) ⇒ Object
Drops a Cubrid database: not supported now
255 256 257 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 255 def drop_database(_name) # :nodoc: raise 'In Cubrid create/drop database not supported' end |
#drop_table(table_name, options = {}) ⇒ Object
Drops a table from the database.
:force-
Set to
:cascadeto drop dependent objects as well. Defaults to false. :if_exists-
Set to
trueto only drop the table if it exists. Defaults to false. :temporary-
Set to
trueto 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.
320 321 322 323 324 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 320 def drop_table(table_name, = {}) if_exists = ([:if_exists] ? 'IF EXISTS' : '') cascade = ([: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.
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_booleans ⇒ Object
: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.
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_transaction ⇒ Object
: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.
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
386 387 388 389 390 391 392 393 394 395 396 397 398 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 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 386 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]) = { name: name, column: column, primary_key: primary_key } [:on_update] = extract_foreign_key_action(_strip_left_str(detail_match[3])) [:on_delete] = extract_foreign_key_action(_strip_left_str(detail_match[4])) fkeys << ForeignKeyDefinition.new(table_name, to_table, ) 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_version ⇒ Object
: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_algorithms ⇒ Object
146 147 148 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 146 def index_algorithms {} end |
#native_database_types ⇒ Object
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:
457 458 459 460 461 462 463 464 465 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 457 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
Drops the database: not supported now
245 246 247 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 245 def recreate_database(_name, = {}) raise 'In Cubrid create/drop database not supported' 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:
364 365 366 367 368 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 364 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
326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 326 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')
300 301 302 303 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 300 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’
453 454 455 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 453 def show_variable(_name) raise 'Not supported' end |
#supports_advisory_locks? ⇒ 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
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
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
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
82 83 84 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 82 def supports_explain? true end |
#supports_expression_index? ⇒ 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
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
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
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
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
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
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
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
78 79 80 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 78 def supports_transaction_isolation? true end |
#supports_views? ⇒ 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
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:
277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 277 def table_comment(table_name) # :nodoc: raise 'table comment not supported' unless supports_comments? query_value(" SELECT comment\n FROM db_class\n WHERE owner_name = 'PUBLIC'\n AND class_type = 'CLASS'\n AND is_system_class = 'NO'\n AND class_name = \#{quote(table_name)}\n SQL\nend\n", 'SCHEMA').presence |
#table_options(table_name) ⇒ Object
:nodoc:
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb', line 435 def (table_name) # :nodoc: = {} 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. = tableinfo.sub(/\A.*\n\) ?/m, '').sub(%r{\n/\*!.*\*/\n\z}m, '').strip [:options] = unless .blank? # strip COMMENT [:comment] = table_comment(table_name) if .sub!(/ COMMENT='.+'/, '') end |