diff --git a/core/DB/Dialect.class.php b/core/DB/Dialect.class.php index 5c6b9e4641..1323e24b9f 100644 --- a/core/DB/Dialect.class.php +++ b/core/DB/Dialect.class.php @@ -100,17 +100,20 @@ public function toValueString($expression) private function toNeededString($expression, $method) { + if (null === $expression) + throw new WrongArgumentException( + 'not null expression expected' + ); + $string = null; - if (null !== $expression) { - if ($expression instanceof DialectString) { - if ($expression instanceof Query) - $string .= '('.$expression->toDialectString($this).')'; - else - $string .= $expression->toDialectString($this); - } else { - $string .= $this->$method($expression); - } + if ($expression instanceof DialectString) { + if ($expression instanceof Query) + $string .= '('.$expression->toDialectString($this).')'; + else + $string .= $expression->toDialectString($this); + } else { + $string .= $this->$method($expression); } return $string; diff --git a/doc/ChangeLog b/doc/ChangeLog index 5407f828ee..c19bd04dbc 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2012-01-11 Evgeny V. Kokovikhin + + * core/DB/Dialect.class.php: throw exception for null values. Thanks to + Nikita V. Konstantinov. + 2011-11-21 Alexey S. Denisov, Evgeny V. Kokovikhin * meta/types/ObjectType.class.php, test/misc/DAOTest.class.php: changed logic diff --git a/test/core/LogicTest.class.php b/test/core/LogicTest.class.php index bfaa3834e7..83b20e5c4c 100644 --- a/test/core/LogicTest.class.php +++ b/test/core/LogicTest.class.php @@ -210,6 +210,14 @@ public function testBaseSqlGeneration() '(- a)', Expression::minus('a')->toDialectString($dialect) ); + + try { + Expression::eq('id', null)->toDialectString($dialect); + + $this->fail(); + } catch (WrongArgumentException $e) { + //it's Ok + } } public function testPgGeneration()