Class: Dolphin::DataStore::Mysql

Inherits:
BaseRdb
  • Object
show all
Defined in:
lib/dolphin/data_stores/mysql.rb

Constant Summary

Constants inherited from BaseRdb

BaseRdb::ORM

Instance Method Summary collapse

Methods inherited from BaseRdb

#closed?, #connect_path, #current_database, #delete_notification, #get_event, #get_notification, #initialize, #put_event, #put_notification

Constructor Details

This class inherits a constructor from Dolphin::DataStore::BaseRdb

Instance Method Details

#connectObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dolphin/data_stores/mysql.rb', line 8

def connect
  @connection = current_database
  case @connection.adapter_scheme
  when :mysql, :mysql2
    Sequel::MySQL.default_charset = 'utf8'
    Sequel::MySQL.default_collate = 'utf8_general_ci'
    Sequel::MySQL.default_engine = ENV['MYSQL_DB_ENGINE'] || 'InnoDB'

    # this is the mysql adapter specific constants. won't work with mysql2.
    if @connection.adapter_scheme == :mysql
      # Disable TEXT to Sequel::SQL::Blob translation.
      # see the thread: MySQL text turning into blobs
      # http://groups.google.com/group/sequel-talk/browse_thread/thread/d0f4c85abe9b3227/9ceaf291f90111e6
      # lib/sequel/adapters/mysql.rb
      [249, 250, 251, 252].each { |v|
        Sequel::MySQL::MYSQL_TYPES.delete(v)
      }
    end
  end
  @connection
end