Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WhereClauseでfalseとして評価されるパラメータを受け取れるよう変更 #4685

Merged
merged 1 commit into from
Sep 25, 2020
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
12 changes: 4 additions & 8 deletions src/Eccube/Doctrine/Query/WhereClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@ private function __construct($expr, $params = null)
*/
private static function newWhereClause($expr, $x, $y)
{
if ($y) {
if (is_array($y)) {
return new WhereClause($expr, $y);
} else {
return new WhereClause($expr, [$x => $y]);
}
if (is_array($y)) {
return new WhereClause($expr, $y);
} else {
return new WhereClause($expr, [$x => $y]);
}

return new WhereClause($expr);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/Eccube/Tests/Doctrine/Query/WhereClauseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ public function testLteWithMap()
self::assertEquals([new Parameter('Price', 1000)], $this->getParams($actual));
}

public function testParameterNull()
{
$actual = WhereClause::eq('name', ':Name', null);
self::assertEquals('name = :Name', $this->asString($actual));
self::assertEquals([new Parameter('Name', null)], $this->getParams($actual));
}

public function testParameterFalseEquivalent()
{
$actual = WhereClause::eq('name', ':Name', '0');
self::assertEquals('name = :Name', $this->asString($actual));
self::assertEquals([new Parameter('Name', '0')], $this->getParams($actual));
}

/*
* Helper methods.
*/
Expand Down