Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the composite partition key syntax is incorrect when multiple cluster keys are used #35

Closed
batwicket opened this issue Feb 15, 2017 · 4 comments

Comments

@batwicket
Copy link

When an array is specified for the cluster key arguments an extra parenthesis is placed around them in the PRIMARY KEY clause i.e., from https://docs.datastax.com/en/cql/3.1/cql/cql_reference/refCompositePk.html:

CREATE TABLE Cats (
  block_id uuid,
  breed text,
  color text,
  short_hair boolean,
  PRIMARY KEY ((block_id, breed), color, short_hair)
);

is, instead:

CREATE TABLE Cats (
  block_id uuid,
  breed text,
  color text,
  short_hair boolean,
  PRIMARY KEY ((block_id, breed), (color, short_hair))
);

The unit tests don't appear to catch this case. Sounds valid?

@UnbounDev
Copy link
Contributor

Hello @batwicket,

I think the case you're referring to is handled by this unit test.

As to your second example I'm not certain what you mean as that is an invalid CQL statement:

cqlsh:sandbox> CREATE TABLE Cats (
           ...   block_id uuid,
           ...   breed text,
           ...   color text,
           ...   short_hair boolean,
           ...   PRIMARY KEY ((block_id, breed), (color, short_hair))
           ... );
SyntaxException: line 6:34 no viable alternative at input '(' (... ((block_id, breed), [(]...)

@batwicket
Copy link
Author

I may have been unclear. The second example I gave is the syntax produced by cassanknex. It adds extra parentheses around the cluster keys. As you say, this causes a syntax error.

@batwicket
Copy link
Author

Just to be clear, I want to make sure I'm addressing something that's an issue. If it is then it might take me a few days to get to it if you don't have time.

UnbounDev added a commit that referenced this issue Feb 15, 2017
@UnbounDev UnbounDev mentioned this issue Feb 15, 2017
@UnbounDev
Copy link
Contributor

Ah, I see your point.

This statement is correct:

cassanKnex("cassanKnexy")
        .createColumnFamily("columnFamily")
        .text("textType")
        .uuid("uuidType")
        .int("intType")
        .timestamp("timestamp")
        .primary(["textType", "uuidType"], "timestamp", "intType");

But the following statement would produce additional brackets around the clustered columns:

cassanKnex("cassanKnexy")
        .createColumnFamily("columnFamily")
        .text("textType")
        .uuid("uuidType")
        .int("intType")
        .timestamp("timestamp")
        .primary(["textType", "uuidType"], ["timestamp", "intType"]);

Thanks for pointing it out, it's a nice convenience for input, I've added it to the next version push (#36)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants