Skip to content

Commit

Permalink
fix: Fix bug signature help
Browse files Browse the repository at this point in the history
  • Loading branch information
lighttiger2505 committed Mar 19, 2021
1 parent 552c79a commit 0546a76
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/handler/signature_help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type signatureHelpTestCase struct {

var signatureHelpTestCases = []signatureHelpTestCase{
// single record
// input is "insert into city (ID, Name, CountryCode) VALUES (123, 'aaa', '2020')"
// input is "insert into city (ID, Name, CountryCode) VALUES (123, NULL, '2020')"
genSingleRecordInsertTest(50, 0),
genSingleRecordInsertTest(52, 0),
genSingleRecordInsertTest(53, 1),
Expand Down Expand Up @@ -48,7 +48,7 @@ var signatureHelpTestCases = []signatureHelpTestCase{
func genSingleRecordInsertTest(col int, wantActiveParameter int) signatureHelpTestCase {
return signatureHelpTestCase{
name: fmt.Sprintf("single record %d-%d", col, wantActiveParameter),
input: "insert into city (ID, Name, CountryCode) VALUES (123, 'aaa', '2020')",
input: "insert into city (ID, Name, CountryCode) VALUES (123, NULL, '2020')",
line: 0,
col: col,
want: lsp.SignatureHelp{
Expand Down
3 changes: 3 additions & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ var identifierListTargetMatcher = astutil.NodeMatcher{
ast.TypeOperator,
ast.TypeSwitchCase,
},
ExpectKeyword: []string{
"NULL",
},
}

func parseIdentifierList(reader *astutil.NodeReader) ast.Node {
Expand Down
9 changes: 9 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,15 @@ func TestParseIdentifierList(t *testing.T) {
testIdentifierList(t, list[0], input)
},
},
{
name: "with null",
input: "foo, null, foobar",
checkFn: func(t *testing.T, stmts []*ast.Statement, input string) {
testStatement(t, stmts[0], 1, input)
list := stmts[0].GetTokens()
testIdentifierList(t, list[0], input)
},
},
{
name: "invalid single identifer without whitespace",
input: "foo,",
Expand Down

0 comments on commit 0546a76

Please sign in to comment.