Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JoinHelper is never reused, so there is no need to separate

  • Loading branch information...
commit 0fddc3c1c07e83249e4b6ff1ed5f6b7f74e41c1f 1 parent bfc34fc
Aaron Patterson tenderlove authored
1  activerecord/lib/active_record/associations.rb
View
@@ -130,7 +130,6 @@ module Builder #:nodoc:
autoload :JoinDependency, 'active_record/associations/join_dependency'
autoload :AssociationScope, 'active_record/associations/association_scope'
autoload :AliasTracker, 'active_record/associations/alias_tracker'
- autoload :JoinHelper, 'active_record/associations/join_helper'
end
# Clears out the association cache.
30 activerecord/lib/active_record/associations/association_scope.rb
View
@@ -1,10 +1,6 @@
-require 'active_record/associations/join_helper'
-
module ActiveRecord
module Associations
class AssociationScope #:nodoc:
- include JoinHelper
-
attr_reader :association, :alias_tracker
delegate :klass, :owner, :reflection, :interpolate, :to => :association
@@ -21,8 +17,32 @@ def scope
add_constraints(scope)
end
+ def join_type
+ Arel::Nodes::InnerJoin
+ end
+
private
+ def construct_tables
+ chain.map do |reflection|
+ alias_tracker.aliased_table_for(
+ table_name_for(reflection),
+ table_alias_for(reflection, reflection != self.reflection)
+ )
+ end
+ end
+
+
+ def table_alias_for(reflection, join = false)
+ name = "#{reflection.plural_name}_#{alias_suffix}"
+ name << "_join" if join
+ name
+ end
+
+ def join(table, constraint)
+ table.create_join(table, table.create_on(constraint), join_type)
+ end
+
def column_for(table_name, column_name)
columns = alias_tracker.connection.schema_cache.columns_hash(table_name)
columns[column_name]
@@ -115,7 +135,7 @@ def table_name_for(reflection)
# the owner
klass.table_name
else
- super
+ reflection.table_name
end
end
36 activerecord/lib/active_record/associations/join_helper.rb
View
@@ -1,36 +0,0 @@
-module ActiveRecord
- module Associations
- # Helper class module which gets mixed into JoinDependency::JoinAssociation and AssociationScope
- module JoinHelper #:nodoc:
-
- def join_type
- Arel::Nodes::InnerJoin
- end
-
- private
-
- def construct_tables
- chain.map do |reflection|
- alias_tracker.aliased_table_for(
- table_name_for(reflection),
- table_alias_for(reflection, reflection != self.reflection)
- )
- end
- end
-
- def table_name_for(reflection)
- reflection.table_name
- end
-
- def table_alias_for(reflection, join = false)
- name = "#{reflection.plural_name}_#{alias_suffix}"
- name << "_join" if join
- name
- end
-
- def join(table, constraint)
- table.create_join(table, table.create_on(constraint), join_type)
- end
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.