mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
30 lines
871 B
Ruby
30 lines
871 B
Ruby
require 'arel/visitors/to_sql'
|
|
require 'arel/visitors/postgresql'
|
|
require 'arel/visitors/mysql'
|
|
require 'arel/visitors/oracle'
|
|
require 'arel/visitors/join_sql'
|
|
require 'arel/visitors/where_sql'
|
|
require 'arel/visitors/order_clauses'
|
|
require 'arel/visitors/dot'
|
|
|
|
module Arel
|
|
module Visitors
|
|
VISITORS = {
|
|
'postgresql' => Arel::Visitors::PostgreSQL,
|
|
'mysql' => Arel::Visitors::MySQL,
|
|
'mysql2' => Arel::Visitors::MySQL,
|
|
'oracle_enhanced' => Arel::Visitors::Oracle,
|
|
}
|
|
|
|
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
|