Skip to content

Commit 34613d6

Browse files
committed
Merge master and keep both the FLOAT and empty-comment tests
2 parents 7183bb7 + 9d191a6 commit 34613d6

8 files changed

Lines changed: 57 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: '1.27.x'
18+
cache: false
19+
- run: go build ./...
20+
- run: make -B sql.go
21+
- run: git diff --exit-code -- sql.go
22+
- run: go vet ./...
23+
- run: go test -count=1 ./...

‎.travis.yml‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# limitations under the License.
1414

1515
MAKEFLAGS = -s
16+
GOYACC = go run golang.org/x/tools/cmd/goyacc@v0.0.0-20180926032708-9eb9690e392a
1617

1718
sql.go: sql.y
18-
goyacc -o sql.go sql.y
19+
$(GOYACC) -o sql.go sql.y
1920
gofmt -w sql.go
2021

2122
clean:

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Go package for parsing SQLite or SQL-92 queries.
44

5+
The module builds with Go 1.11 and later. Regenerating `sql.go` with
6+
`make -B sql.go` requires Go 1.17 or later for versioned `go run` support.
7+
The Makefile pins the generator that reproduces the committed parser byte
8+
for byte.
9+
510
## Notice
611

712
The backbone of this repo is extracted from [vitessio/vitess](https://github.com/vitessio/vitess).

‎comments.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ func ExtractMysqlComment(sql string) (version string, innerSQL string) {
170170
digitCount++
171171
return !unicode.IsDigit(c) || digitCount == 6
172172
})
173+
if endOfVersionIndex < 0 {
174+
return "", ""
175+
}
173176
version = sql[0:endOfVersionIndex]
174177
innerSQL = strings.TrimFunc(sql[endOfVersionIndex:], unicode.IsSpace)
175178

‎comments_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ func TestExtractMysqlComment(t *testing.T) {
216216
var testCases = []struct {
217217
input, outSQL, outVersion string
218218
}{{
219+
input: "/*!*/",
220+
}, {
221+
input: "/*!1234*/",
222+
}, {
219223
input: "/*!50708SET max_execution_time=5000 */",
220224
outSQL: "SET max_execution_time=5000",
221225
outVersion: "50708",
@@ -346,4 +350,3 @@ func TestExtractCommentDirectives(t *testing.T) {
346350
t.Errorf("d.IsSet(six) should be false")
347351
}
348352
}
349-

‎go.mod‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/CovenantSQL/sqlparser
2+
3+
go 1.11

‎parse_test.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,23 @@ func TestKeywords(t *testing.T) {
887887
}
888888
}
889889

890+
func TestEmptySpecialComments(t *testing.T) {
891+
for _, input := range []string{"select /*!*/ 1", "select /*!1234*/ 1"} {
892+
queries, statements, err := ParseMultiple(NewStringTokenizer(input))
893+
if err != nil {
894+
t.Errorf("ParseMultiple(%q): %v", input, err)
895+
continue
896+
}
897+
if len(queries) != 1 || queries[0] != input || len(statements) != 1 {
898+
t.Errorf("ParseMultiple(%q): unexpected result %v, %v", input, queries, statements)
899+
continue
900+
}
901+
if got := String(statements[0]); got != "select 1" {
902+
t.Errorf("ParseMultiple(%q) = %q, want select 1", input, got)
903+
}
904+
}
905+
}
906+
890907
func TestConvert(t *testing.T) {
891908
validSQL := []struct {
892909
input string

0 commit comments

Comments
 (0)