Skip to content

Commit a6a5935

Browse files
committed
Properly quote keyspace name in Session.set_keyspace()
1 parent ca936e0 commit a6a5935

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Bug Fixes
1919
called
2020
* Avoid race condition that could leave ResponseFuture callbacks uncalled
2121
if the callback was added outside of the event loop thread (github issue #95)
22+
* Properly escape keyspace name in Session.set_keyspace(). Previously, the
23+
keyspace name was quoted, but any quotes in the string were not escaped.
2224

2325
Other
2426
-----

cassandra/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
PreparedQueryNotFound,
3232
IsBootstrappingErrorMessage, named_tuple_factory,
3333
dict_factory)
34-
from cassandra.metadata import Metadata
34+
from cassandra.metadata import Metadata, protect_name
3535
from cassandra.policies import (RoundRobinPolicy, SimpleConvictionPolicy,
3636
ExponentialReconnectionPolicy, HostDistance,
3737
RetryPolicy)
@@ -1253,7 +1253,7 @@ def set_keyspace(self, keyspace):
12531253
Set the default keyspace for all queries made through this Session.
12541254
This operation blocks until complete.
12551255
"""
1256-
self.execute('USE "%s"' % (keyspace,))
1256+
self.execute('USE %s' % (protect_name(keyspace),))
12571257

12581258
def _set_keyspace_for_all_pools(self, keyspace, callback):
12591259
"""

0 commit comments

Comments
 (0)