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

Zend\Stdlib\PriorityList cannot contain false values #6768

Closed
Grundik opened this issue Oct 15, 2014 · 6 comments
Closed

Zend\Stdlib\PriorityList cannot contain false values #6768

Grundik opened this issue Oct 15, 2014 · 6 comments
Assignees
Milestone

Comments

@Grundik
Copy link

Grundik commented Oct 15, 2014

As a consequence, Zend\Db\Sql\Update not only cannot set false values, but also stop setting any values beyond false one.

$platform = new \Zend\Db\Adapter\Platform\Mysql(new \Zend\Db\Adapter\Driver\Mysqli\Mysqli(null));
// just for convenience, platform really doesn't matter, because bug in PriorityList

$sql = new \Zend\Db\Sql\Update('table');
$sql->set(array('value2'=>'test', 'value3'=>true, 'value1'=>false));
echo $sql->getSqlString($platform);
// UPDATE `table` SET `value2` = 'test', `value3` = '1'
// value1 silently discarded

$sql2 = new \Zend\Db\Sql\Update('table');
$sql2->set(array('value1'=>false, 'value2'=>'test', 'value3'=>true));
echo $sql2->getSqlString($platform);
// UPDATE `table` SET
// Totally malformed request, all values discarded

PriorityList->valid() checks, is ->current() returns false. But ->current() returns false not only if current item is invalid, but also when item is false.

@samsonasik
Copy link
Contributor

afaik, boolean in db use tinyint(1) for 0 as false or 1 as true. why not use 0 and 1 instead ? maybe you can do :

$sql->set(array('value2'=>'test', 'value3'=>(int) true, 'value1'=> (int) false));

with cast with (int) ...

@samsonasik
Copy link
Contributor

btw, I have tried to create PR #6773 to it

@Grundik
Copy link
Author

Grundik commented Oct 16, 2014

Yes, using integers is a workaround. But is not it better to have a library to work correctly?

This bug reminds me similar ZF1 bug: http://framework.zend.com/issues/browse/ZF-1457 Still actual, 7 years old, btw. Seems like booleans in database is a pain point of ZF.

@samsonasik
Copy link
Contributor

Yeah, could you take a look at PR #6773 and maybe suggest some feedback if there is something missing ?

@Grundik
Copy link
Author

Grundik commented Oct 16, 2014

Maybe its better not interfere by converting types, since PriorityList in Stdlib package. Something like this: Grundik@e9812a0

@samsonasik
Copy link
Contributor

@Grundik yes, that's better. I've pulled your branch to my branch, combined at #6773 .
Thanks.

samsonasik added a commit to samsonasik/zf2 that referenced this issue Nov 19, 2014
@Ocramius Ocramius self-assigned this Nov 20, 2014
@Ocramius Ocramius added this to the 2.3.4 milestone Nov 20, 2014
Ocramius added a commit that referenced this issue Nov 20, 2014
… into its own test method with `@group` annotations
Ocramius added a commit that referenced this issue Nov 20, 2014
Ocramius added a commit that referenced this issue Nov 20, 2014
…'develop'

Close #6773
Close #6768
Close #6820
Close #6834
Close #6881
Forward port #6773
Forward port #6768
Ocramius added a commit that referenced this issue Nov 20, 2014
gianarb pushed a commit to zendframework/zend-stdlib that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this issue May 15, 2015
…emoving redundant docblocks, cleaning up comparison operations syntax and simplifying code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants