Skip to content
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

[WIP] Rails 7.1 support #168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
- '3.3'
rails-version:
- '7.0'
- '7.1'
services:
postgres:
image: postgres:13
Expand All @@ -39,6 +44,7 @@ jobs:
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: password
TEST_RAILS_VERSION: ${{ matrix.rails-version }}
# for the mysql cli (mysql, mysqladmin)
MYSQL_HOST: 127.0.0.1
MYSQL_PWD: password
Expand All @@ -64,7 +70,7 @@ jobs:
DB: mysql2
run: bundle exec rake
- name: Report code coverage
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' }}
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' && matrix.rails-version == '7.0' }}
continue-on-error: true
uses: paambaati/codeclimate-action@v9
env:
Expand Down
13 changes: 12 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

source "https://rubygems.org"

gem "activerecord", "~>7.0.8"
minimum_version =
case ENV['TEST_RAILS_VERSION']
when "7.2"
"~>7.2.1"
when "7.1"
"~>7.1.4"
else
"~>7.0.8"
end

gem "activerecord", minimum_version

gem "mysql2"
gem "pg"
gem "sqlite3", "< 2"
Expand Down
4 changes: 2 additions & 2 deletions lib/active_record/virtual_attributes/virtual_delegates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ def self.select_from_alias(to_ref, col, to_model_col_name, src_model_id)
def self.select_from_alias_table(to_klass, src_relation)
to_table = to_klass.arel_table
# if a self join, alias the second table to a different name
if to_table.table_name == src_relation.table_name
if to_table.name == src_relation.name
# use a dup to not modify the primary table in the model
to_table = to_table.dup
# use a table alias to not conflict with table name in the primary query
to_table.table_alias = "#{to_table.table_name}_sub"
to_table.instance_variable_set(:@table_alias, "#{to_table.name}_sub")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock do we need to set a table alias in this way? I didn't look to see if this was yours or Nick's comment. Clearly, they don't want to let us set it so I concerned this will change in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aah - now I remember

rails uses a manager to manage the names of the tables (so you can do a self join and it all works)

I had been meaning to change this for the next revision

If I remember correctly, this is tied to 3 test failures - the only real failures for rails.

They are real faiulres.
Pretty sure we don't want name here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this WIP... feel free to take this change in part or whole and change it while I'm away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm putting together a PR for tests that will verify this change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock do you have suggestions on getting this change in? I'm not a fan of this change so I'm open to something better.

end
to_table
end
Expand Down