pyorient
pyorient copied to clipboard
failure to parse temporary rids
Temporary rids cause a crash in pyorient. A simple example:
>>> connection.command('select 1, $t let $t=(select 1)')
Traceback (most recent call last):
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/orient.py", line 411, in command
.prepare(( QUERY_CMD, ) + args).send().fetch_response()
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/messages/commands.py", line 149, in fetch_response
return self._read_sync()
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/messages/commands.py", line 202, in _read_sync
res.append( self._read_record() )
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/messages/base.py", line 470, in _read_record
class_name, data = self.get_serializer().decode(__res['content'].rstrip())
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/serializations.py", line 75, in decode
chunk = self._parse_value(content)
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/serializations.py", line 236, in _parse_value
return self._parse_collection( content[1:] )
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/serializations.py", line 391, in _parse_collection
chunk = self._parse_value(content)
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/serializations.py", line 234, in _parse_value
return self._parse_rid( content[1:] )
File "/Users/ryan.pessa/venv/callsign/lib/python3.5/site-packages/pyorient/serializations.py", line 374, in _parse_rid
return [ OrientRecordLink( cluster + ":" + collected ), content[i:]]
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
This occurs because _parse_rid and _is_numeric don't handle the - in temp rids (monkey patching _is_numeric to return True for a '-' input fixes the crash). Though I'm not certain that returning OrientRecordLinks to a temp rid is the right thing to do here anyway (see #210).