Skip to content

Commit

Permalink
feat: add support of parsing rid instead of providing cluster in reco…
Browse files Browse the repository at this point in the history
…rd update and delete
  • Loading branch information
tglman committed May 27, 2024
1 parent 469021e commit b3f3dbb
Showing 1 changed file with 58 additions and 18 deletions.
76 changes: 58 additions & 18 deletions pyorient/messages/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .base import BaseMessage
from ..exceptions import PyOrientBadMethodCallException, \
PyOrientConnectionException
from ..otypes import OrientRecord
from ..otypes import OrientRecord, OrientRecordLink
from ..constants import FIELD_BOOLEAN, FIELD_BYTE, FIELD_BYTES, \
FIELD_INT, FIELD_LONG, FIELD_SHORT, FIELD_STRING, RECORD_CREATE_OP, \
RECORD_DELETE_OP, RECORD_LOAD_OP, RECORD_TYPE_DOCUMENT, RECORD_UPDATE_OP, \
Expand Down Expand Up @@ -209,14 +209,34 @@ def __init__(self, _orient_socket ):
def prepare(self, params=None):

try:
# mandatory if not passed by method
self.set_cluster_id( params[0] )
if type(params) is str :
# mandatory if not passed by method
rid = OrientRecordLink(params)

# mandatory if not passed by method
self.set_cluster_position( params[1] )
self.set_cluster_id( rid.clusterID )

# mandatory if not passed by method
self.set_cluster_position( rid.recordPosition )
elif type(params[0]) is str :
# mandatory if not passed by method
rid = OrientRecordLink(params[0])

self.set_cluster_id( rid.clusterID )

self._record_version = params[2] # optional
self._mode_async = params[3] # optional
# mandatory if not passed by method
self.set_cluster_position( rid.recordPosition )

self._record_version = params[1] # optional
self._mode_async = params[2] # optional
else :
# mandatory if not passed by method
self.set_cluster_id( params[0] )

# mandatory if not passed by method
self.set_cluster_position( params[1] )

self._record_version = params[2] # optional
self._mode_async = params[3] # optional
except IndexError:
# Use default for non existent indexes
pass
Expand Down Expand Up @@ -452,23 +472,43 @@ def __init__(self, _orient_socket ):
def prepare(self, params=None):

try:
# mandatory if not passed by method
self.set_cluster_id( params[0] )
if type(params[0]) is str :
# mandatory if not passed by method
rid = OrientRecordLink(params[0])
self.set_cluster_id( rid.clusterID )

# mandatory if not passed by method
self.set_cluster_position( params[1] )
# mandatory if not passed by method
self.set_cluster_position( rid.recordPosition )

# mandatory if not passed by method
self._record_content = params[2]
# mandatory if not passed by method
self._record_content = params[1]

self._record_version = params[2] # Optional|Needed for transaction

self.set_record_type( params[3] ) # optional

self._record_version_policy = params[4] # optional
self._mode_async = params[5] # optional

self._update_content = params[6] # optional
else :
# mandatory if not passed by method
self.set_cluster_id( params[0] )

# mandatory if not passed by method
self.set_cluster_position( params[1] )

# mandatory if not passed by method
self._record_content = params[2]

self._record_version = params[3] # Optional|Needed for transaction
self._record_version = params[3] # Optional|Needed for transaction

self.set_record_type( params[4] ) # optional
self.set_record_type( params[4] ) # optional

self._record_version_policy = params[5] # optional
self._mode_async = params[6] # optional
self._record_version_policy = params[5] # optional
self._mode_async = params[6] # optional

self._update_content = params[7] # optional
self._update_content = params[7] # optional

except IndexError:
# Use default for non existent indexes
Expand Down

0 comments on commit b3f3dbb

Please sign in to comment.