From 3ffce2206962b9486648c7cd5e60a064f2450cfb Mon Sep 17 00:00:00 2001 From: Assaf Ben-Amitai Date: Mon, 18 Dec 2023 13:19:09 +0200 Subject: [PATCH] Fix support for GetItems' `TableName` parameter (#111) --- tests/test_client.py | 12 ++++++++++++ tests/test_client_aio.py | 12 ++++++++++++ v3io/aio/dataplane/kv.py | 6 ++++++ v3io/aio/dataplane/kv_cursor.py | 3 +++ v3io/dataplane/kv.py | 6 ++++++ v3io/dataplane/kv_cursor.py | 3 +++ 6 files changed, 42 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index 0ade3c1..be1701d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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"]) diff --git a/tests/test_client_aio.py b/tests/test_client_aio.py index 7fa03a1..c80e188 100644 --- a/tests/test_client_aio.py +++ b/tests/test_client_aio.py @@ -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"]) diff --git a/v3io/aio/dataplane/kv.py b/v3io/aio/dataplane/kv.py index b0047ef..f33a9cf 100644 --- a/v3io/aio/dataplane/kv.py +++ b/v3io/aio/dataplane/kv.py @@ -30,6 +30,7 @@ def new_cursor( self, container, table_path, + table_name=None, access_key=None, raise_for_status=None, attribute_names="*", @@ -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, @@ -205,6 +207,7 @@ async def scan( self, container, table_path, + table_name=None, access_key=None, raise_for_status=None, attribute_names="*", @@ -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 '*' diff --git a/v3io/aio/dataplane/kv_cursor.py b/v3io/aio/dataplane/kv_cursor.py index d62b37b..341a8a0 100644 --- a/v3io/aio/dataplane/kv_cursor.py +++ b/v3io/aio/dataplane/kv_cursor.py @@ -19,6 +19,7 @@ def __init__( container_name, access_key, table_path, + table_name, raise_for_status=None, attribute_names="*", filter_expression=None, @@ -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 @@ -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, diff --git a/v3io/dataplane/kv.py b/v3io/dataplane/kv.py index 9e75704..d7e160d 100644 --- a/v3io/dataplane/kv.py +++ b/v3io/dataplane/kv.py @@ -30,6 +30,7 @@ def new_cursor( self, container, table_path, + table_name=None, access_key=None, raise_for_status=None, attribute_names="*", @@ -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, @@ -228,6 +230,7 @@ def scan( self, container, table_path, + table_name=None, access_key=None, raise_for_status=None, transport_actions=None, @@ -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 '*' diff --git a/v3io/dataplane/kv_cursor.py b/v3io/dataplane/kv_cursor.py index b4304b1..791433f 100644 --- a/v3io/dataplane/kv_cursor.py +++ b/v3io/dataplane/kv_cursor.py @@ -19,6 +19,7 @@ def __init__( container_name, access_key, table_path, + table_name, raise_for_status=None, attribute_names="*", filter_expression=None, @@ -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 @@ -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,