blob: 4a8d254ba77e2cc40f3a43358d5166dc4cb9b144 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require 'arel/visitors/visitor'
require 'arel/visitors/depth_first'
require 'arel/visitors/to_sql'
require 'arel/visitors/sqlite'
require 'arel/visitors/postgresql'
require 'arel/visitors/mysql'
require 'arel/visitors/mssql'
require 'arel/visitors/oracle'
require 'arel/visitors/where_sql'
require 'arel/visitors/dot'
require 'arel/visitors/ibm_db'
require 'arel/visitors/informix'
module Arel
module Visitors
VISITORS = {
'postgresql' => Arel::Visitors::PostgreSQL,
'mysql' => Arel::Visitors::MySQL,
'mysql2' => Arel::Visitors::MySQL,
'mssql' => Arel::Visitors::MSSQL,
'sqlserver' => Arel::Visitors::MSSQL,
'oracle_enhanced' => Arel::Visitors::Oracle,
'sqlite' => Arel::Visitors::SQLite,
'sqlite3' => Arel::Visitors::SQLite,
'ibm_db' => Arel::Visitors::IBM_DB,
'informix' => Arel::Visitors::Informix,
}
ENGINE_VISITORS = Hash.new do |hash, engine|
pool = engine.connection_pool
adapter = pool.spec.config[:adapter]
hash[engine] = (VISITORS[adapter] || Visitors::ToSql).new(engine)
end
def self.visitor_for engine
ENGINE_VISITORS[engine]
end
class << self; alias :for :visitor_for; end
end
end
|