@@ -406,6 +406,30 @@ def test_raise_error_on_prepared_statement_execution_dropped_table(self):
406406 with pytest .raises (InvalidRequest ):
407407 self .session .execute (prepared , [0 ])
408408
409+ def test_recognize_bound_lwt_query (self ):
410+ self .session .execute ("CREATE TABLE IF NOT EXISTS preparedtests.bound_statement_test (a int PRIMARY KEY, b int)" )
411+ # Prepare a non-LWT statement
412+ statementNonLWT = self .session .prepare ("UPDATE preparedtests.bound_statement_test SET b = ? WHERE a = ?" )
413+ # Prepare an LWT statement
414+ statementLWT = self .session .prepare ("UPDATE preparedtests.bound_statement_test SET b = ? WHERE a = ? IF b = ?" )
415+
416+ boundNonLWT = statementNonLWT .bind ((3 , 1 ))
417+ boundLWT = statementLWT .bind ((3 , 1 , 5 ))
418+
419+ # Check LWT detection
420+ assert not boundNonLWT .is_lwt ()
421+ assert boundLWT .is_lwt ()
422+
423+ def test_recognize_prepared_lwt_query (self ):
424+ self .session .execute ("CREATE TABLE IF NOT EXISTS preparedtests.prepared_statement_test (a int PRIMARY KEY, b int)" )
425+ # Prepare a non-LWT statement
426+ statementNonLWT = self .session .prepare ("UPDATE preparedtests.prepared_statement_test SET b = ? WHERE a = ?" )
427+ # Prepare an LWT statement
428+ statementLWT = self .session .prepare ("UPDATE preparedtests.prepared_statement_test SET b = ? WHERE a = ? IF b = ?" )
429+ # Check LWT detection
430+ assert not statementNonLWT .is_lwt ()
431+ assert statementLWT .is_lwt ()
432+
409433 @unittest .skipIf ((CASSANDRA_VERSION >= Version ('3.11.12' ) and CASSANDRA_VERSION < Version ('4.0' )) or \
410434 CASSANDRA_VERSION >= Version ('4.0.2' ),
411435 "Fixed server-side in Cassandra 3.11.12, 4.0.2" )
0 commit comments