blob: 6160f244f7c3acbd762fe1957ba4c904112c36f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Arel
module Sql
class Christener
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.name
@used_names[name] += 1
hash[relation] = name + (@used_names[name] > 1 ? "_#{@used_names[name]}" : '')
end
end
def name_for(relation)
@relation_names[relation.table]
end
end
end
end
|