Skip to content

Can't apply filter by date ranges #937

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

Closed
wpolicarpo opened this issue Aug 11, 2021 · 0 comments · Fixed by #938
Closed

Can't apply filter by date ranges #937

wpolicarpo opened this issue Aug 11, 2021 · 0 comments · Fixed by #938

Comments

@wpolicarpo
Copy link
Member

Issue

There's a bug where tables with date columns can't be filtered by a date range because an exception is raised.

Expected behavior

No errors should be raised and filter applied correctly.

Actual behavior

An error is raised: ArgumentError: wrong number of arguments (given 1, expected 0).

How to reproduce

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org/"
  gem "tiny_tds"
  gem "activerecord", "6.1.4"
  gem "activerecord-sqlserver-adapter", "6.1.0.0"
end

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

ActiveRecord::Base.establish_connection(
  adapter:  "sqlserver",
  timeout:  5000,
  pool:     100,
  encoding: "utf8",
  database: "mydatabase",
  username: "myusername",
  password: "mypassword",
  host:     "myhost",
  port:     1433,
)
ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
  drop_table :bugs rescue nil

  create_table :bugs, force: true do |t|
    t.date :report_date
  end
end

Bug = Class.new(ActiveRecord::Base)

class BugTest < Minitest::Test
  def test_date_range
    date_1 = Date.new(2021, 8, 7)
    date_2 = Date.new(2021, 8, 7)

    Bug.create!(report_date: date_2)

    assert_equal 1, Bug.where(report_date: date_2..Date::Infinity.new).count
  end
end

Details

  • Rails version: 6.1.4
  • SQL Server adapter version: 6.1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant