diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-23 11:45:29 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-23 13:38:56 -0700 |
commit | aa4c957fa1a0f9ec26727800b80316c991b4a1d6 (patch) | |
tree | 25909936ffe6d703b1820beb2cb3de4366651fd9 /lib | |
parent | 4cc43be38c488e7ec2d83408b8cb2475e2a620e7 (diff) | |
download | rails-aa4c957fa1a0f9ec26727800b80316c991b4a1d6.tar.gz rails-aa4c957fa1a0f9ec26727800b80316c991b4a1d6.tar.bz2 rails-aa4c957fa1a0f9ec26727800b80316c991b4a1d6.zip |
adding a postgres adapter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel.rb | 12 | ||||
-rw-r--r-- | lib/arel/tree_manager.rb | 11 | ||||
-rw-r--r-- | lib/arel/update_manager.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/postgresql.rb | 6 |
4 files changed, 23 insertions, 8 deletions
diff --git a/lib/arel.rb b/lib/arel.rb index 7d870ec17e..85a866b0ce 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -12,6 +12,13 @@ require 'arel/relation' require 'arel/expression' #### +require 'arel/visitors/to_sql' +require 'arel/visitors/postgresql' +require 'arel/visitors/update_sql' +require 'arel/visitors/join_sql' +require 'arel/visitors/order_clauses' +require 'arel/visitors/dot' + require 'arel/tree_manager' require 'arel/insert_manager' require 'arel/select_manager' @@ -25,8 +32,3 @@ require 'arel/sql/engine' require 'arel/sql_literal' #### -require 'arel/visitors/to_sql' -require 'arel/visitors/update_sql' -require 'arel/visitors/join_sql' -require 'arel/visitors/order_clauses' -require 'arel/visitors/dot' diff --git a/lib/arel/tree_manager.rb b/lib/arel/tree_manager.rb index 24df5e0c09..11d34ec138 100644 --- a/lib/arel/tree_manager.rb +++ b/lib/arel/tree_manager.rb @@ -3,8 +3,15 @@ module Arel # FIXME: Remove this. include Arel::Relation + VISITORS = { + 'postgresql' => Arel::Visitors::PostgreSQL + } + def initialize engine - @engine = engine + @engine = engine + @pool = engine.connection_pool + @adapter = @pool.spec.config[:adapter] + @visitor_klass = VISITORS[@adapter] || Visitors::ToSql end def to_dot @@ -12,7 +19,7 @@ module Arel end def to_sql - viz = Visitors::ToSql.new @engine + viz = @visitor_klass.new @engine viz.accept @head end diff --git a/lib/arel/update_manager.rb b/lib/arel/update_manager.rb index 7b9b0fc295..0cb5554954 100644 --- a/lib/arel/update_manager.rb +++ b/lib/arel/update_manager.rb @@ -46,7 +46,7 @@ module Arel end def to_sql - viz = Visitors::ToSql.new @engine + viz = @visitor_klass.new @engine unless @engine.connection_pool.spec.config[:adapter] =~ /^mysql/ viz.extend(Visitors::UpdateSql) end diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb new file mode 100644 index 0000000000..93535f4488 --- /dev/null +++ b/lib/arel/visitors/postgresql.rb @@ -0,0 +1,6 @@ +module Arel + module Visitors + class PostgreSQL < Arel::Visitors::ToSql + end + end +end |