From d0f75a03af584710db4094e5561a7f085ff3faa2 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 26 Nov 2014 19:56:58 +0100 Subject: [PATCH] Allow RLIKE in conditions. --- lib/Cake/Model/Datasource/DboSource.php | 2 +- lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 286572cb4..2b2fc30bd 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -181,7 +181,7 @@ class DboSource extends DataSource { * * @var array */ - protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); + protected $_sqlOps = array('like', 'ilike', 'rlike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); /** * Indicates the level of nested transactions diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index e0e30cef5..0a6493cb6 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -2384,6 +2384,10 @@ SQL; $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))"; $this->assertEquals($expected, $result); + $result = $this->Dbo->conditions(array('User.user RLIKE' => 'mariano|nate')); + $expected = " WHERE `User`.`user` RLIKE 'mariano|nate'"; + $this->assertEquals($expected, $result); + $result = $this->Dbo->conditions(array('or' => array( 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20' )));