Commits

Jean-Tiare Le Bigot committed 4d204f4

added check on batch size

Comments (0)

Files changed (2)

dynamodb_mapper/model.py

             (e.g. [("user1", 1), ("user1", 2), ("user1", 3)]).
 
         get_batch *always* performs eventually consistent reads.
+
+        Please not that a batch can *not* read more than 100 items at once.
         """
+        if len(keys) > 100:
+            raise ValueError("Too many items to read in a single batch. Maximum is 100.")
+
         borg = ConnectionBorg()
         table = borg.get_table(cls.__table__)
         # Convert all the keys to DynamoDB values.

dynamodb_mapper/tests/test_model.py

 
         m_new_batch_list.assert_called_once()
 
+    @raises(ValueError)
+    def test_get_batch_over_100(self):
+        DoomEpisode.get_batch(range(101));
+
     @raises(ThroughputError)
     def test_create_table_bad_throughput(self):
         table = ConnectionBorg().create_table(DoomEpisode, 2, 5, False)