-
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
Changes from 2 commits
2e98e26
78ba3e8
4eb0cbe
dcb9122
824fedb
e9457dd
2006605
88581f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ const L_IN = "in" | |
const L_ASC = "asc" | ||
const L_DESC = "desc" | ||
const L_LIKE = "like" | ||
const L_NOT = "not" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. :) |
||
New("Select message from commits where 'react' in message") | ||
|
||
ast, err := AST() | ||
if err != nil { | ||
t.Errorf(err.Error()) | ||
return | ||
} | ||
|
||
selectNode := ast.Child.(*NodeSelect) | ||
w := selectNode.Where | ||
if w == nil { | ||
t.Errorf("should have where node") | ||
} | ||
|
||
if reflect.TypeOf(w) != reflect.TypeOf(new(NodeIn)) { | ||
t.Errorf("should be a NodeIn") | ||
} | ||
|
||
notBool := w.(*NodeIn).Not | ||
if notBool == true { | ||
t.Errorf("Not bool should be set to false") | ||
} | ||
|
||
lValue := w.LeftValue().(*NodeLiteral) | ||
rValue := w.RightValue().(*NodeId) | ||
if lValue.Value() != "react" { | ||
t.Errorf("LValue should be 'react'") | ||
} | ||
|
||
if rValue.Value() != "message" { | ||
t.Errorf("RValue should be 'message'") | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. lol |
||
|
||
ast, err := AST() | ||
if err != nil { | ||
t.Errorf(err.Error()) | ||
return | ||
} | ||
|
||
selectNode := ast.Child.(*NodeSelect) | ||
w := selectNode.Where | ||
if w == nil { | ||
t.Errorf("should have where node") | ||
} | ||
|
||
if reflect.TypeOf(w) != reflect.TypeOf(new(NodeIn)) { | ||
t.Errorf("should be a NodeIn") | ||
} | ||
|
||
notBool := w.(*NodeIn).Not | ||
if notBool == false { | ||
t.Errorf("Not bool should be set to true") | ||
} | ||
|
||
lValue := w.LeftValue().(*NodeLiteral) | ||
rValue := w.RightValue().(*NodeId) | ||
if lValue.Value() != "react" { | ||
t.Errorf("LValue should be 'react'") | ||
} | ||
|
||
if rValue.Value() != "message" { | ||
t.Errorf("RValue should be 'message'") | ||
} | ||
|
||
} | ||
|
||
func TestWhereWithLike(t *testing.T) { | ||
New("Select author, message from commits where message like '%B'") | ||
|
||
ast, err := AST() | ||
if err != nil { | ||
t.Errorf(err.Error()) | ||
return | ||
} | ||
|
||
selectNode := ast.Child.(*NodeSelect) | ||
w := selectNode.Where | ||
if w == nil { | ||
t.Errorf("should have where node") | ||
} | ||
|
||
if reflect.TypeOf(w) != reflect.TypeOf(new(NodeLike)) { | ||
t.Errorf("should be a NodeLike") | ||
} | ||
|
||
notBool := w.(*NodeLike).Not | ||
if notBool == true { | ||
t.Errorf("Not bool should be set to false") | ||
} | ||
|
||
lValue := w.LeftValue().(*NodeId) | ||
rValue := w.RightValue().(*NodeLiteral) | ||
if lValue.Value() != "message" { | ||
t.Errorf("LValue should be 'message'") | ||
} | ||
|
||
es := `Rvalue should be &B` | ||
if rValue.Value() != "%B" { | ||
t.Errorf(es) | ||
} | ||
|
||
} | ||
|
||
func TestWhereWithNotLike(t *testing.T) { | ||
New("Select author, message from commits where message not like '%B'") | ||
|
||
ast, err := AST() | ||
if err != nil { | ||
t.Errorf(err.Error()) | ||
return | ||
} | ||
|
||
selectNode := ast.Child.(*NodeSelect) | ||
w := selectNode.Where | ||
if w == nil { | ||
t.Errorf("should have where node") | ||
} | ||
|
||
if reflect.TypeOf(w) != reflect.TypeOf(new(NodeLike)) { | ||
t.Errorf("should be a NodeLike") | ||
} | ||
|
||
notBool := w.(*NodeLike).Not | ||
if notBool == false { | ||
t.Errorf("Not bool should be set to true") | ||
} | ||
|
||
lValue := w.LeftValue().(*NodeId) | ||
rValue := w.RightValue().(*NodeLiteral) | ||
if lValue.Value() != "message" { | ||
t.Errorf("LValue should be 'message'") | ||
} | ||
|
||
es := `Rvalue should be &B` | ||
if rValue.Value() != "%B" { | ||
t.Errorf(es) | ||
} | ||
|
||
} | ||
|
||
func TestWhereWithGreater(t *testing.T) { | ||
New("select * from commits where date > '2014-05-12 00:00:00' ") | ||
|
||
|
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?