1. Ludia
  2. Untitled project
  3. dynamodb-mock

Commits

Jean-Tiare Le Bigot  committed 65f2522

fix #9; When QUERY hash_key is not found, return empty result set instead of prpagating a KeyError

  • Participants
  • Parent commits 4eb5ffd
  • Branches default

Comments (0)

Files changed (2)

File ddbmock/database/table.py

View file
         if start and start['HashKeyElement'] != hash_key:
             raise ValidationException("'HashKeyElement' element of 'ExclusiveStartKey' must be the same as the hash_key. Expected {}, got {}".format(hash_key, start['HashKeyElement']))
 
-        data = self.store[hash_value, None]
+        try:
+            data = self.store[hash_value, None]
+        except KeyError:
+            # fix #9: return empty result set if first key does not exist
+            return Results(results, size, lek, -1)
 
         keys = sorted(data.keys())
 

File tests/functional/pyramid/test_query.py

View file
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=400)
+        res = self.app.post_json('/', request, HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
         self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])