Class: WraithDB::Adapters::Mysql2Adapter

Inherits:
ActiveRecord::ConnectionAdapters::Mysql2Adapter
  • Object
show all
Includes:
WraithFunctionality
Defined in:
lib/wraithdb/adapters/mysql2_adapter.rb

Instance Attribute Summary

Attributes included from WraithFunctionality

#tables

Instance Method Summary collapse

Methods included from WraithFunctionality

#add_index, #create_table, #initialize, #support_migrations?

Instance Method Details

#adapter_nameObject



34
35
36
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 34

def adapter_name
  'WraithMysql2'
end

#connectObject



25
26
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 25

def connect
end

#quote(value, column = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 8

def quote(value, column = nil)
  if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary)
    s = column.class.string_to_binary(value).unpack("H*")[0]
    "x'#{s}'"
  elsif value.kind_of?(BigDecimal)
    value.to_s("F")
  else
    super
  end
end

#quote_string(s) ⇒ Object

Quotes a string, escaping any ‘ (single quote) and \ (backslash) characters.



21
22
23
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 21

def quote_string(s)
  s.gsub(/\\/, '\&\&').gsub(/'/, "\\\\'") # ' (for ruby-mode)
end

#reconnectObject



28
29
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 28

def reconnect
end

#reconnect!Object



31
32
# File 'lib/wraithdb/adapters/mysql2_adapter.rb', line 31

def reconnect!
end