Class: ActiveRecord::ConnectionAdapters::Cubrid2Adapter

Inherits:
AbstractCubrid2Adapter show all
Includes:
ActiveRecord::ConnectionAdapters::Cubrid2::DatabaseStatements
Defined in:
lib/active_record/connection_adapters/cubrid2_adapter.rb

Constant Summary collapse

ADAPTER_NAME =
'Cubrid2'

Constants inherited from AbstractCubrid2Adapter

AbstractCubrid2Adapter::NATIVE_DATABASE_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveRecord::ConnectionAdapters::Cubrid2::DatabaseStatements

#exec_delete, #exec_query, #execute, #query, #query_value, #query_values, #select_all, #write_query?

Methods inherited from AbstractCubrid2Adapter

#_strip_key_str, #_strip_left_str, #add_index, #add_sql_comment!, #begin_db_transaction, #begin_isolated_db_transaction, #build_insert_sql, #case_sensitive_comparison, #change_column, #change_column_comment, #change_column_default, #change_column_null, #change_table_comment, #charset, #check_version, #collation, #columns_for_distinct, #commit_db_transaction, #create_database, #current_database, #default_index_type?, #default_uniqueness_comparison, #drop_database, #drop_table, #empty_insert_statement_value, #emulate_booleans, #exec_rollback_db_transaction, #execute, #execute_and_free, #explain, #foreign_keys, #get_advisory_lock, #get_database_version, #index_algorithms, #native_database_types, #primary_keys, #recreate_database, #release_advisory_lock, #rename_column, #rename_index, #rename_table, #show_variable, #supports_advisory_locks?, #supports_bulk_alter?, #supports_common_table_expressions?, #supports_datetime_with_precision?, #supports_explain?, #supports_expression_index?, #supports_foreign_keys?, #supports_index_sort_order?, #supports_indexes_in_create?, #supports_insert_on_duplicate_skip?, #supports_insert_on_duplicate_update?, #supports_optimizer_hints?, #supports_rename_column?, #supports_transaction_isolation?, #supports_views?, #supports_virtual_columns?, #table_comment, #table_options

Methods included from ActiveRecord::ConnectionAdapters::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 ActiveRecord::ConnectionAdapters::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) ⇒ Cubrid2Adapter

Returns a new instance of Cubrid2Adapter.



31
32
33
34
35
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 31

def initialize(connection, logger, connection_options, config)
  superclass_config = config.reverse_merge(prepared_statements: false)
  super(connection, logger, connection_options, superclass_config)
  configure_connection
end

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 41

def self.database_exists?(config)
  !!ActiveRecord::Base.cubrid_connection(config)
rescue ActiveRecord::NoDatabaseError
  false
end

Instance Method Details

#active?Boolean

– CONNECTION MANAGEMENT ==================================== ++

Returns:

  • (Boolean)


100
101
102
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 100

def active?
  @connection.ping
end

#adapter_nameObject



37
38
39
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 37

def adapter_name
  ADAPTER_NAME
end

#auto_commitObject

오류??



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

def auto_commit
  @connection.auto_commit
end

#auto_commit=(flag) ⇒ Object



141
142
143
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 141

def auto_commit=(flag)
  @connection.auto_commit = flag
end

#cubrid_connectionObject



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

def cubrid_connection
  @connection
end

#discard!Object

:nodoc:



118
119
120
121
122
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 118

def discard! # :nodoc:
  super
  # @connection.automatic_close = false
  @connection = nil
end

#disconnect!Object

Disconnects from the database if already connected. Otherwise, this method does nothing.



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

def disconnect!
  super
  @connection.close
end

#each_hash(result) ⇒ Object

HELPER METHODS ===========================================



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 69

def each_hash(result) # :nodoc:
  stmt = result.is_a?(Array) ? result.first : result
  if block_given?
    if result && stmt
      while (row = stmt.fetch_hash)
        yield row.symbolize_keys
      end
    end
  else
    to_enum(:each_hash, stmt)
  end
end

#error_number(exception) ⇒ Object



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

def error_number(exception)
  exception.error_number if exception.respond_to?(:error_number)
end

#pingObject



128
129
130
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 128

def ping
  @connection.ping
end

#quote_string(string) ⇒ Object

– QUOTING ================================================== ++



90
91
92
93
94
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 90

def quote_string(string)
  # escaping with backslash is only allowed when 'no_backslash_escapes' == 'yes' in cubrid config, default is yes.
  # See: https://www.cubrid.org/manual/ko/11.2/sql/literal.html#id5
  "#{string.gsub("'", "''")}"
end

#reconnect!Object Also known as: reset!



104
105
106
107
108
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 104

def reconnect!
  super
  disconnect!
  connect
end

#server_versionObject



124
125
126
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 124

def server_version
  @connection.server_version
end

#supports_comments?Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 51

def supports_comments?
  # https://www.cubrid.org/manual/en/10.0/release_note/r10_0.html#overview
  database_version >= '10.0'
end

#supports_comments_in_create?Boolean

Returns:

  • (Boolean)


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

def supports_comments_in_create?
  supports_comments?
end

#supports_json?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 47

def supports_json?
  database_version >= '10.2'
end

#supports_lazy_transactions?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 64

def supports_lazy_transactions?
  false
end

#supports_savepoints?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/active_record/connection_adapters/cubrid2_adapter.rb', line 60

def supports_savepoints?
  true
end