{"action":"opened","issue":{"url":"https://api.github.com/repos/jlafon/PynamoDB/issues/69","labels_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/69/comments","events_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/69/events","html_url":"https://github.com/jlafon/PynamoDB/issues/69","id":103577689,"number":69,"title":"Batch deletes fail for Models without a range key defined","user":{"login":"kemitche","id":849933,"avatar_url":"https://avatars.githubusercontent.com/u/849933?v=3","gravatar_id":"","url":"https://api.github.com/users/kemitche","html_url":"https://github.com/kemitche","followers_url":"https://api.github.com/users/kemitche/followers","following_url":"https://api.github.com/users/kemitche/following{/other_user}","gists_url":"https://api.github.com/users/kemitche/gists{/gist_id}","starred_url":"https://api.github.com/users/kemitche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kemitche/subscriptions","organizations_url":"https://api.github.com/users/kemitche/orgs","repos_url":"https://api.github.com/users/kemitche/repos","events_url":"https://api.github.com/users/kemitche/events{/privacy}","received_events_url":"https://api.github.com/users/kemitche/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-27T19:27:15Z","updated_at":"2015-08-27T19:27:15Z","closed_at":null,"body":"If I define a simple model with only a hash key, but no range key, I'm unable to perform bulk delete operations:\r\n\r\n```\r\nimport os\r\nimport pynamodb.attributes\r\nimport pynamodb.models\r\n\r\n\r\nclass SimpleModel(pynamodb.models.Model):\r\n    class Meta:\r\n        table_name = \"simple_model\"\r\n        host = os.environ['DYNAMODB_URL']\r\n    id = pynamodb.attributes.UnicodeAttribute(hash_key=True)\r\n\r\nSimpleModel.create_table(read_capacity_units=1, write_capacity_units=1, wait=True)\r\n\r\nsimple = SimpleModel(\"test\")\r\nsimple.save()\r\n\r\nwith SimpleModel.batch_write() as batch:\r\n    batch.delete(simple)\r\n```\r\n\r\nOutput:\r\n\r\n```\r\ntest@kemitche:/srv/service/current# service_venv python scripts/simple_model.py Traceback (most recent call last):\r\n  File \"scripts/simple_model.py\", line 18, in <module>\r\n    batch.delete(simple)\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/models.py\", line 94, in __exit__\r\n    return self.commit()\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/models.py\", line 115, in commit\r\n    delete_items=delete_items\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/connection/table.py\", line 98, in batch_write_item\r\n    return_item_collection_metrics=return_item_collection_metrics)\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/connection/base.py\", line 706, in batch_write_item\r\n    DELETE_REQUEST: self.get_item_attribute_map(table_name, item, item_key=KEY, pythonic_key=False)\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/connection/base.py\", line 440, in get_item_attribute_map\r\n    pythonic_key=pythonic_key)\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/connection/base.py\", line 110, in get_item_attribute_map\r\n    self.get_attribute_type(key): value\r\n  File \"/usr/local/lib/service_venv/local/lib/python2.7/site-packages/pynamodb/connection/base.py\", line 126, in get_attribute_type\r\n    raise ValueError(\"No attribute {0} in {1}\".format(attribute_name, attr_names))\r\nValueError: No attribute None in [u'id']\r\n```\r\n\r\nIt appears the culprit is `Model._get_keys()` which unconditionally returns a dictionary with a range key of `None` if there is no defined range key."}}