Ostico / PhpOrient

PhpOrient - Official Php driver based on the binary protocol of OrientDB.
Other
68 stars 37 forks source link

Record ID returned as decimal #65

Closed emman-ok closed 8 years ago

emman-ok commented 8 years ago

How Do I Solve This rid: "#13:25.0000000000". Was Expecting rid:"13:25"

andreyvk commented 8 years ago

That doesnt look good. Any way to reproduce that?

Sent from my iPhone

On Jan 30, 2016, at 17:50, emman_ok notifications@github.com wrote:

How Do I Solve This rid: "#13:250000000000" Was Expecting rid:"13:25"

— Reply to this email directly or view it on GitHub.

smolinari commented 8 years ago

@emman-ok - Is the problem solved? If yes, what was the solution?

Scott

emman-ok commented 8 years ago

Yes , I just have to edit the file path "PhpOrient\src\PhpOrient\Protocols\Binary\Data\ID.php" by casting the cluster and position into integer

public function __construct( $cluster = -1, $position = -1 ) { if ( is_array( $cluster ) ) { if ( isset( $cluster[ 'cluster' ] ) ) { $this->cluster = (int)$cluster[ 'cluster' ]; } if ( isset( $cluster[ 'position' ] ) ) { $this->position = (int)$cluster[ 'position' ]; } } else { if ( is_string( $cluster ) && $cluster[ 0 ] === '#' ) { list( $this->cluster, $this->position ) = self::parseString( $cluster ); } else { $this->cluster = (int)$cluster; $this->position = (int)$position; } } }

andreyvk commented 8 years ago

@emman-ok @smolinari i think a better solution would be to cast cluster and position into integer and then back to string again, since original ID cluster and position are strings initially

smolinari commented 8 years ago

Can the casting be avoided altogether?

Scott

andreyvk commented 8 years ago

@smolinari technically problem should be fixed somewhere before the ID is instantiated. It looks like some part of the code that deserializes RID passed from the server is initially casting it into a float or smth. Hence the problem with the floating point. After that ID is instantiated with a wrongly parsed $position. @emman-ok did not get rid or the problem, but prevented it from happening again. I personally think that the problem stems from Reader::unpackLong, but im not sure. @Ostico what do you think?

Ostico commented 8 years ago

Yes guys this is a bug that can happen in PHP 32bit version. @emman-ok can you confirm this?

By the way: ReadMe