Ostico / PhpOrient

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

Error on updating record with EMBEDDED class-linked attribute #26

Closed andreyvk closed 9 years ago

andreyvk commented 9 years ago

Hi,

I suspect that embedded class attributes which were linked to certain classes do not work, when record is updated. Im on OrientDB 2.0.x and the latest PhpOrient.

Here's the schema + test record:

create class Test extends V
create class TestInfo

create property Test.attr1 string
create property Test.attr2 embedded TestInfo

insert into Test set attr1 = "test", attr2 = { "@type": "d", "@class": "TestInfo", "subAttr1": "sub test"}

In the console:

orientdb {db=test}> select from Test

----+-----+------+-----+-----------------------------------
#   |@RID |@CLASS|attr1|attr2
----+-----+------+-----+-----------------------------------
0   |#36:0|Test  |test |TestInfo{@type:d,subAttr1:sub test}
----+-----+------+-----+-----------------------------------

Executing the following throws an exception:

$client = new \PhpOrient\PhpOrient( 'localhost', 2424 );
$client->username = 'user';
$client->password = 'pass';
$client->connect();
$client->dbOpen( 'test', 'user', 'pass' );
$record = $client->recordLoad( new \PhpOrient\Protocols\Binary\Data\ID( '#36:0' ) )[0];
$updatedRecord = $client->recordUpdate( $record );

Error:

PHP Fatal error:  Uncaught exception 'PhpOrient\Exceptions\PhpOrientException' with message 'com.orientechnologies.orient.core.exception.OValidationException: The field 'Test.attr2' has been declared as EMBEDDED with linked class 'TestInfo' but the record has no class' in /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/Abstracts/Operation.php:412
Stack trace:
#0 /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/Abstracts/Operation.php(142): PhpOrient\Protocols\Binary\Abstracts\Operation->_readError()
#1 /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/Abstracts/Operation.php(217): PhpOrient\Protocols\Binary\Abstracts\Operation->_readHeader()
#2 /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/SocketTransport.php(154): PhpOrient\Protocols\Binary\Abstracts\Operation->getResponse()
#3 /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/PhpOrie in /home/ubuntu/shared/www/test/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/Abstracts/Operation.php on line 412
andreyvk commented 9 years ago

:+1: Great job!