Class: ActiveRecord::ConnectionAdapters::MemsqlAdapter

Inherits:
AbstractMysqlAdapter
  • Object
show all
Includes:
MySQL::DatabaseStatements
Defined in:
lib/active_record/connection_adapters/memsql_adapter.rb

Constant Summary collapse

ADAPTER_NAME =
"MemSQL".freeze

Instance Method Summary collapse

Constructor Details

#initialize(connection, logger, connection_options, config) ⇒ MemsqlAdapter

Returns a new instance of MemsqlAdapter.



42
43
44
45
46
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 42

def initialize(connection, logger, connection_options, config)
  super
  @prepared_statements = false unless config.key?(:prepared_statements)
  configure_connection
end

Instance Method Details

#active?Boolean

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

Returns:

  • (Boolean)


96
97
98
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 96

def active?
  @connection.ping
end

#disconnect!Object

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



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

def disconnect!
  super
  @connection.close
end

#each_hash(result) ⇒ Object

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



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

def each_hash(result) # :nodoc:
  if block_given?
    result.each(as: :hash, symbolize_keys: true) do |row|
      yield row
    end
  else
    to_enum(:each_hash, result)
  end
end

#error_number(exception) ⇒ Object



80
81
82
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 80

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

#quote_string(string) ⇒ Object

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



88
89
90
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 88

def quote_string(string)
  @connection.escape(string)
end

#reconnect!Object Also known as: reset!



100
101
102
103
104
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 100

def reconnect!
  super
  disconnect!
  connect
end

#supports_advisory_locks?Boolean

Returns:

  • (Boolean)


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

def supports_advisory_locks?
  false
end

#supports_comments?Boolean

Returns:

  • (Boolean)


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

def supports_comments?
  true
end

#supports_comments_in_create?Boolean

Returns:

  • (Boolean)


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

def supports_comments_in_create?
  true
end

#supports_json?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/active_record/connection_adapters/memsql_adapter.rb', line 48

def supports_json?
  !mariadb? && version >= "5.7.8"
end

#supports_savepoints?Boolean

Returns:

  • (Boolean)


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

def supports_savepoints?
  true
end