azuqua / cassanknex

A CQL query builder written in the spirit of Knexjs
MIT License
50 stars 10 forks source link

Wrap names with double quotation marks #14

Closed rashtao closed 9 years ago

rashtao commented 9 years ago

With this command:

cassanKnex("ks").createColumnFamily("cf")
        .text("textType")
        .uuid("uuidType")
        .timestamp("timestamp")
        .primary(["textType", "uuidType"], "timestamp");

I get the following CQL query generated:

CREATE COLUMNFAMILY ks.cf ( textType TEXT, uuidType UUID, timestamp TIMESTAMP, PRIMARY KEY ((textType, uuidType), timestamp) ) ;

But this will be stored in Cassandra with all the names lowercase:

> DESCRIBE TABLE cf ;

CREATE TABLE ks.cf (
    texttype text,
    uuidtype uuid,
    "timestamp" timestamp,
    PRIMARY KEY ((texttype, uuidtype), "timestamp")
) 
...

This happens because:

Keyspace, column, and table names created using CQL 3 are case-insensitive unless enclosed in double quotation marks ... http://docs.datastax.com/en/cql/3.0/cql/cql_reference/ucase-lcase_r.html

It would be nice to have in the generated CQL queries all the Keyspaces, columns, and tables names always enclosed in double quotation marks, allowing to specify uppercase letters.

UnbounDev commented 9 years ago

@rashtao can you pull the develop branch and see that your use cases are covered by the enhancements?

rashtao commented 9 years ago

@UnbounDev it seems ok!