File tree Expand file tree Collapse file tree
tests/integration/standard Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111* Reevaluate MONKEY_PATCH_LOOP in test codebase (PYTHON-903)
1212* Remove CASS_SERVER_VERSION and replace it for CASSANDRA_VERSION in tests (PYTHON-910)
1313* Refactor CASSANDRA_VERSION to a some kind of version object (PYTHON-915)
14+ * Warn users when using the deprecated Session.default_consistency_level (PYTHON-953)
1415
1516
16173.13.0
Original file line number Diff line number Diff line change @@ -1936,6 +1936,7 @@ def default_timeout(self, timeout):
19361936 @property
19371937 def default_consistency_level (self ):
19381938 """
1939+ *Deprecated:* use execution profiles instead
19391940 The default :class:`~ConsistencyLevel` for operations executed through
19401941 this session. This default may be overridden by setting the
19411942 :attr:`~.Statement.consistency_level` on individual statements.
@@ -1950,6 +1951,12 @@ def default_consistency_level(self):
19501951
19511952 @default_consistency_level .setter
19521953 def default_consistency_level (self , cl ):
1954+ """
1955+ *Deprecated:* use execution profiles instead
1956+ """
1957+ warn ("Setting the consistency level at the session level will be removed in 4.0. Consider using "
1958+ "execution profiles and setting the desired consitency level to the EXEC_PROFILE_DEFAULT profile."
1959+ , DeprecationWarning )
19531960 self ._validate_set_legacy_config ('default_consistency_level' , cl )
19541961
19551962 _default_serial_consistency_level = None
Original file line number Diff line number Diff line change @@ -328,7 +328,10 @@ replicas of the data you are interacting with need to respond for
328328the query to be considered a success.
329329
330330By default, :attr:`.ConsistencyLevel.LOCAL_ONE ` will be used for all queries.
331- You can specify a different default for the session on :attr:`.Session.default_consistency_level` .
331+ You can specify a different default for the session on :attr:`.Session.default_consistency_level`
332+ if the cluster is configured in legacy mode (not using execution profiles). Otherwise this can
333+ be done by setting the :attr:`.ExecutionProfile.consistency_level` for the execution profile with key
334+ :data:`~ .cluster.EXEC_PROFILE_DEFAULT ` .
332335To specify a different consistency level per request, wrap queries
333336in a :class :`~ .SimpleStatement` :
334337
Original file line number Diff line number Diff line change @@ -1482,3 +1482,22 @@ def test_deprecation_warnings_meta_refreshed(self):
14821482 self .assertEqual (len (w ), 1 )
14831483 self .assertIn ("Cluster.set_meta_refresh_enabled is deprecated and will be removed in 4.0." ,
14841484 str (w [0 ].message ))
1485+
1486+ def test_deprecation_warning_default_consistency_level (self ):
1487+ """
1488+ Tests the deprecation warning has been added when enabling
1489+ session the default consistency level to session
1490+
1491+ @since 3.14
1492+ @jira_ticket PYTHON-935
1493+ @expected_result the deprecation warning is emitted
1494+
1495+ @test_category logs
1496+ """
1497+ with warnings .catch_warnings (record = True ) as w :
1498+ cluster = Cluster ()
1499+ session = cluster .connect ()
1500+ session .default_consistency_level = ConsistencyLevel .ONE
1501+ self .assertEqual (len (w ), 1 )
1502+ self .assertIn ("Setting the consistency level at the session level will be removed in 4.0" ,
1503+ str (w [0 ].message ))
You can’t perform that action at this time.
0 commit comments