#612392 by chx and Crell: Allow lowercase comparison operators in DBTNG.
parent
7536a35414
commit
c1ce884e4b
|
@ -1321,12 +1321,26 @@ class DatabaseCondition implements QueryConditionInterface, Countable {
|
||||||
'BETWEEN' => array('delimiter' => ' AND '),
|
'BETWEEN' => array('delimiter' => ' AND '),
|
||||||
'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
|
'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
|
||||||
'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
|
'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
|
||||||
'LIKE' => array('operator' => 'LIKE'),
|
|
||||||
'IS NULL' => array('use_value' => FALSE),
|
'IS NULL' => array('use_value' => FALSE),
|
||||||
'IS NOT NULL' => array('use_value' => FALSE),
|
'IS NOT NULL' => array('use_value' => FALSE),
|
||||||
|
// These ones are here for performance reasons.
|
||||||
|
'=' => array(),
|
||||||
|
'<' => array(),
|
||||||
|
'>' => array(),
|
||||||
|
'>=' => array(),
|
||||||
|
'<=' => array(),
|
||||||
|
'LIKE' => array(),
|
||||||
);
|
);
|
||||||
|
if (isset($specials[$operator])) {
|
||||||
|
$return = $specials[$operator];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We need to upper case because PHP index matches are case sensitive but
|
||||||
|
// do not need the more expensive drupal_strtoupper because SQL statements are ASCII.
|
||||||
|
$operator = strtoupper($operator);
|
||||||
$return = isset($specials[$operator]) ? $specials[$operator] : array();
|
$return = isset($specials[$operator]) ? $specials[$operator] : array();
|
||||||
|
}
|
||||||
|
|
||||||
$return += array('operator' => $operator);
|
$return += array('operator' => $operator);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -790,9 +790,11 @@ class DatabaseUpdateComplexTestCase extends DatabaseTestCase {
|
||||||
* Test WHERE NOT IN clauses.
|
* Test WHERE NOT IN clauses.
|
||||||
*/
|
*/
|
||||||
function testNotInConditionUpdate() {
|
function testNotInConditionUpdate() {
|
||||||
|
// The o is lowercase in the 'NoT IN' operator, to make sure the operators
|
||||||
|
// work in mixed case.
|
||||||
$num_updated = db_update('test')
|
$num_updated = db_update('test')
|
||||||
->fields(array('job' => 'Musician'))
|
->fields(array('job' => 'Musician'))
|
||||||
->condition('name', array('John', 'Paul', 'George'), 'NOT IN')
|
->condition('name', array('John', 'Paul', 'George'), 'NoT IN')
|
||||||
->execute();
|
->execute();
|
||||||
$this->assertIdentical($num_updated, 1, t('Updated 1 record.'));
|
$this->assertIdentical($num_updated, 1, t('Updated 1 record.'));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue