Skip to content

Commit 2182804

Browse files
committed
bug fixes
1 parent ccf6d1b commit 2182804

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Persist/Expression.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function __construct($operator,$operands){
3636
);
3737
/**
3838
* @todo to support Aggregator functions like , SUM , MAX, MIN ...
39-
* @todo extend support for IS NULL and IS NOT NULL
4039
*/
4140

4241
if(!in_array($operator, $allowedOperators)){
@@ -67,23 +66,23 @@ function __construct($operator,$operands){
6766
break;
6867
case Model::OPERATOR_LT:
6968
$this->expectedOperandsLength($operands, 2);
70-
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM);
71-
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM);
69+
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
70+
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
7271
break;
7372
case Model::OPERATOR_GT:
7473
$this->expectedOperandsLength($operands, 2);
75-
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM);
76-
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM);
74+
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
75+
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
7776
break;
7877
case Model::OPERATOR_LTE:
7978
$this->expectedOperandsLength($operands, 2);
80-
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM);
81-
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM);
79+
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
80+
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
8281
break;
8382
case Model::OPERATOR_GTE:
8483
$this->expectedOperandsLength($operands, 2);
85-
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM);
86-
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM);
84+
$this->isValidOpearand($operands[0], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
85+
$this->isValidOpearand($operands[1], self::$IS_FIELD|self::$IS_NUM|self::$IS_STRING);
8786
break;
8887
case Model::OPERATOR_BETWEEN:
8988
$this->expectedOperandsLength($operands, 3);
@@ -190,8 +189,10 @@ function asString($columnNameMapping){
190189
$operand = "%$operand%";
191190
}
192191
$operand = "'$operand'";
193-
}elseif(is_numeric($operand) || is_bool($operand)){
192+
}elseif(is_numeric($operand)){
194193
$operand = $operand;
194+
}elseif(is_bool($operand)){
195+
$operand = $operand?'TRUE':'FALSE';
195196
}elseif(is_array($operand)){
196197
if(count($operand) == 0){
197198
throw new InvalidInputException('the operand for IN operator can not be empty array');

0 commit comments

Comments
 (0)