Skip to content

Commit fa3c33e

Browse files
Merge branch 'fix/camelcase-fabric-proto-names'
Signed-off-by: kmilo <kmilo.denis.glez@yandex.com>
2 parents 1bf1fcf + d0187ea commit fa3c33e

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎src/fabric_shim/handler.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ async def handle_get_state_by_range(self, collection, start_key, end_key,
245245
message — used for pagination.
246246
"""
247247
msg_pb = ccshim_pb2.GetStateByRange()
248-
msg_pb.start_key = start_key or ""
249-
msg_pb.end_key = end_key or ""
248+
# NB: the protobuf field names are camelCase (startKey/endKey), not
249+
# snake_case.
250+
msg_pb.startKey = start_key or ""
251+
msg_pb.endKey = end_key or ""
250252
msg_pb.collection = collection
251253
if metadata is not None:
252254
msg_pb.metadata = metadata

‎src/fabric_shim/stub.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async def get_state_by_range(self, start_key: str, end_key: str):
160160
tx_id=self.tx_id,
161161
initial_response=raw,
162162
response_factory=lambda payload: ccshim_pb2.QueryResponse.FromString(payload),
163-
parser=lambda qrb: kv_pb.KV.FromString(qrb.result_bytes),
163+
parser=lambda qrb: kv_pb.KV.FromString(qrb.resultBytes),
164164
)
165165

166166
async def get_state_by_range_with_pagination(self, start_key: str, end_key: str,
@@ -176,7 +176,7 @@ async def get_state_by_range_with_pagination(self, start_key: str, end_key: str,
176176
from fabric_protos.ledger.queryresult import kv_query_result_pb2 as kv_pb
177177

178178
meta = ccshim_pb2.QueryMetadata()
179-
meta.pagesize = int(page_size)
179+
meta.pageSize = int(page_size)
180180
meta.bookmark = bookmark or ""
181181
raw = await self.client.handle_get_state_by_range(
182182
collection, start_key, end_key,
@@ -188,7 +188,7 @@ async def get_state_by_range_with_pagination(self, start_key: str, end_key: str,
188188
tx_id=self.tx_id,
189189
initial_response=raw,
190190
response_factory=lambda payload: ccshim_pb2.QueryResponse.FromString(payload),
191-
parser=lambda qrb: kv_pb.KV.FromString(qrb.result_bytes),
191+
parser=lambda qrb: kv_pb.KV.FromString(qrb.resultBytes),
192192
)
193193

194194
async def get_query_result(self, query: str):
@@ -210,7 +210,7 @@ async def get_query_result(self, query: str):
210210
tx_id=self.tx_id,
211211
initial_response=raw,
212212
response_factory=lambda payload: ccshim_pb2.QueryResponse.FromString(payload),
213-
parser=lambda qrb: kv_pb.KV.FromString(qrb.result_bytes),
213+
parser=lambda qrb: kv_pb.KV.FromString(qrb.resultBytes),
214214
)
215215

216216
async def get_query_result_with_pagination(self, query: str, page_size: int,
@@ -222,7 +222,7 @@ async def get_query_result_with_pagination(self, query: str, page_size: int,
222222
from fabric_protos.ledger.queryresult import kv_query_result_pb2 as kv_pb
223223

224224
meta = ccshim_pb2.QueryMetadata()
225-
meta.pagesize = int(page_size)
225+
meta.pageSize = int(page_size)
226226
meta.bookmark = bookmark or ""
227227
raw = await self.client.handle_get_query_result(
228228
collection, query, self.channel_id, self.tx_id,
@@ -234,7 +234,7 @@ async def get_query_result_with_pagination(self, query: str, page_size: int,
234234
tx_id=self.tx_id,
235235
initial_response=raw,
236236
response_factory=lambda payload: ccshim_pb2.QueryResponse.FromString(payload),
237-
parser=lambda qrb: kv_pb.KV.FromString(qrb.result_bytes),
237+
parser=lambda qrb: kv_pb.KV.FromString(qrb.resultBytes),
238238
)
239239

240240
async def get_history_for_key(self, key: str):
@@ -256,7 +256,7 @@ async def get_history_for_key(self, key: str):
256256
tx_id=self.tx_id,
257257
initial_response=raw,
258258
response_factory=lambda payload: ccshim_pb2.QueryResponse.FromString(payload),
259-
parser=lambda qrb: kv_pb.KeyModification.FromString(qrb.result_bytes),
259+
parser=lambda qrb: kv_pb.KeyModification.FromString(qrb.resultBytes),
260260
)
261261

262262
async def get_state_by_partial_composite_key(self, object_type: str,

0 commit comments

Comments
 (0)