I'm trying to create an entry that links to a particular class
cluster_id = -1
res = client.command('SELECT * FROM Role WHERE name="User"')
user_role = res[0]
rec = { '@Person': { 'first_name': 'joe', 'last_name': 'soap', 'username': 'soapj', 'roles':user_role._rid } }
res = client.record_create(cluster_id, rec)
But when I do this I get:
Traceback (most recent call last):
File "project/dbtest.py", line 40, in <module>
res = client.record_create(cluster_id, rec )
File "/project/pyorient/orient.py", line 442, in record_create
.prepare(args).send().fetch_response()
File "/project/pyorient/messages/records.py", line 99, in fetch_response
result = super( RecordCreateMessage, self ).fetch_response()
File "/project/pyorient/messages/base.py", line 256, in fetch_response
self._decode_all()
File "/project/pyorient/messages/base.py", line 240, in _decode_all
self._decode_header()
File "/project/pyorient/messages/base.py", line 192, in _decode_header
[ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: java.lang.ArrayIndexOutOfBoundsException -
However, if I instead use raw SQL it works:
res = client.command('SELECT * FROM Role WHERE name="User"')
user_role = res[0]
rec = "INSERT INTO Person SET first_name='joe', last_name='soap', username='soapj', roles=%s" % user_role._rid
res = client.command(rec)
Is there a way to do it using pyorient's native methods, or do I need to drop down into raw sql?