Skip to content
New issue

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

unscope not working when where by tripe dot range #48094

Closed
ippachi opened this issue Apr 29, 2023 · 1 comment · Fixed by #48095
Closed

unscope not working when where by tripe dot range #48094

ippachi opened this issue Apr 29, 2023 · 1 comment · Fixed by #48095

Comments

@ippachi
Copy link
Contributor

ippachi commented Apr 29, 2023

Steps to reproduce

  1. where by triple dot range
  2. unscope 1.
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  # Activate the gem you are reporting the issue against.
  gem "activerecord", "~> 7.0.0"
  gem "sqlite3"
end

require "active_record"
require "minitest/autorun"
require "logger"

# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
  create_table :posts, force: true do |t|
  end
end

class Post < ActiveRecord::Base
end

class BugTest < Minitest::Test
  def test_association_stuff
    Post.create!(id: 1)
    Post.create!(id: 2)
    Post.create!(id: 3)

    assert_equal 3, Post.where(id: 1..2).unscope(where: :id).count # double dot is working
    assert_equal 3, Post.where(id: 1...2).unscope(where: :id).count # triple dot is not working
  end
end

Expected behavior

Post.where(id: 1...2).unscope(where: :id) returns 3

Actual behavior

Post.where(id: 1...2).unscope(where: :id) returns 1

System configuration

Rails version: 7.0.4.3

Ruby version: 3.2.2

@Onkar26
Copy link

Onkar26 commented May 8, 2023

`
class BugTest < Minitest::Test
def test_association_stuff
Post.create!(id: 1)
Post.create!(id: 2)
Post.create!(id: 3)

  assert_equal 3, Post.where(id: 1..3).unscope(where: :id).count # double dot will work now
  assert_equal 3, Post.where(id: 1...4).unscope(where: :id).count # triple dot will work now
end

end
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants