Skip to content

Commit f3cf734

Browse files
committed
Fix aliases usage on bblfsh client impl.
- Add aliases to supportedLanguages slice to check also alias names. - Make IsSupported to check lang names in lower case. - Update go-mysql-server to fix some nil handling errors. - Fix regression query that was using DISTINCT on aggregations giving wrong results. - Update minimal supported bblfsh version on documentation. Signed-off-by: Antonio Navarro Perez <[email protected]>
1 parent 044fcad commit f3cf734

File tree

9 files changed

+57
-26
lines changed

9 files changed

+57
-26
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ before_install:
2222
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90
2323

2424
before_script:
25-
- docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd
26-
- docker exec -it bblfshd bblfshctl driver install python bblfsh/python-driver
27-
- docker exec -it bblfshd bblfshctl driver install php bblfsh/php-driver
28-
- docker exec -it bblfshd bblfshctl driver install go bblfsh/go-driver
25+
- docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd:v2.14.0-drivers
2926
- go get -v github.com/go-sql-driver/mysql/...
3027
- go get gopkg.in/src-d/go-git-fixtures.v3/...
3128

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.21.0-beta3] - 2019-06-19
10+
11+
### Fixed
12+
13+
- bblfsh aliases are now handled correctly ([#728](https://github.com/src-d/gitbase/issues/728)).
14+
- sql: correctly handle nulls in SQL type conversion ([#753](https://github.com/src-d/go-mysql-server/pull/753))
15+
- sql/parse: error for unsupported distinct on aggregations ([#869](https://github.com/src-d/gitbase/issues/869))
16+
917
## [0.21.0-beta2] - 2019-06-18
1018

1119
### Added

_testdata/regression.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@
2323
ID: 'query04'
2424
Name: 'Top 10 repositories by contributor count (all branches)'
2525
Statements:
26-
- SELECT repository_id,contributor_count FROM (SELECT repository_id, COUNT(DISTINCT commit_author_email) AS contributor_count FROM commits GROUP BY repository_id) AS q ORDER BY contributor_count DESC LIMIT 10
26+
- >
27+
SELECT
28+
repository_id,
29+
COUNT(commit_author_email) as contributor_count
30+
FROM (
31+
SELECT DISTINCT
32+
repository_id,
33+
commit_author_email
34+
FROM commits
35+
) as q
36+
GROUP BY repository_id
37+
ORDER BY contributor_count DESC
38+
LIMIT 10
2739
-
2840
ID: 'query05'
2941
Name: 'Query all files from HEAD'

docs/using-gitbase/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
`gitbase` optional dependencies that should be running on your system if you're planning on using certain functionality.
66

7-
- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.10.0 (only if you're planning to use the `UAST` functionality provided in gitbase)
7+
- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.14.0 (only if you're planning to use the `UAST` functionality provided in gitbase)
88

99
## Installing gitbase
1010

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/src-d/enry/v2 v2.0.0
1717
github.com/src-d/go-git v4.7.0+incompatible
1818
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible
19-
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99
19+
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a
2020
github.com/stretchr/testify v1.3.0
2121
github.com/uber-go/atomic v1.4.0 // indirect
2222
github.com/uber/jaeger-client-go v2.16.0+incompatible

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlo
204204
github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk=
205205
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible h1:A5bKevhs9C//Nh8QV0J+1KphEaIa25cDe1DTs/yPxDI=
206206
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible/go.mod h1:XcIQp7L+k0pgfTqfbaTKj3kxlBv8kYOKZ/tKNXbZFLg=
207-
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99 h1:oZMn2HmQlDRHxWvyXRZnE9uUwUaVXVE/qrcvuFFDJ7s=
208-
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM=
207+
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a h1:tAgjKO6ynjJasm6wTSjmFJIf/lh/Rk3dPVCUnOXAWEQ=
208+
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM=
209209
github.com/src-d/go-oniguruma v1.0.0 h1:JDk5PUAjreGsGAKLsoDLNmrsaryjJ5RqT3h+Si6aw/E=
210210
github.com/src-d/go-oniguruma v1.0.0/go.mod h1:chVbff8kcVtmrhxtZ3yBVLLquXbzCS6DrxQaAK/CeqM=
211211
github.com/src-d/go-oniguruma v1.1.0 h1:EG+Nm5n2JqWUaCjtM0NtutPxU7ZN5Tp50GWrrV8bTww=

integration_test.go

+15-16
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515

1616
"github.com/src-d/gitbase"
1717
"github.com/src-d/gitbase/internal/function"
18-
"github.com/stretchr/testify/require"
1918
fixtures "github.com/src-d/go-git-fixtures"
20-
"gopkg.in/src-d/go-git.v4/plumbing/cache"
2119
sqle "github.com/src-d/go-mysql-server"
2220
"github.com/src-d/go-mysql-server/auth"
2321
"github.com/src-d/go-mysql-server/sql"
2422
"github.com/src-d/go-mysql-server/sql/analyzer"
2523
"github.com/src-d/go-mysql-server/sql/index/pilosa"
24+
"github.com/stretchr/testify/require"
25+
"gopkg.in/src-d/go-git.v4/plumbing/cache"
2626
)
2727

2828
func TestIntegration(t *testing.T) {
@@ -330,20 +330,20 @@ func TestIntegration(t *testing.T) {
330330
},
331331
{
332332
`
333-
SELECT
334-
repository_id,
335-
contributor_count
336-
FROM (
337-
SELECT
338-
repository_id,
339-
COUNT(DISTINCT commit_author_email) AS contributor_count
340-
FROM commits
341-
GROUP BY repository_id
342-
) AS q
343-
ORDER BY contributor_count DESC
344-
LIMIT 10
333+
SELECT
334+
repository_id,
335+
COUNT(commit_author_email) as contributor_count
336+
FROM (
337+
SELECT DISTINCT
338+
repository_id,
339+
commit_author_email
340+
FROM commits
341+
) as q
342+
GROUP BY repository_id
343+
ORDER BY contributor_count DESC
344+
LIMIT 10
345345
`,
346-
[]sql.Row{{"worktree", int64(9)}},
346+
[]sql.Row{{"worktree", int64(2)}},
347347
},
348348
{
349349
`SELECT cf.file_path
@@ -394,7 +394,6 @@ func TestIntegration(t *testing.T) {
394394
require.NoError(err)
395395
rows, err := sql.RowIterToRows(iter)
396396
require.NoError(err)
397-
398397
require.ElementsMatch(tt.result, rows)
399398
})
400399
}

session.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (c *BblfshClient) IsLanguageSupported(ctx context.Context, lang string) (bo
105105
}
106106

107107
for _, lng := range langs {
108-
if lng == strings.ToLower(lang) {
108+
if strings.ToLower(lng) == strings.ToLower(lang) {
109109
return true, nil
110110
}
111111
}
@@ -126,6 +126,7 @@ func (c *BblfshClient) SupportedLanguages(ctx context.Context) ([]string, error)
126126

127127
for _, dm := range driverManifests {
128128
c.supportedLanguages = append(c.supportedLanguages, dm.Language)
129+
c.supportedLanguages = append(c.supportedLanguages, dm.Aliases...)
129130
}
130131
}
131132

session_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gitbase
22

33
import (
4+
"context"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -17,6 +18,19 @@ func TestSessionBblfshClient(t *testing.T) {
1718
require.Equal(connectivity.Ready, cli.GetState())
1819
}
1920

21+
func TestSupportedLanguagesAliases(t *testing.T) {
22+
require := require.New(t)
23+
24+
session := NewSession(nil, WithBblfshEndpoint(defaultBblfshEndpoint))
25+
cli, err := session.BblfshClient()
26+
require.NoError(err)
27+
require.NotNil(cli)
28+
require.Equal(connectivity.Ready, cli.GetState())
29+
ok, err := cli.IsLanguageSupported(context.TODO(), "C++")
30+
require.NoError(err)
31+
require.True(ok)
32+
}
33+
2034
func TestSessionBblfshClientNoConnection(t *testing.T) {
2135
require := require.New(t)
2236

0 commit comments

Comments
 (0)