iconara / cql-rb

Cassandra CQL 3 binary protocol driver for Ruby
106 stars 31 forks source link

Allow mixed case keyspace names #121

Closed michaelmior closed 10 years ago

michaelmior commented 10 years ago

Currently use_keyspace will only work for keyspace names which are all lower case. Quoting the argument to USE is a simple fix. Would be nice if a new minor version of the gem could be released if possible.

michaelmior commented 10 years ago

Sorry, I see after looking at the test results that the intention seems to be that the keyspace name be passed already in quotes. This seems like a strange choice to me. Any particular reason not to just automatically quote all keyspace names?

iconara commented 10 years ago

I'm not super happy about how keyspace names are handled. I probably never should have added the Client#use method. Originally I wasn't aware that there was an issue with the casing of keyspace names. Since they are defined as case insensitive in CQL I had just assumed that would apply to Thrift keyspaces too, but that was wrong (and that's where the quotes come from, it's a way to even make it possible to use #use and the :keyspace option to change to a Thrift keyspace).

This patch would not be possible to merge without a major version bump. It makes the handling of keyspace names case sensitive, which is not what you would expect in CQL – and code that relied on the case insensitivity of the current implementation would break.

There will shortly be a new Cassandra driver for Ruby that will replace cql-rb, so if you feel strongly about this issue please open an issue there and maybe we can get something that works better into that driver. Currently it does not have a #use method, but the keyspace name you pass into #connect is not quoted, so you would have the same problem as with cql-rb.

Personally I think that if you're working with Thrift keyspaces then having to do client.execute('USE "MyKeyspace"') instead of client.use('MyKeyspace'), isn't a big deal. There's so many other things that work differently with Thrift keyspaces anyway.

michaelmior commented 10 years ago

Thanks for the clarification. Coming from using Thrift, I didn't realize that keyspaces are supposed to be case-insensitive in CQL. Given that, I agree that there doesn't really need to be any changes made.