Skip to content

Commit e157984

Browse files
authored
Merge pull request #7 from RSS-Engineering/table_scan_resourcenotfound_exception_fix
Resource not found Exception fix on resource level table scan
2 parents d38e46c + cbbfed8 commit e157984

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pydanticrud/backends/dynamodb.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,21 @@ def query(self, query_expr: Optional[Rule] = None, filter_expr: Optional[Rule] =
298298

299299
try:
300300
resp = table.query(**params)
301+
except ClientError as e:
302+
if e.response["Error"]["Code"] == "ResourceNotFoundException":
303+
return []
304+
raise e
301305
except DynamoDBNeedsKeyConditionError:
302306
raise ConditionCheckFailed("Non-key attributes are not valid in the query expression. Use filter "
303307
"expression")
304308

305309
else:
306-
resp = table.scan(**params)
310+
try:
311+
resp = table.scan(**params)
312+
except ClientError as e:
313+
if e.response["Error"]["Code"] == "ResourceNotFoundException":
314+
return []
315+
raise e
307316

308317
return [self._deserialize_record(rec) for rec in resp["Items"]]
309318

0 commit comments

Comments
 (0)