From 92c265b3ad89303e53e64f7ead4499066966c722 Mon Sep 17 00:00:00 2001 From: James Pearson Date: Mon, 29 Jul 2019 12:04:07 +0100 Subject: Enabled matches_regex for MySql Previously matches_regex was only availble on PostgreSql, this will enable it for MySql Usage example: users = User.arel_table; users = User.arel_table; User.where(users[:email].matches_regexp('(.*)\@gmail.com')) Update activerecord/test/cases/arel/visitors/mysql_test.rb Co-Authored-By: Ryuta Kamizono --- activerecord/lib/arel/visitors/mysql.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/arel/visitors/mysql.rb b/activerecord/lib/arel/visitors/mysql.rb index dd77cfdf66..6cb866715f 100644 --- a/activerecord/lib/arel/visitors/mysql.rb +++ b/activerecord/lib/arel/visitors/mysql.rb @@ -48,6 +48,14 @@ module Arel # :nodoc: all visit_Arel_Nodes_IsNotDistinctFrom o, collector end + def visit_Arel_Nodes_Regexp(o, collector) + infix_value o, collector, " REGEXP " + end + + def visit_Arel_Nodes_NotRegexp(o, collector) + infix_value o, collector, " NOT REGEXP " + end + # In the simple case, MySQL allows us to place JOINs directly into the UPDATE # query. However, this does not allow for LIMIT, OFFSET and ORDER. To support # these, we must use a subquery. -- cgit v1.2.3