We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ransack_alias
test_ransack.rb
require 'bundler/inline' gemfile(true) do source 'https://rubygems.org' gem 'activerecord', '~> 6.1', '>= 6.1.4', require: "active_record" gem 'sqlite3', '~> 1.4' gem 'ransack', '~> 2.4', '>= 2.4.2' gem 'minitest', '~> 5.14', '>= 5.14.2', require: "minitest/autorun" end ActiveRecord::Base.establish_connection( adapter: "sqlite3", database: "./test_ransack_alias" ) ActiveRecord::Schema.define do drop_table(:fees, if_exists: true) create_table :fees do |t| t.integer :amount end end class Fee < ActiveRecord::Base ransack_alias :amount_a, :amount end class MyTest < Minitest::Test # success def test_1 query_params = { amount_not_eq: 1 } assert_equal "SELECT \"fees\".* FROM \"fees\" WHERE \"fees\".\"amount\" != 1", Fee.ransack(query_params).result.to_sql end # success def test_2 query_params = { amount_not_eq: 1, amount_a_not_eq: 2 } assert_equal "SELECT \"fees\".* FROM \"fees\" WHERE (\"fees\".\"amount\" != 1 AND \"fees\".\"amount\" != 2)", Fee.ransack(query_params).result.to_sql end # failure def test_3 query_params = { amount_a_not_eq: 2, amount_not_eq: 1 } assert_equal "SELECT \"fees\".* FROM \"fees\" WHERE (\"fees\".\"amount\" != 2 AND \"fees\".\"amount\" != 1)", Fee.ransack(query_params).result.to_sql end end
deploy@local-vm:~$ ruby test_ransack.rb Fetching gem metadata from https://gems.ruby-china.com/........ Resolving dependencies... Using concurrent-ruby 1.1.9 Using i18n 1.8.10 Using minitest 5.14.4 Using tzinfo 2.0.4 Using zeitwerk 2.4.2 Using activesupport 6.1.4 Using activemodel 6.1.4 Using activerecord 6.1.4 Using bundler 2.2.19 Using ransack 2.4.2 Using sqlite3 1.4.2 -- drop_table(:fees, {:if_exists=>true}) -> 0.0094s -- create_table(:fees) -> 0.0052s Run options: --seed 9735 # Running: ..F Finished in 0.008001s, 374.9565 runs/s, 374.9565 assertions/s. 1) Failure: MyTest#test_3 [test_ransack.rb:45]: --- expected +++ actual @@ -1 +1 @@ -"SELECT \"fees\".* FROM \"fees\" WHERE (\"fees\".\"amount\" != 2 AND \"fees\".\"amount\" != 1)" +"SELECT \"fees\".* FROM \"fees\" WHERE \"fees\".\"amount\" != 1" 3 runs, 3 assertions, 1 failures, 0 errors, 0 skips
The text was updated successfully, but these errors were encountered:
Fix ransack_alias issue, close activerecord-hackery#1239
5cc98a5
gem 'ransack', github: 'itsalongstory/ransack', branch: 'issue_1239'
Fixed this.
Sorry, something went wrong.
a0af78f
Successfully merging a pull request may close this issue.
test_ransack.rb
The text was updated successfully, but these errors were encountered: