From a6a5935be33a5a09158f4df29ce8d52acd86ca98 Mon Sep 17 00:00:00 2001 From: Tyler Hobbs Date: Wed, 19 Mar 2014 14:06:19 -0500 Subject: [PATCH] Properly quote keyspace name in Session.set_keyspace() --- CHANGELOG.rst | 2 ++ cassandra/cluster.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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): """