Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Incorrect Sql Expression parameters when passing zero in the constructor #381

Open
2 tasks done
albertor24 opened this issue Jul 2, 2019 · 2 comments
Open
2 tasks done

Comments

@albertor24
Copy link
Contributor

albertor24 commented Jul 2, 2019

I am trying to create an expression that has zero as the parameter value. However, the parameters incorrectly show as empty.

Code to reproduce the issue

$expr = new \Zend\Db\Sql\Expression('?', '0');
print_r($expr->getParameters());

Expected results

It prints "0"

Actual results

It prints empty array

Proposed fix

https://github.com/zendframework/zend-db/blob/master/src/Sql/Expression.php#L59

In Zend\Db\Sql\Expression, update the constructor to explicitly check for '0' when setting parameters

if ($parameters || $parameters === '0') {
     $this->setParameters($parameters);
}
@albertor24 albertor24 changed the title Incorrect expression parameters when passing zero Incorrect Sql Expression parameters when passing zero in the constructor Jul 3, 2019
@michalbundyra
Copy link
Member

@albertor24 Please submit PR and add test to cover your case 👍

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#6.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants