Added not reserved keyword. Works for both not in and not like - #68
Conversation
filhodanuvem
left a comment
There was a problem hiding this comment.
Awesome work @frahman5 🎉 .
I'm just waiting for @luizperes review and we can merge it.
| const T_ASC = 25 | ||
| const T_LIKE = 26 | ||
| const T_NOT = 27 | ||
| const T_NOT_OR_T_LIKE = 28 |
There was a problem hiding this comment.
Did your Idea actually was T_IN_OR_T_LIKE, isn't? I'm not too comfortable seeing a token that is used just for error messages. I prefer to suggest just one of the options (T_NOT) and maybe we can discuss better in another thread how to improve the parser error to show more then one expected tokens. What do you think?
There was a problem hiding this comment.
Yeah I wasn't too happy about that either. I didn't want to create an entirely different SyntaxError function though, so I squeezed in that token instead. I think you're right though. I'll change it to just suggest T_NOT for now, and we can leave the issue of leaving better parser errors for another day.
There was a problem hiding this comment.
Just letting you know I pushed another commit with this fix :)
| } | ||
| } | ||
|
|
||
| func TestWhereWithIn(t *testing.T) { |
There was a problem hiding this comment.
Wow, thanks a lot for that ❤️
| } | ||
|
|
||
| func TestWhereWithNotIn(t *testing.T) { | ||
| New("Select message from commits where 'react' not in message") |
| @@ -0,0 +1,8 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
Thank you for the change but you commit some IDE files :/ . Can you remove them?
filhodanuvem
left a comment
There was a problem hiding this comment.
Just because of the IDE files.
| T_IN: "T_IN", | ||
| T_EOF: "T_EOF", | ||
| T_ASC: "T_ASC", | ||
| T_NOT: "T_NOT", |
There was a problem hiding this comment.
are these extra spaces only on github? otherwise, could you align them?
luizperes
left a comment
There was a problem hiding this comment.
LGTM (except for the extra non-needed files)
|
@luizperes @cloudson I'll take care of those IDE files and space issues by tomorrow |
|
@luizperes @cloudson requested changes made. I've removed the IDE files and fixed the spacing on tokens. go :) |
|
Thank you again 🤘 |
|
👍 😃 |
|
I think this would close #49 |
|
Totally right @jsixface , thank you for the suggestion. |
The basic update I made is to add a "Not" field to the NodeIn and NodeLike types and update their assertion methods accordingly. The Not field acts as a flag telling the program whether to query with a normal In/Like or with a Not In/Not Like. If "Not" is set to true, then the assertion method returns the opposite of what it would return otherwise.
All the other changes just support the above structural update. I updated lexical to be able to process a "not" reserved keyword. And I updated the parser to be able to correctly read in the "not" and create the appropriate NodeIn and NodeLike objects. I also added some tests to parser_test.go to make sure that was all working.
I chose this route over the other route of creating entirely new NodeNotIn and NodeNotLike objects because:
Examples
A query with no where condition
A query with a where condition that excludes several of the authors you'd otherwise see
Using a not like to exclude any commits where the message begins with Add
@luizperes :)