https://github.com/github0013/activerecord-includes
https://github.com/github0013/activerecord-includes
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/github0013/activerecord-includes
- Owner: github0013
- Created: 2021-02-09T06:36:07.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-12-11T18:15:13.000Z (over 4 years ago)
- Last Synced: 2025-01-23T05:15:52.592Z (over 1 year ago)
- Language: Ruby
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Issue with ActiveRecord#includes
Checked with the latest rails versions
- 5.2.4.4
- 6.1.1
## Models

## The Problem
- `c_type_xs` is a scoped has_many in A, through Bs (source Cs)
- `ds` is a distinct has_many in A, through Cs
Under this condition, if you switch around the orders in includes, you get different results.
### spec/models/a_spec.rb
```rb
it { expect(A.includes(:c_type_xs, :ds).find(subject.id).c_type_xs.size).to eq 1 }
it("if you switch includes around, you get different results") do
expect(A.includes(:ds, :c_type_xs).find(subject.id).c_type_xs.size).to eq 1
end
```
## How to reproduce
Just run the docker, and it will run rspec automatically.
```
$ git clone && cd activerecord-includes
$ docker-compose run --rm rails-5.2.x
$ docker-compose run --rm rails-6.1.x
```