Skip to content

Writing bytes into OGM object throws an exception #40

Description

@FredPraca

Using the following class representation:

class Sensor(Node):
     name = String()
     zone = String()
     photo = Binary()

I'm able to create the schema in the database using the Node registry without any problem.

When trying to insert values using:

graph.create_vertex(Sensor,
       name = 'test',
       zone = 'z1',
       photo = bytes_read)

where bytes_read comes from

with open('/home/test/Images/test.png', 'rb') as f:
     bytes_read = f.read();

I got the following stacktrace

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/ogm/graph.py", line 546, in create_vertex
    to_unicode(self.create_vertex_command(vertex_cls, **kwargs)))[0]
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/orient.py", line 463, in command
    .prepare(( QUERY_CMD, ) + args).send().fetch_response()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/commands.py", line 144, in fetch_response
    super( CommandMessage, self ).fetch_response()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 265, in fetch_response
    self._decode_all()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 249, in _decode_all
    self._decode_header()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 182, in _decode_header
    [ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientSQLParsingException: com.orientechnologies.orient.core.sql.OCommandSQLParsingException - Lexical error at line 1, column 57.  Encountered: "x" (120), after : "\'\\"
	DB name="test"
	Error Code="1"

I suspect the binary is not correctly encoded as in PropertyEncoder, I don't find ay case to serialize Binary object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions