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

Zend\Db\ResultSet\ResultSet->current() returns false instead of NULL #330

Open
willy0275 opened this Issue Jul 30, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@willy0275
Copy link

willy0275 commented Jul 30, 2018

This problem was there in version 2.7. It was fixed in 2.8, but came back in 2.9.

  • Database: 10.0.35-MariaDB
  • PHP version: 7.2.7
  • Zend Db version: 2.9.3

To reproduce, use a database with some empty table, and execute:

$myAdapter = new \Zend\Db\Adapter\Adapter([
    'host'      => 'mariadb',
    'driver'    => 'Mysqli',
    'username'  => 'devppl',
    'password'  => '******',
    'database'  => 'mydatabase',
    'charset'   => 'utf8',
    'options'   => ['buffer_results' => true]
]);

$tableGateway = new \Zend\Db\TableGateway\TableGateway('myEmptyTable', $myAdapter);
$row = $tableGateway->select('myField = 999')->current();
var_export($row);

Expected result would be NULL, I get false instead.

I noticed that when I set buffer_results to false, I don't have the bug.

@willy0275

This comment has been minimized.

Copy link

willy0275 commented Jul 30, 2018

I think the commit that actually broke the fonctionnality is this one, it returns false in there and it should not because the signature says it should be null (or array):

8276cf6#diff-86b3a79320eb564e46456a1b75003271R197

@ezimuel

This comment has been minimized.

Copy link
Member

ezimuel commented Aug 8, 2018

@willy0275 I confirm this bug has been introduce by #255 and released in 2.9.0. I'm working on a fix.

@ezimuel ezimuel added the bug label Aug 8, 2018

@willy0275

This comment has been minimized.

Copy link

willy0275 commented Aug 8, 2018

@ezimuel

This comment has been minimized.

Copy link
Member

ezimuel commented Aug 8, 2018

Maybe this is related with #325

@willy0275

This comment has been minimized.

Copy link

willy0275 commented Aug 9, 2018

After a quick look, it seems like the same resulting bug but not the same bug as the method HydratingResultSet->current() is not using the code in the abstract class. So it seems it's just a coincidence and not really related.

@ezimuel

This comment has been minimized.

Copy link
Member

ezimuel commented Aug 9, 2018

@willy0275 I just sent the PR #334, please check and let me know. Thanks!

@willy0275

This comment has been minimized.

Copy link

willy0275 commented Aug 9, 2018

Looks great, thanks!

@ezimuel

This comment has been minimized.

Copy link
Member

ezimuel commented Aug 10, 2018

@willy0275 it seems there are some inconsistencies for other adapter, apart Mysqli. I'm working on it and let you know asap.

ezimuel added a commit to ezimuel/zend-db that referenced this issue Aug 17, 2018

@ezimuel ezimuel referenced a pull request that will close this issue Aug 17, 2018

Open

Fixes #330 current NULL for mysqli #337

@ezimuel

This comment has been minimized.

Copy link
Member

ezimuel commented Aug 17, 2018

@willy0275 I closed #334 in favor of #337. Now the solution is directly in the mysqli adapter. Can you check? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment