[jira] [Commented] (CASSANDRA-7111) Include snippet of CQL query near error in SyntaxError messages

2014-07-15 Thread Tyler Hobbs (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-7111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14062344#comment-14062344
 ] 

Tyler Hobbs commented on CASSANDRA-7111:


Thanks, committed to cassandra-2.1 and trunk.

However, I noticed that a couple of the new unit tests are failing in trunk:

{noformat}
[junit] Testsuite: org.apache.cassandra.cql3.CqlParserTest
[junit] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 
0.161 sec
[junit] 
[junit] Testcase: 
testRemoveErrorListener(org.apache.cassandra.cql3.CqlParserTest): FAILED
[junit] expected:1 but was:2
[junit] junit.framework.AssertionFailedError: expected:1 but was:2
[junit] at 
org.apache.cassandra.cql3.CqlParserTest.testRemoveErrorListener(CqlParserTest.java:70)
[junit] 
[junit] 
[junit] Testcase: 
testAddErrorListener(org.apache.cassandra.cql3.CqlParserTest):FAILED
[junit] expected:1 but was:2
[junit] junit.framework.AssertionFailedError: expected:1 but was:2
[junit] at 
org.apache.cassandra.cql3.CqlParserTest.testAddErrorListener(CqlParserTest.java:49)
[junit] 
[junit] 
[junit] Test org.apache.cassandra.cql3.CqlParserTest FAILED
{noformat}

Can you post a second patch to fix the tests on trunk?

 Include snippet of CQL query near error in SyntaxError messages
 ---

 Key: CASSANDRA-7111
 URL: https://issues.apache.org/jira/browse/CASSANDRA-7111
 Project: Cassandra
  Issue Type: Improvement
  Components: API, Tools
Reporter: Tyler Hobbs
Assignee: Benjamin Lerer
  Labels: cql
 Fix For: 2.1.1

 Attachments: CASSANDRA-7111-V2.txt, CASSANDRA-7111-V3.txt, 
 CASSANDRA-7111.txt


 When a SyntaxError is returned, including a snippet of the query close to the 
 error would make a lot of error messages easier to understand.  For example, 
 if you did this with the python driver:
 {code}
 session.execute(SELECT * FROM users WHERE username='%s', ['Joe Smith'])
 {code}
 you would wind up with an extra set of single quotes (the driver 
 automatically escapes and quotes input).  If a snippet like {{...WHERE 
 username=''Joe Smith''}} were included in the error message, this would be 
 pretty easy to spot.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (CASSANDRA-7111) Include snippet of CQL query near error in SyntaxError messages

2014-07-10 Thread Tyler Hobbs (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-7111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14058013#comment-14058013
 ] 

Tyler Hobbs commented on CASSANDRA-7111:


I should have noticed these in the first review, but a couple of additional 
changes:
* Since ErrorCollector is the only implementation of ErrorListener, I would 
prefer to just leave out the ErrorListener interface (unless you have plans to 
use it soon)
* For mock test classes like MockToken, you can leave out things like {{/\*\* 
\{\@inheritDoc\} \*/}} javadocs

There's also still a bit of trailing whitespace in ErrorCollector and Cql.g in 
the patch, and the unit tests need to be updated for the whitespace change.

 Include snippet of CQL query near error in SyntaxError messages
 ---

 Key: CASSANDRA-7111
 URL: https://issues.apache.org/jira/browse/CASSANDRA-7111
 Project: Cassandra
  Issue Type: Improvement
  Components: API, Tools
Reporter: Tyler Hobbs
Assignee: Benjamin Lerer
  Labels: cql
 Fix For: 2.1.1

 Attachments: CASSANDRA-7111-V2.txt, CASSANDRA-7111.txt


 When a SyntaxError is returned, including a snippet of the query close to the 
 error would make a lot of error messages easier to understand.  For example, 
 if you did this with the python driver:
 {code}
 session.execute(SELECT * FROM users WHERE username='%s', ['Joe Smith'])
 {code}
 you would wind up with an extra set of single quotes (the driver 
 automatically escapes and quotes input).  If a snippet like {{...WHERE 
 username=''Joe Smith''}} were included in the error message, this would be 
 pretty easy to spot.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (CASSANDRA-7111) Include snippet of CQL query near error in SyntaxError messages

2014-07-09 Thread Tyler Hobbs (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-7111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14056782#comment-14056782
 ] 

Tyler Hobbs commented on CASSANDRA-7111:


Overall, this looks great!

I have a few nitpicks:

 * It would be nice to add a space between the token and the snippet.  For 
example, between {{'ks'}} and {{(}} here: {{line 1:9 missing K_FROM at 
'ks'\(select * \[ks\]\;\)}}.
 * I think we can reasonably make {{FIRST_TOKEN_OFFSET}} 10 instead of 6
 * There are a few places where you don't put the opening curly brace on a 
newline (ErrorCollector ctor, insertChar(), lineIndex(), 
getSnippetLastTokenIndex(), getSnippetFirstTokenIndex(), ...)
 * Single line conditionals and loops don't need curlies 
(ErrorCollector.syntaxError(), appendSnippet(), throwLastSyntaxError())
 * There's quite a bit of trailing whitespace in the patch

 Include snippet of CQL query near error in SyntaxError messages
 ---

 Key: CASSANDRA-7111
 URL: https://issues.apache.org/jira/browse/CASSANDRA-7111
 Project: Cassandra
  Issue Type: Improvement
  Components: API, Tools
Reporter: Tyler Hobbs
Assignee: Benjamin Lerer
  Labels: cql
 Fix For: 2.1.1

 Attachments: CASSANDRA-7111.txt


 When a SyntaxError is returned, including a snippet of the query close to the 
 error would make a lot of error messages easier to understand.  For example, 
 if you did this with the python driver:
 {code}
 session.execute(SELECT * FROM users WHERE username='%s', ['Joe Smith'])
 {code}
 you would wind up with an extra set of single quotes (the driver 
 automatically escapes and quotes input).  If a snippet like {{...WHERE 
 username=''Joe Smith''}} were included in the error message, this would be 
 pretty easy to spot.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (CASSANDRA-7111) Include snippet of CQL query near error in SyntaxError messages

2014-04-30 Thread Tyler Hobbs (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-7111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13985705#comment-13985705
 ] 

Tyler Hobbs commented on CASSANDRA-7111:


The snippet could just be inserted into the normal message without breaking 
compatibility.  I don't think any of the drivers try to parse the message or 
anything like that.

 Include snippet of CQL query near error in SyntaxError messages
 ---

 Key: CASSANDRA-7111
 URL: https://issues.apache.org/jira/browse/CASSANDRA-7111
 Project: Cassandra
  Issue Type: Improvement
  Components: API, Tools
Reporter: Tyler Hobbs
Priority: Minor

 When a SyntaxError is returned, including a snippet of the query close to the 
 error would make a lot of error messages easier to understand.  For example, 
 if you did this with the python driver:
 {code}
 session.execute(SELECT * FROM users WHERE username='%s', ['Joe Smith'])
 {code}
 you would wind up with an extra set of single quotes (the driver 
 automatically escapes and quotes input).  If a snippet like {{...WHERE 
 username=''Joe Smith''}} were included in the error message, this would be 
 pretty easy to spot.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (CASSANDRA-7111) Include snippet of CQL query near error in SyntaxError messages

2014-04-30 Thread Sylvain Lebresne (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-7111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13985794#comment-13985794
 ] 

Sylvain Lebresne commented on CASSANDRA-7111:
-

Yeah, I don't think we've ever promised not changing error messages, and even 
those maverick drivers that do parse error message probably just pattern match 
part of the message, so adding this wouldn't break them probably. So I wouldn't 
mind doing this even in 2.0 if the patch is trivial, which I think it will. The 
convenience it might bring to most users outweighs the very remote risk of 
breaking 1 or 2 users imo.

 Include snippet of CQL query near error in SyntaxError messages
 ---

 Key: CASSANDRA-7111
 URL: https://issues.apache.org/jira/browse/CASSANDRA-7111
 Project: Cassandra
  Issue Type: Improvement
  Components: API, Tools
Reporter: Tyler Hobbs
 Fix For: 2.1 rc1


 When a SyntaxError is returned, including a snippet of the query close to the 
 error would make a lot of error messages easier to understand.  For example, 
 if you did this with the python driver:
 {code}
 session.execute(SELECT * FROM users WHERE username='%s', ['Joe Smith'])
 {code}
 you would wind up with an extra set of single quotes (the driver 
 automatically escapes and quotes input).  If a snippet like {{...WHERE 
 username=''Joe Smith''}} were included in the error message, this would be 
 pretty easy to spot.



--
This message was sent by Atlassian JIRA
(v6.2#6252)