Skip to content

Commit

Permalink
Fix support for GetItems' TableName parameter (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf758 authored Dec 18, 2023
1 parent b869b0e commit 3ffce22
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,18 @@ def test_kv(self):
filter_expression="age > 15",
).all()

self.assertEqual(2, len(received_items))
for item in received_items:
self.assertLess(15, item["age"])

received_items = self._client.kv.new_cursor(
container=self._container,
table_path="",
table_name=self._path,
attribute_names=["age", "feature"],
filter_expression="age > 15",
).all()

self.assertEqual(2, len(received_items))
for item in received_items:
self.assertLess(15, item["age"])
Expand Down
12 changes: 12 additions & 0 deletions tests/test_client_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,18 @@ async def test_kv(self):
filter_expression="age > 15",
).all()

self.assertEqual(2, len(received_items))
for item in received_items:
self.assertLess(15, item["age"])

received_items = await self._client.kv.new_cursor(
container=self._container,
table_path="",
table_name=self._path,
attribute_names=["age", "feature"],
filter_expression="age > 15",
).all()

self.assertEqual(2, len(received_items))
for item in received_items:
self.assertLess(15, item["age"])
Expand Down
6 changes: 6 additions & 0 deletions v3io/aio/dataplane/kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def new_cursor(
self,
container,
table_path,
table_name=None,
access_key=None,
raise_for_status=None,
attribute_names="*",
Expand All @@ -47,6 +48,7 @@ def new_cursor(
container,
access_key or self._access_key,
table_path,
table_name,
raise_for_status,
attribute_names,
filter_expression,
Expand Down Expand Up @@ -205,6 +207,7 @@ async def scan(
self,
container,
table_path,
table_name=None,
access_key=None,
raise_for_status=None,
attribute_names="*",
Expand All @@ -228,6 +231,9 @@ async def scan(
The container on which to operate.
table_path (Required) : str
The full path of the table
table_name (Optional) : str
The name of the table. Allows for specifying all tables with '/*'. If used, table_path must be an empty
string.
access_key (Optional) : str
The access key with which to authenticate. Defaults to the V3IO_ACCESS_KEY env.
attribute_names (Optional) : []str or '*'
Expand Down
3 changes: 3 additions & 0 deletions v3io/aio/dataplane/kv_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(
container_name,
access_key,
table_path,
table_name,
raise_for_status=None,
attribute_names="*",
filter_expression=None,
Expand All @@ -42,6 +43,7 @@ def __init__(
# get items params
self.raise_for_status = raise_for_status
self.table_path = table_path
self.table_name = table_name
self.attribute_names = attribute_names
self.filter_expression = filter_expression
self.marker = marker
Expand Down Expand Up @@ -80,6 +82,7 @@ async def next_item(self):
self._current_response = await self._context.kv.scan(
self._container_name,
self.table_path,
self.table_name,
self._access_key,
self.raise_for_status,
self.attribute_names,
Expand Down
6 changes: 6 additions & 0 deletions v3io/dataplane/kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def new_cursor(
self,
container,
table_path,
table_name=None,
access_key=None,
raise_for_status=None,
attribute_names="*",
Expand All @@ -47,6 +48,7 @@ def new_cursor(
container,
access_key or self._access_key,
table_path,
table_name,
raise_for_status,
attribute_names,
filter_expression,
Expand Down Expand Up @@ -228,6 +230,7 @@ def scan(
self,
container,
table_path,
table_name=None,
access_key=None,
raise_for_status=None,
transport_actions=None,
Expand All @@ -252,6 +255,9 @@ def scan(
The container on which to operate.
table_path (Required) : str
The full path of the table
table_name (Optional) : str
The name of the table. Allows for specifying all tables with '/*'. If used, table_path must be an empty
string.
access_key (Optional) : str
The access key with which to authenticate. Defaults to the V3IO_ACCESS_KEY env.
attribute_names (Optional) : []str or '*'
Expand Down
3 changes: 3 additions & 0 deletions v3io/dataplane/kv_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(
container_name,
access_key,
table_path,
table_name,
raise_for_status=None,
attribute_names="*",
filter_expression=None,
Expand All @@ -42,6 +43,7 @@ def __init__(
# get items params
self.raise_for_status = raise_for_status
self.table_path = table_path
self.table_name = table_name
self.attribute_names = attribute_names
self.filter_expression = filter_expression
self.marker = marker
Expand Down Expand Up @@ -82,6 +84,7 @@ def next_item(self):
self._current_response = self._context.kv.scan(
self._container_name,
self.table_path,
self.table_name,
self._access_key,
self.raise_for_status,
None,
Expand Down

0 comments on commit 3ffce22

Please sign in to comment.