Cassandra
  1. Cassandra
  2. CASSANDRA-4776

Don't require quotes for true and false

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Fix Version/s: 1.2.0 beta 2
    • Component/s: Core
    • Labels:
    • Environment:

      Mac OS X, Fedora 16

      Description

      The docs at http://cassandra.apache.org/doc/cql3/CQL.html#identifiers describe using double quotes for an identifier that is a reserved word. The following works as expected,

      cqlsh:test> select "columnfamily" from system.schema_columnfamilies;

      I have a table with a boolean column. In order to insert a boolean value, I have to enclose it in single quotes. The table looks like,

      CREATE TABLE bool_test (
      id int PRIMARY KEY,
      val boolean
      );

      Here is what happens when I try using double quotes,

      cqlsh:rhq> insert into bool_test (id, val) values (4, "false");
      Bad Request: line 1:43 no viable alternative at input 'false'

      The use of single quotes here seems inconsistent with what is described in the docs, and makes things a bit confusing. It would be nice if single or double quotes could be used for identifiers that are reserved words. I also think it is a bit counter-intuitive to require quotes for true and false which are literal values.

      1. 4776.txt
        2 kB
        Sylvain Lebresne
      2. 4776-cqlsh.txt
        1 kB
        Aleksey Yeschenko

        Activity

        Hide
        Sylvain Lebresne added a comment -

        Alright, committed both patches, thanks

        Show
        Sylvain Lebresne added a comment - Alright, committed both patches, thanks
        Hide
        Aleksey Yeschenko added a comment -

        Please don't commit it yet - I'll attach a patch for cqlsh as well. Soon.

        Show
        Aleksey Yeschenko added a comment - Please don't commit it yet - I'll attach a patch for cqlsh as well. Soon.
        Hide
        Jonathan Ellis added a comment -

        +1

        Show
        Jonathan Ellis added a comment - +1
        Hide
        Sylvain Lebresne added a comment -

        Where/how can I access the latest CQL3 docs?

        The good question is when. There has been many change to CQL3 on trunk but the doc hasn't been updated yet. We'll update it for the release though.

        Show
        Sylvain Lebresne added a comment - Where/how can I access the latest CQL3 docs? The good question is when. There has been many change to CQL3 on trunk but the doc hasn't been updated yet. We'll update it for the release though.
        Hide
        Sylvain Lebresne added a comment -

        Attaching the fairly trivial patch to make boolean literals.

        Show
        Sylvain Lebresne added a comment - Attaching the fairly trivial patch to make boolean literals.
        Hide
        John Sanda added a comment -

        Where/how can I access the latest CQL3 docs? I just ran ant generate-cql-html from trunk where my HEAD is a commit from 10/17. I am not sure how different that is from the doc I cited in the description.

        Show
        John Sanda added a comment - Where/how can I access the latest CQL3 docs? I just ran ant generate-cql-html from trunk where my HEAD is a commit from 10/17. I am not sure how different that is from the doc I cited in the description.
        Hide
        Jonathan Ellis added a comment -

        Updated title.

        Show
        Jonathan Ellis added a comment - Updated title.
        Hide
        Aleksey Yeschenko added a comment -

        I agree with making true/false valid identifiers, but don't understand what's otherwise expected from this issue. It's a documentation bug, and that doc has quite some outdated stuff (assuming it's intended to reflect latest CQL3 and not 3.0.0-beta1).

        Show
        Aleksey Yeschenko added a comment - I agree with making true/false valid identifiers, but don't understand what's otherwise expected from this issue. It's a documentation bug, and that doc has quite some outdated stuff (assuming it's intended to reflect latest CQL3 and not 3.0.0-beta1).
        Hide
        Sylvain Lebresne added a comment -

        In fact there is a documentation bug as the doc pretends that <identifier> are valid <term> but they are not (a <term> is a value, an <identifier> is not a value, not in CQL at least). So that should be fixed. So, with the documentation fixed, it should be clear that you should use single quotes because that's a string you should pass.

        That being said, I'm also open at making true/false being values themselves (without quoting).

        Show
        Sylvain Lebresne added a comment - In fact there is a documentation bug as the doc pretends that <identifier> are valid <term> but they are not (a <term> is a value, an <identifier> is not a value, not in CQL at least). So that should be fixed. So, with the documentation fixed, it should be clear that you should use single quotes because that's a string you should pass. That being said, I'm also open at making true/false being values themselves (without quoting).
        Hide
        Jonathan Ellis added a comment -
        1. it sounds like you're complaining that the server uses single quotes to denote the input it couldn't parse. that sounds completely unreleated to how keywords must be quoted, and a non-problem.
        2. open to making true/false not require quoting but if it's a pita i'm also fine with leaving this alone
        Show
        Jonathan Ellis added a comment - it sounds like you're complaining that the server uses single quotes to denote the input it couldn't parse. that sounds completely unreleated to how keywords must be quoted, and a non-problem. open to making true/false not require quoting but if it's a pita i'm also fine with leaving this alone

          People

          • Assignee:
            Sylvain Lebresne
            Reporter:
            John Sanda
            Reviewer:
            Jonathan Ellis
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development