From cdf375804987c740c12b8534ceb9ee757cee9739 Mon Sep 17 00:00:00 2001 From: GregBestland Date: Mon, 8 Aug 2016 16:09:26 -0500 Subject: [PATCH] Adding test for PYTHON-608 --- .../cqlengine/query/test_updates.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/integration/cqlengine/query/test_updates.py b/tests/integration/cqlengine/query/test_updates.py index a3244d21..747f6d3a 100644 --- a/tests/integration/cqlengine/query/test_updates.py +++ b/tests/integration/cqlengine/query/test_updates.py @@ -241,3 +241,39 @@ class QueryUpdateTests(BaseCassEngTestCase): text_map__update={"bar": None}) obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster) self.assertEqual(obj.text_map, {"foo": '1'}) + + +class StaticDeleteModel(Model): + example_id = columns.Integer(partition_key=True, primary_key=True, default=uuid4) + example_static1 = columns.Integer(static=True) + example_static2 = columns.Integer(static=True) + example_clust = columns.Integer(primary_key=True) + + +class StaticDeleteTests(BaseCassEngTestCase): + + @classmethod + def setUpClass(cls): + super(StaticDeleteTests, cls).setUpClass() + sync_table(StaticDeleteModel) + + @classmethod + def tearDownClass(cls): + super(StaticDeleteTests, cls).tearDownClass() + drop_table(StaticDeleteModel) + + def test_static_deletion(self): + """ + Test to ensure that cluster keys are not included when removing only static columns + + @since 3.6 + @jira_ticket PYTHON-608 + @expected_result Server should not throw an exception, and the static column should be deleted + + @test_category object_mapper + """ + StaticDeleteModel.create(example_id=5, example_clust=5, example_static2=1) + sdm = StaticDeleteModel.filter(example_id=5).first() + self.assertEqual(1, sdm.example_static2) + sdm.update(example_static2=None) + self.assertIsNone(sdm.example_static2)