Permalink
Browse files

Regexp.union seems to have different results in 1.8

  • Loading branch information...
tenderlove committed Dec 8, 2011
1 parent 859a455 commit d80e4ee20e690dfc0f4ec31c41b873d607462872
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/test/cases/helper.rb
@@ -70,16 +70,16 @@ class SQLCounter
attr_reader :ignore
- def initialize(ignore = Regexp.union(self.class.ignored_sql))
- @ignore = ignore
+ def initialize(ignore = self.class.ignored_sql)
+ @ignore = ignore
end
def call(name, start, finish, message_id, values)
sql = values[:sql]
# FIXME: this seems bad. we should probably have a better way to indicate
# the query was cached
- return if 'CACHE' == values[:name] || ignore =~ sql
+ return if 'CACHE' == values[:name] || ignore.any? { |x| x =~ sql }
self.class.log << sql
end
end

4 comments on commit d80e4ee

@sobrinho

This comment has been minimized.

Show comment
Hide comment
@sobrinho

sobrinho Dec 9, 2011

Contributor

Are you sure?

This snippet produces exactly same result on ree-1.8.7-2011.03 and 1.9.3-p0

words = %w(foo bar baz)
puts Regexp.union(words)
# => (?-mix:foo|bar|baz)

regexps = [/foo/, /bar/, /baz/]
puts Regexp.union(regexps)
# => (?-mix:(?-mix:foo)|(?-mix:bar)|(?-mix:baz))
Contributor

sobrinho replied Dec 9, 2011

Are you sure?

This snippet produces exactly same result on ree-1.8.7-2011.03 and 1.9.3-p0

words = %w(foo bar baz)
puts Regexp.union(words)
# => (?-mix:foo|bar|baz)

regexps = [/foo/, /bar/, /baz/]
puts Regexp.union(regexps)
# => (?-mix:(?-mix:foo)|(?-mix:bar)|(?-mix:baz))
@tenderlove

This comment has been minimized.

Show comment
Hide comment
@tenderlove

tenderlove Dec 9, 2011

Member
Member

tenderlove replied Dec 9, 2011

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 6, 2012

Member

Can we revert it now on master? =)

Can we revert it now on master? =)

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 6, 2012

Member

Well, I've sent a pull request reverting this and another 1.8 compat change.

Well, I've sent a pull request reverting this and another 1.8 compat change.

Please sign in to comment.