1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/visitors.rb

39 lines
1.2 KiB
Ruby
Raw Normal View History

2010-10-19 14:42:02 -04:00
require 'arel/visitors/visitor'
require 'arel/visitors/depth_first'
2010-09-23 18:26:08 -04:00
require 'arel/visitors/to_sql'
require 'arel/visitors/sqlite'
2010-09-23 18:26:08 -04:00
require 'arel/visitors/postgresql'
require 'arel/visitors/mysql'
require 'arel/visitors/mssql'
2010-09-24 12:41:48 -04:00
require 'arel/visitors/oracle'
2010-09-23 18:26:08 -04:00
require 'arel/visitors/join_sql'
2010-10-12 17:17:26 -04:00
require 'arel/visitors/where_sql'
2010-09-23 18:26:08 -04:00
require 'arel/visitors/order_clauses'
require 'arel/visitors/dot'
2010-09-23 18:45:00 -04:00
module Arel
module Visitors
VISITORS = {
2010-09-24 12:41:48 -04:00
'postgresql' => Arel::Visitors::PostgreSQL,
'mysql' => Arel::Visitors::MySQL,
'mysql2' => Arel::Visitors::MySQL,
'mssql' => Arel::Visitors::MSSQL,
'sqlserver' => Arel::Visitors::MSSQL,
2010-09-24 12:41:48 -04:00
'oracle_enhanced' => Arel::Visitors::Oracle,
'sqlite' => Arel::Visitors::SQLite,
'sqlite3' => Arel::Visitors::SQLite,
2010-09-23 18:45:00 -04:00
}
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
2010-10-03 17:26:57 -04:00
class << self; alias :for :visitor_for; end
2010-09-23 18:45:00 -04:00
end
end