diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5fd7340d..1b9f04bf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,8 @@ Bug Fixes called * Avoid race condition that could leave ResponseFuture callbacks uncalled if the callback was added outside of the event loop thread (github issue #95) +* Properly escape keyspace name in Session.set_keyspace(). Previously, the + keyspace name was quoted, but any quotes in the string were not escaped. Other ----- diff --git a/cassandra/cluster.py b/cassandra/cluster.py index 85419c2f..6ccf4264 100644 --- a/cassandra/cluster.py +++ b/cassandra/cluster.py @@ -31,7 +31,7 @@ from cassandra.decoder import (QueryMessage, ResultMessage, PreparedQueryNotFound, IsBootstrappingErrorMessage, named_tuple_factory, dict_factory) -from cassandra.metadata import Metadata +from cassandra.metadata import Metadata, protect_name from cassandra.policies import (RoundRobinPolicy, SimpleConvictionPolicy, ExponentialReconnectionPolicy, HostDistance, RetryPolicy) @@ -1253,7 +1253,7 @@ class Session(object): Set the default keyspace for all queries made through this Session. This operation blocks until complete. """ - self.execute('USE "%s"' % (keyspace,)) + self.execute('USE %s' % (protect_name(keyspace),)) def _set_keyspace_for_all_pools(self, keyspace, callback): """