Commits

Jean-Tiare Le Bigot committed 739db7a

fix #11 - fix bug #11 in delete. Keys where not serialized.

  • Participants
  • Parent commits 3493459
  • Tags 1.6.3

Comments (0)

Files changed (3)

+====================
+DynamoDBMapper 1.6.3
+====================
+
+This section documents all user visible changes included between DynamoDBMapper
+versions 1.6.2 and versions 1.6.3
+
+Changes
+-------
+
+- fix bug #11 in delete. Keys where not serialized.
+
+
 ====================
 DynamoDBMapper 1.6.2
 ====================
 
 This section documents all user visible changes included between DynamoDBMapper
-versions 1.5.0 and versions 1.6.0
+versions 1.6.1 and versions 1.6.2
 
 Additions
 ---------

dynamodb_mapper/model.py

         """Delete the current object from the database."""
         cls = type(self)
         hash_key_value = getattr(self, cls.__hash_key__)
+        h_value = _python_to_dynamodb(hash_key_value)
         # Range key is only present in composite primary keys
         if cls.__range_key__:
             range_key_value = getattr(self, cls.__range_key__)
+            r_value = _python_to_dynamodb(range_key_value)
         else:
-            range_key_value = None
+            r_value = None
 
         table = ConnectionBorg().get_table(cls.__table__)
-        Item(table, hash_key_value, range_key_value).delete()
+        Item(table, h_value, r_value).delete()
 
-        dblog.debug("Deleted (%s, %s) from table %s", hash_key_value, range_key_value, cls.__table__)
+        dblog.debug("Deleted (%s, %s) from table %s", h_value, r_value, cls.__table__)

dynamodb_mapper/tests/test_model.py

         m_item_instance = m_item.return_value
         m_table = m_boto.connect_dynamodb.return_value.get_table.return_value
 
-        # Tests with a hash key elem
-        d = DoomEpisode()
-        d.id = "42"
+        python_date = datetime.datetime(2012, 05, 31, 12, 0, 0, tzinfo=utc_tz)
+        dynamodb_date = _python_to_dynamodb(python_date)
+
+
+        # Tests with a date hash key elem (bug #11)
+        d = Patch()
+        d.datetime = python_date
 
         d.delete()
 
-        m_item.assert_called_once_with(m_table, "42", None)
+        m_item.assert_called_once_with(m_table, dynamodb_date, None)
         assert m_item_instance.delete.called
 
     @mock.patch("dynamodb_mapper.model.boto")