diff options
author | Jesse Storimer <jstorimer@gmail.com> | 2011-01-20 00:37:05 -0500 |
---|---|---|
committer | Jesse Storimer <jstorimer@gmail.com> | 2011-01-20 00:37:05 -0500 |
commit | 6c65b0176223c90e08903ebc1a9a1075659f2c43 (patch) | |
tree | 53923dbaf7ab3674459ae297919ebbd20b83404e /test | |
parent | dae7a245f8ec9f8eb5d9866938ea46ed7c88dcf1 (diff) | |
download | rails-6c65b0176223c90e08903ebc1a9a1075659f2c43.tar.gz rails-6c65b0176223c90e08903ebc1a9a1075659f2c43.tar.bz2 rails-6c65b0176223c90e08903ebc1a9a1075659f2c43.zip |
Allow database specific locking clauses to be used
Diffstat (limited to 'test')
-rw-r--r-- | test/visitors/test_mysql.rb | 15 | ||||
-rw-r--r-- | test/visitors/test_postgres.rb | 17 |
2 files changed, 23 insertions, 9 deletions
diff --git a/test/visitors/test_mysql.rb b/test/visitors/test_mysql.rb index c3b79ca667..c22cbaff19 100644 --- a/test/visitors/test_mysql.rb +++ b/test/visitors/test_mysql.rb @@ -29,11 +29,16 @@ module Arel sql.must_be_like "SELECT FROM DUAL" end - it 'uses FOR UPDATE when locking' do - stmt = Nodes::SelectStatement.new - stmt.lock = Nodes::Lock.new - sql = @visitor.accept(stmt) - sql.must_be_like "SELECT FROM DUAL FOR UPDATE" + describe 'locking' do + it 'defaults to FOR UPDATE when locking' do + node = Nodes::Lock.new + @visitor.accept(node).must_be_like "FOR UPDATE" + end + + it 'allows a custom string to be used as a lock' do + node = Nodes::Lock.new('LOCK IN SHARE MODE') + @visitor.accept(node).must_be_like "LOCK IN SHARE MODE" + end end end end diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb index 6e8f399b6b..ec55e555a6 100644 --- a/test/visitors/test_postgres.rb +++ b/test/visitors/test_postgres.rb @@ -7,10 +7,19 @@ module Arel @visitor = PostgreSQL.new Table.engine end - it 'should produce a lock value' do - @visitor.accept(Nodes::Lock.new).must_be_like %{ - FOR UPDATE - } + describe 'locking' do + it 'defaults to FOR UPDATE' do + @visitor.accept(Nodes::Lock.new).must_be_like %{ + FOR UPDATE + } + end + + it 'allows a custom string to be used as a lock' do + node = Nodes::Lock.new('FOR SHARE') + @visitor.accept(node).must_be_like %{ + FOR SHARE + } + end end it "should escape LIMIT" do |