Doubled first row when HydratingResultSet use buffer() on Oracle database
weierophinney opened this issue · 2 comments
- I was not able to find an open or closed issue matching what I'm seeing.
- This is not a question. (Questions should be asked on chat (Signup here) or our forums.)
Hi, i use a OCI8 (oracle) adapter for an application in Expressive. zend-db and zend-hydrator is installed. I need sometime to use buffer() function to iterate more than one time in the result.
It appear that the first row is doubled in the result when i use buffer(). When i'm not use buffer the result is correct.
I also check with MariaDB database for testing and it works in both case (with and without buffer).
I don't know if that problem are really in zend-hydrator or somewhere else because it happened in my case with oracle only.
- PHP 7.1.x / 7.3.x
- zendframework/zend-hydrator (3.0.2)
- zendframework/zend-db (2.10.0)
- OCI8 Version (2.2.0)
Thanks!
Code to reproduce the issue
Just a partial code to see
/*
* Test with MariaDB
*/
$sql = sprintf("MariaDB SQL query that retreive 5 records");
$result = $this->mariadbAdapter->createStatement($sql)->execute();
// Hydrating, not totally configured for that test
$hydrator = new ObjectPropertyHydrator();
$resultSet = new HydratingResultSet($hydrator, new TestEntity());
$resultSet->initialize($result);
$resultSet->buffer(); // With or without the use of buffer, all works like expected
/*
* Test with Oracle
*/
$sql = sprintf("Oracle SQL query that retreive 5 records");
$result2 = $this->oracleAdapter->createStatement($sql)->execute();
// Hydrating, not totally configured for that test
$hydrator2 = new ObjectPropertyHydrator();
$resultSet2 = new HydratingResultSet($hydrator2, new TestEntity());
$resultSet2->initialize($result2);
$resultSet2->buffer(); // -> First row is doubled if buffer enabled!!
/* In view $resultSet is on $this->mariadbDatas and $resultSet2 on $this->oracleDatas */
<h2>MariaDB Results:</h2>
<!-- MariaDB results -->
<?php foreach($this->mariadbDatas as $row): ?>
<pre>
<?php print_r($row) ?>
</pre>
<?php endforeach; ?>
<h2>Oracle Results:</h2>
<!-- Oracle results -->
<?php foreach($this->oracleDatas as $row): ?>
<pre>
<?php print_r($row) ?>
</pre>
<?php endforeach; ?>
Expected results
A
B
C
D
E
Actual results with buffer() // oracle only
A
A <- first line doubled in the results
B
C
D
E
Originally posted by @mbourquin at zendframework/zend-hydrator#107
@mbourquin I would guess the problem is with the adapter, not with zend-hydrator. Definitely needs checking. Thanks for reporting!
Originally posted by @michalbundyra at zendframework/zend-hydrator#107 (comment)
Marked as "Won't Fix", and closing; the issue lies in the database adapter, not this package.