Last active
August 29, 2015 14:11
-
-
Save benissimo/aabf0bc99a178b1cf47d to your computer and use it in GitHub Desktop.
test case for issue 606 of activerecord-jdbc-adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
# tested using jruby 1.7.6, activerecord 3.2.21, db2 10.5, and activerecord-jdbc-adapter (1.2.9 vs 1.3.13) | |
# and rspec 2.13.0 | |
describe "add_limit_offset!" do | |
before do | |
CreateTablesForAddLimitOffsetTestMigration.migrate :up | |
end | |
after do | |
CreateTablesForAddLimitOffsetTestMigration.migrate :down | |
end | |
class Name < ActiveRecord::Base; end | |
let(:arel_with_pagination) { Name.joins("JOIN persons p on p.id = names.person_id").limit(2).offset(3) } | |
it "should handle pagination with ordering" do | |
# passes on 1.2.9 and 1.3.13 | |
expect { arel_with_pagination.all }.to_not raise_error(ActiveRecord::StatementInvalid) | |
end | |
it "should handle pagination with ordering even when order column is not returned" do | |
# passes on 1.2.9, fails on 1.3.13 unless build_order() is overwritten to force an empty string | |
expect { arel_with_pagination.order("p.tax_code").all }.to_not raise_error(ActiveRecord::StatementInvalid) | |
end | |
class CreateTablesForAddLimitOffsetTestMigration < ActiveRecord::Migration | |
def up | |
create_table "names" do |t| | |
t.string :name | |
t.integer :person_id | |
end | |
create_table "persons" do |t| | |
t.string :tax_code | |
end | |
end | |
def down | |
%w{names persons}.each do |t| | |
drop_table t | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Workaround is: jruby/activerecord-jdbc-adapter@b330635
(see comments section)