Skip to content

Instantly share code, notes, and snippets.

@raghubetina
Last active November 17, 2020 04:49
Show Gist options
  • Save raghubetina/5ab87d77a8663f84bd1464cf8d91bd04 to your computer and use it in GitHub Desktop.
Save raghubetina/5ab87d77a8663f84bd1464cf8d91bd04 to your computer and use it in GitHub Desktop.
Executable test case for behavior of `where` with exclusive endless ranges
# 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", "6.0.3"
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 :things, force: true do |t|
t.integer :number
end
end
class Thing < ActiveRecord::Base
end
class EndlessRangeBugTest < Minitest::Test
def test_query_with_upper_unbounded_exclusive_range
Thing.create [{ number: 1 }, { number: 2 }]
assert_equal 1, Thing.where(number: 1...::Float::INFINITY).count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment