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

Doubled first row when HydratingResultSet use buffer() on Oracle database #107

Open
2 tasks done
mbourquin opened this issue Nov 18, 2019 · 2 comments
Open
2 tasks done

Comments

@mbourquin
Copy link

  • 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

@michalbundyra
Copy link
Member

@mbourquin I would guess the problem is with the adapter, not with zend-hydrator. Definitely needs checking. Thanks for reporting!

@weierophinney
Copy link
Member

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

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