ikuto0608 / rails Goto Github PK
View Code? Open in Web Editor NEWThis project forked from rails/rails
Ruby on Rails
Home Page: https://rubyonrails.org
License: MIT License
This project forked from rails/rails
Ruby on Rails
Home Page: https://rubyonrails.org
License: MIT License
Is this intentional?
# 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 :evaluation_template_role_scene_item_restrictions, force: true do |t|
t.bigint :evaluation_template_sheet_item_id, null: false
t.bigint :evaluation_template_role_scene_restriction_id, null: false
t.timestamps
end
end
module EvaluationTemplate
module Role
class SceneItemRestriction < ActiveRecord::Base
self.table_name = 'evaluation_template_role_scene_item_restrictions'
end
end
end
class BugTest < Minitest::Test
def test_association_stuff
2.times do
EvaluationTemplate::Role::SceneItemRestriction.create!(
evaluation_template_role_scene_restriction_id: 1,
evaluation_template_sheet_item_id: 2
)
end
res = EvaluationTemplate::Role::SceneItemRestriction.group(:evaluation_template_role_scene_restriction_id, :evaluation_template_sheet_item_id).having("count(*) >= 2").count
# ここが期待通り動かない
assert_equal({ [1, 2] => 2 }, res)
end
end
It should return expected count grouping by 2 columns.
{[1, 2]=>2}
{[2, 2]=>2}
Rails version: gem "activerecord", "~> 7.0.0"
Ruby version: ruby 3.0.2p107
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.