diff options
-rw-r--r-- | Manifest.txt | 1 | ||||
-rw-r--r-- | lib/arel/visitors/postgresql.rb | 4 | ||||
-rw-r--r-- | spec/visitors/postgres_spec.rb | 17 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Manifest.txt b/Manifest.txt index a14b9aad2b..0c74e6932e 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -102,4 +102,5 @@ spec/table_spec.rb spec/update_manager_spec.rb spec/visitors/join_sql_spec.rb spec/visitors/oracle_spec.rb +spec/visitors/postgres_spec.rb spec/visitors/to_sql_spec.rb diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 5e03f40984..553ee91bf9 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -2,6 +2,10 @@ module Arel module Visitors class PostgreSQL < Arel::Visitors::ToSql private + def visit_Arel_Nodes_Lock o + "FOR UPDATE" + end + def visit_Arel_Nodes_SelectStatement o if !o.orders.empty? && using_distinct_on?(o) subquery = o.dup diff --git a/spec/visitors/postgres_spec.rb b/spec/visitors/postgres_spec.rb new file mode 100644 index 0000000000..b5174a4c04 --- /dev/null +++ b/spec/visitors/postgres_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +module Arel + module Visitors + describe 'the postgres visitor' do + before do + @visitor = PostgreSQL.new Table.engine + end + + it 'should produce a lock value' do + @visitor.accept(Nodes::Lock.new).should be_like %{ + FOR UPDATE + } + end + end + end +end |