File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -53,10 +53,11 @@ const (
5353func Preview (sql string ) int {
5454 trimmed := StripLeadingComments (sql )
5555
56- firstWord := strings . TrimLeftFunc ( trimmed , func ( r rune ) bool { return ! unicode . IsLetter ( r ) })
57- if end := strings .IndexFunc (firstWord , unicode .IsSpace ); end != - 1 {
58- firstWord = firstWord [:end ]
56+ firstWord := trimmed
57+ if end := strings .IndexFunc (trimmed , unicode .IsSpace ); end != - 1 {
58+ firstWord = trimmed [:end ]
5959 }
60+ firstWord = strings .TrimLeftFunc (firstWord , func (r rune ) bool { return ! unicode .IsLetter (r ) })
6061 // Comparison is done in order of priority.
6162 loweredFirstWord := strings .ToLower (firstWord )
6263 switch loweredFirstWord {
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ func TestPreview(t *testing.T) {
7070 {"unknown" , StmtUnknown },
7171
7272 {"/* leading comment */ select ..." , StmtSelect },
73+ {"/* leading comment */ (select ..." , StmtSelect },
7374 {"/* leading comment */ /* leading comment 2 */ select ..." , StmtSelect },
7475 {"/*! MySQL-specific comment */" , StmtComment },
7576 {"/*!50708 MySQL-version comment */" , StmtComment },
You can’t perform that action at this time.
0 commit comments