Skip to content

Commit 8e6a1db

Browse files
aboudreaultmambocab
authored andcommitted
PrepareStatement should support is_idempotent
1 parent b81cfee commit 8e6a1db

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.11
2+
====
3+
4+
Bug Fixes
5+
---------
6+
* is_idempotent flag is not propagated from PreparedStatement to BoundStatement (PYTHON-736)
7+
18
3.10.0
29
======
310
May 24, 2017

cassandra/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ def __init__(self, prepared_statement, retry_policy=None, consistency_level=None
496496
self.keyspace = meta[0].keyspace_name
497497

498498
Statement.__init__(self, retry_policy, consistency_level, routing_key,
499-
serial_consistency_level, fetch_size, keyspace, custom_payload)
499+
serial_consistency_level, fetch_size, keyspace, custom_payload,
500+
prepared_statement.is_idempotent)
500501

501502
def bind(self, values):
502503
"""

tests/integration/standard/test_policies.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ def test_speculative_execution(self):
112112
with self.assertRaises(OperationTimedOut):
113113
result = self.session.execute(statement, execution_profile='spec_ep_rr', timeout=.5)
114114

115+
# PYTHON-736 Test speculation policy works with a prepared statement
116+
statement = self.session.prepare("SELECT timeout(100) FROM d WHERE k = ?")
117+
# non-idempotent
118+
result = self.session.execute(statement, (0,), execution_profile='spec_ep_brr')
119+
self.assertEqual(1, len(result.response_future.attempted_hosts))
120+
# idempotent
121+
statement.is_idempotent = True
122+
result = self.session.execute(statement, (0,), execution_profile='spec_ep_brr')
123+
self.assertLess(1, len(result.response_future.attempted_hosts))
124+
115125
#TODO redo this tests with Scassandra
116126
def test_speculative_and_timeout(self):
117127
"""

0 commit comments

Comments
 (0)