1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

just use the regexp directly

This commit is contained in:
Aaron Patterson 2010-12-10 17:03:32 -08:00
parent de708447f4
commit 9094cd2600

View file

@ -58,18 +58,16 @@ module ActiveRecord
when Arel::Table
right.name.downcase == name ? 1 : 0
when String
count_aliases_from_string(right.downcase, quoted_name)
# Table names + table aliases
right.downcase.scan(
/join(?:\s+\w+)?\s+(\S+\s+)?#{quoted_name}\son/
).size
else
0
end
}.sum
end
def count_aliases_from_string(join_sql, name)
# Table names + table aliases
join_sql.scan(/join(?:\s+\w+)?\s+(\S+\s+)?#{name}\son/).size
end
def instantiate(rows)
primary_key = join_base.aliased_primary_key
parents = {}