Skip to content

Commit

Permalink
Explain how this is completely broken
Browse files Browse the repository at this point in the history
  • Loading branch information
rzane committed Aug 19, 2019
1 parent 095ae02 commit a6a9f43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ else
gem 'activerecord', ENV['AR']
end

git 'https://github.com/gregmolnar/ransack', branch: 'fix-polymorphic-joins' do
gem 'polyamorous'
end

gem 'bump'

group :test do
Expand Down
4 changes: 2 additions & 2 deletions baby_squeel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}')

spec.add_dependency 'activerecord', '>= 4.2.0'
spec.add_dependency 'polyamorous', '~> 2.1.1'
spec.add_dependency 'polyamorous', '~> 2.3.0'
spec.add_dependency 'join_dependency', '~> 0.1.4'

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'bundler', '~> 2'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.4.0'
spec.add_development_dependency 'sqlite3', '~> 1.3.6'
Expand Down
6 changes: 6 additions & 0 deletions lib/baby_squeel/join_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ def initialize(relation)
def find_alias(associations)
join_association = find_join_association(associations)

# NOTE: Below is a hack. It does not work. In previous
# versions of Active Record, `#table` would ALWAYS return
# an instance of Arel::Table.
if join_association.table
join_association.table
else
# This literally does not work. This will often
# give you the wrong Arel::Table instance, which
# causes aliases in the query to be wrong.
join_association.base_klass.arel_table
end
end
Expand Down

0 comments on commit a6a9f43

Please sign in to comment.