Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions core/DB/Dialect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/core/LogicTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down