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

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

@albertor24

Description

@albertor24

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions