-
Notifications
You must be signed in to change notification settings - Fork 163
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
Added not reserved keyword. Works for both not in and not like #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @frahman5 🎉 .
I'm just waiting for @luizperes review and we can merge it.
lexical/tokens.go
Outdated
@@ -26,6 +26,8 @@ const T_PARENTH_R = 23 | |||
const T_IN = 24 | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just letting you know I pushed another commit with this fix :)
@@ -230,6 +230,154 @@ func TestWhereWithNotEqualCompare(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestWhereWithIn(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, thanks a lot for that ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
} | ||
|
||
func TestWhereWithNotIn(t *testing.T) { | ||
New("Select message from commits where 'react' not in message") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vue forever (?) 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
.idea/gitql.iml
Outdated
@@ -0,0 +1,8 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the change but you commit some IDE files :/ . Can you remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because of the IDE files.
lexical/tokens.go
Outdated
@@ -58,6 +59,7 @@ func allocMapTokenNames() { | |||
T_IN: "T_IN", | |||
T_EOF: "T_EOF", | |||
T_ASC: "T_ASC", | |||
T_NOT: "T_NOT", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these extra spaces only on github? otherwise, could you align them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this PR @frahman5! It looks neat!
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 :)