aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/algebra/relations/operations/join.rb1
-rw-r--r--lib/arel/engines/sql/christener.rb13
-rw-r--r--lib/arel/engines/sql/formatters.rb5
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/arel/algebra/relations/operations/join.rb b/lib/arel/algebra/relations/operations/join.rb
index 83ebfc129f..72b4c9b8fe 100644
--- a/lib/arel/algebra/relations/operations/join.rb
+++ b/lib/arel/algebra/relations/operations/join.rb
@@ -8,6 +8,7 @@ module Arel
@relation1 = relation1
@relation2 = relation2
@predicates = predicates
+ @attributes = nil
end
def name
diff --git a/lib/arel/engines/sql/christener.rb b/lib/arel/engines/sql/christener.rb
index a2a2da799a..2c96020554 100644
--- a/lib/arel/engines/sql/christener.rb
+++ b/lib/arel/engines/sql/christener.rb
@@ -1,13 +1,18 @@
module Arel
module Sql
class Christener
- def name_for(relation)
- @used_names ||= Hash.new(0)
- (@relation_names ||= Hash.new do |hash, relation|
+ def initialize
+ # FIXME: this exists because all objects hash the same. :'(
+ @used_names = Hash.new(0)
+ @relation_names = Hash.new do |hash, relation|
name = relation.table_alias ? relation.table_alias : relation.name
@used_names[name] += 1
hash[relation] = name + (@used_names[name] > 1 ? "_#{@used_names[name]}" : '')
- end)[relation.table]
+ end
+ end
+
+ def name_for(relation)
+ @relation_names[relation.table]
end
end
end
diff --git a/lib/arel/engines/sql/formatters.rb b/lib/arel/engines/sql/formatters.rb
index cdbda5ea33..de8278479d 100644
--- a/lib/arel/engines/sql/formatters.rb
+++ b/lib/arel/engines/sql/formatters.rb
@@ -1,13 +1,14 @@
module Arel
module Sql
class Formatter
- attr_reader :environment
- delegate :christener, :engine, :to => :environment
+ attr_reader :environment, :christener
+ delegate :engine, :to => :environment
delegate :name_for, :to => :christener
delegate :quote_table_name, :quote_column_name, :quote, :to => :engine
def initialize(environment)
@environment = environment
+ @christener = environment.christener
end
end