2010-10-19 14:42:02 -04:00
|
|
|
require 'arel/visitors/visitor'
|
2010-11-29 17:11:28 -05:00
|
|
|
require 'arel/visitors/depth_first'
|
2010-09-23 18:26:08 -04:00
|
|
|
require 'arel/visitors/to_sql'
|
2010-10-20 20:16:18 -04:00
|
|
|
require 'arel/visitors/sqlite'
|
2010-09-23 18:26:08 -04:00
|
|
|
require 'arel/visitors/postgresql'
|
|
|
|
require 'arel/visitors/mysql'
|
2010-12-27 11:16:18 -05:00
|
|
|
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,
|
2010-12-27 11:16:18 -05:00
|
|
|
'mssql' => Arel::Visitors::MSSQL,
|
|
|
|
'sqlserver' => Arel::Visitors::MSSQL,
|
2010-09-24 12:41:48 -04:00
|
|
|
'oracle_enhanced' => Arel::Visitors::Oracle,
|
2010-10-20 20:16:18 -04:00
|
|
|
'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
|