Coder Social home page Coder Social logo

kazumasayasui / rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rails/rails

0.0 0.0 0.0 182.85 MB

Ruby on Rails

Home Page: https://rubyonrails.org

License: MIT License

Shell 0.03% JavaScript 3.98% Ruby 95.03% CSS 0.35% HTML 0.58% Yacc 0.01% Dockerfile 0.02%

rails's People

Contributors

amatsuda avatar byroot avatar carlosantoniodasilva avatar dhh avatar drogus avatar eileencodes avatar fxn avatar georgeclaghorn avatar guilleiguaran avatar jeremy avatar jonathanhefner avatar jonleighton avatar josevalim avatar josh avatar kamipo avatar kaspth avatar lifo avatar matthewd avatar miloops avatar nzkoz avatar pixeltrix avatar rafaelfranca avatar senny avatar sgrif avatar spastorino avatar tenderlove avatar vijaydev avatar vipulnsward avatar y-yagi avatar zzak avatar

rails's Issues

It returns a different value than I want it to return, is that correct?

Steps to reproduce

# 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 :foo_bar_baz_foo_bar_baz_foo_bar_baz_foo_bar_baz, force: true do |t|
    t.bigint :tenant_id, null: false
    t.bigint :evaluation_template_sheet_item_id, null: false
    t.bigint :evaluation_template_role_scene_restriction_id, null: false
    t.timestamps
  end
end

module Foo
  module Bar
    class Baz < ActiveRecord::Base
      self.table_name = 'foo_bar_baz_foo_bar_baz_foo_bar_baz_foo_bar_baz'
    end
  end
end

class BugTest < Minitest::Test
  # バグの内容
  def test_should_group_by_multiple_fields_on_short_name_table
    2.times do
      Foo::Bar::Baz.create!(
        tenant_id: 1,
        evaluation_template_role_scene_restriction_id: 1,
        evaluation_template_sheet_item_id: 2
      )
    end

    res = Foo::Bar::Baz.group(:evaluation_template_role_scene_restriction_id, :evaluation_template_sheet_item_id).having("count(*) >= 2").count

    # ここが期待通り動かない
    assert_equal({ [1, 2] => 2 }, res)
  end
end

Expected behavior

{[1, 2]=>2}

Finished in 0.004607s, 217.0625 runs/s, 217.0625 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

Actual behavior

{[2, 2]=>2}

  1) Failure:
BugTest#test_should_group_by_multiple_fields_on_short_name_table [./active_record_gem.rb:79]:
Expected: {[1, 2]=>2}
  Actual: {[2, 2]=>2}

1 runs, 1 assertions, 1 failures, 0 errors, 0 skips

System configuration

Rails version: 7.0.0

Ruby version: ruby 3.0.2p107

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.