diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-29 10:05:54 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-29 10:05:54 -0700 |
commit | 9cd009b3728b07921cbfbfcf820748735c1de38c (patch) | |
tree | cabf9c424841a423a7290739e9369c611703692d /test/visitors | |
parent | b4d6e5debc4f8293eb15cffed56d8a4dbf74378c (diff) | |
parent | 490d6f98f8974c717ddca29df162f5f1ad48e094 (diff) | |
download | rails-9cd009b3728b07921cbfbfcf820748735c1de38c.tar.gz rails-9cd009b3728b07921cbfbfcf820748735c1de38c.tar.bz2 rails-9cd009b3728b07921cbfbfcf820748735c1de38c.zip |
Merge branch 'master' of github.com:rails/arel
* 'master' of github.com:rails/arel:
replace 'LIMIT n' with 'FETCH FIRST n ROWS ONLY' when using ibm_db
Generate more sqlish queue.
Diffstat (limited to 'test/visitors')
-rw-r--r-- | test/visitors/test_ibm_db.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/visitors/test_ibm_db.rb b/test/visitors/test_ibm_db.rb new file mode 100644 index 0000000000..cc35bb768d --- /dev/null +++ b/test/visitors/test_ibm_db.rb @@ -0,0 +1,27 @@ +require 'helper' + +module Arel + module Visitors + describe 'the ibm_db visitor' do + before do + @visitor = IBM_DB.new Table.engine + end + + it 'uses FETCH FIRST n ROWS to limit results' do + stmt = Nodes::SelectStatement.new + stmt.limit = Nodes::Limit.new(1) + sql = @visitor.accept(stmt) + sql.must_be_like "SELECT FETCH FIRST 1 ROWS ONLY" + end + + it 'uses FETCH FIRST n ROWS in updates with a limit' do + stmt = Nodes::UpdateStatement.new + stmt.limit = Nodes::Limit.new(1) + stmt.key = 'id' + sql = @visitor.accept(stmt) + sql.must_be_like "UPDATE NULL WHERE 'id' IN (SELECT 'id' FETCH FIRST 1 ROWS ONLY)" + end + + end + end +end |