From f3cf734123c44b01093f967526aff17ef46d4ce3 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 19 Jun 2019 13:19:11 +0200 Subject: [PATCH 1/3] 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 --- .travis.yml | 5 +---- CHANGELOG.md | 8 +++++++ _testdata/regression.yml | 14 +++++++++++- docs/using-gitbase/getting-started.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- integration_test.go | 31 +++++++++++++-------------- session.go | 3 ++- session_test.go | 14 ++++++++++++ 9 files changed, 57 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 02d6be5a1..2c99676b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,7 @@ before_install: - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90 before_script: - - docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd - - docker exec -it bblfshd bblfshctl driver install python bblfsh/python-driver - - docker exec -it bblfshd bblfshctl driver install php bblfsh/php-driver - - docker exec -it bblfshd bblfshctl driver install go bblfsh/go-driver + - docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd:v2.14.0-drivers - go get -v github.com/go-sql-driver/mysql/... - go get gopkg.in/src-d/go-git-fixtures.v3/... diff --git a/CHANGELOG.md b/CHANGELOG.md index bab0b51b3..e6bd33e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.21.0-beta3] - 2019-06-19 + +### Fixed + +- bblfsh aliases are now handled correctly ([#728](https://github.com/src-d/gitbase/issues/728)). +- sql: correctly handle nulls in SQL type conversion ([#753](https://github.com/src-d/go-mysql-server/pull/753)) +- sql/parse: error for unsupported distinct on aggregations ([#869](https://github.com/src-d/gitbase/issues/869)) + ## [0.21.0-beta2] - 2019-06-18 ### Added diff --git a/_testdata/regression.yml b/_testdata/regression.yml index 2ebc9235c..aba5aa71e 100644 --- a/_testdata/regression.yml +++ b/_testdata/regression.yml @@ -23,7 +23,19 @@ ID: 'query04' Name: 'Top 10 repositories by contributor count (all branches)' Statements: - - 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 + - > + SELECT + repository_id, + COUNT(commit_author_email) as contributor_count + FROM ( + SELECT DISTINCT + repository_id, + commit_author_email + FROM commits + ) as q + GROUP BY repository_id + ORDER BY contributor_count DESC + LIMIT 10 - ID: 'query05' Name: 'Query all files from HEAD' diff --git a/docs/using-gitbase/getting-started.md b/docs/using-gitbase/getting-started.md index 960a235df..502415e99 100644 --- a/docs/using-gitbase/getting-started.md +++ b/docs/using-gitbase/getting-started.md @@ -4,7 +4,7 @@ `gitbase` optional dependencies that should be running on your system if you're planning on using certain functionality. -- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.10.0 (only if you're planning to use the `UAST` functionality provided in gitbase) +- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.14.0 (only if you're planning to use the `UAST` functionality provided in gitbase) ## Installing gitbase diff --git a/go.mod b/go.mod index 1bb2fd948..3f8967af3 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/src-d/enry/v2 v2.0.0 github.com/src-d/go-git v4.7.0+incompatible github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible - github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99 + github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a github.com/stretchr/testify v1.3.0 github.com/uber-go/atomic v1.4.0 // indirect github.com/uber/jaeger-client-go v2.16.0+incompatible diff --git a/go.sum b/go.sum index 40c8b2870..95cb9e354 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlo github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk= github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible h1:A5bKevhs9C//Nh8QV0J+1KphEaIa25cDe1DTs/yPxDI= github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible/go.mod h1:XcIQp7L+k0pgfTqfbaTKj3kxlBv8kYOKZ/tKNXbZFLg= -github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99 h1:oZMn2HmQlDRHxWvyXRZnE9uUwUaVXVE/qrcvuFFDJ7s= -github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM= +github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a h1:tAgjKO6ynjJasm6wTSjmFJIf/lh/Rk3dPVCUnOXAWEQ= +github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM= github.com/src-d/go-oniguruma v1.0.0 h1:JDk5PUAjreGsGAKLsoDLNmrsaryjJ5RqT3h+Si6aw/E= github.com/src-d/go-oniguruma v1.0.0/go.mod h1:chVbff8kcVtmrhxtZ3yBVLLquXbzCS6DrxQaAK/CeqM= github.com/src-d/go-oniguruma v1.1.0 h1:EG+Nm5n2JqWUaCjtM0NtutPxU7ZN5Tp50GWrrV8bTww= diff --git a/integration_test.go b/integration_test.go index 79c65adf3..a4b121d2f 100644 --- a/integration_test.go +++ b/integration_test.go @@ -15,14 +15,14 @@ import ( "github.com/src-d/gitbase" "github.com/src-d/gitbase/internal/function" - "github.com/stretchr/testify/require" fixtures "github.com/src-d/go-git-fixtures" - "gopkg.in/src-d/go-git.v4/plumbing/cache" sqle "github.com/src-d/go-mysql-server" "github.com/src-d/go-mysql-server/auth" "github.com/src-d/go-mysql-server/sql" "github.com/src-d/go-mysql-server/sql/analyzer" "github.com/src-d/go-mysql-server/sql/index/pilosa" + "github.com/stretchr/testify/require" + "gopkg.in/src-d/go-git.v4/plumbing/cache" ) func TestIntegration(t *testing.T) { @@ -330,20 +330,20 @@ func TestIntegration(t *testing.T) { }, { ` - 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 + SELECT + repository_id, + COUNT(commit_author_email) as contributor_count + FROM ( + SELECT DISTINCT + repository_id, + commit_author_email + FROM commits + ) as q + GROUP BY repository_id + ORDER BY contributor_count DESC + LIMIT 10 `, - []sql.Row{{"worktree", int64(9)}}, + []sql.Row{{"worktree", int64(2)}}, }, { `SELECT cf.file_path @@ -394,7 +394,6 @@ func TestIntegration(t *testing.T) { require.NoError(err) rows, err := sql.RowIterToRows(iter) require.NoError(err) - require.ElementsMatch(tt.result, rows) }) } diff --git a/session.go b/session.go index fd330d4f3..dfd3921aa 100644 --- a/session.go +++ b/session.go @@ -105,7 +105,7 @@ func (c *BblfshClient) IsLanguageSupported(ctx context.Context, lang string) (bo } for _, lng := range langs { - if lng == strings.ToLower(lang) { + if strings.ToLower(lng) == strings.ToLower(lang) { return true, nil } } @@ -126,6 +126,7 @@ func (c *BblfshClient) SupportedLanguages(ctx context.Context) ([]string, error) for _, dm := range driverManifests { c.supportedLanguages = append(c.supportedLanguages, dm.Language) + c.supportedLanguages = append(c.supportedLanguages, dm.Aliases...) } } diff --git a/session_test.go b/session_test.go index 99ea7ab18..64114f776 100644 --- a/session_test.go +++ b/session_test.go @@ -1,6 +1,7 @@ package gitbase import ( + "context" "testing" "github.com/stretchr/testify/require" @@ -17,6 +18,19 @@ func TestSessionBblfshClient(t *testing.T) { require.Equal(connectivity.Ready, cli.GetState()) } +func TestSupportedLanguagesAliases(t *testing.T) { + require := require.New(t) + + session := NewSession(nil, WithBblfshEndpoint(defaultBblfshEndpoint)) + cli, err := session.BblfshClient() + require.NoError(err) + require.NotNil(cli) + require.Equal(connectivity.Ready, cli.GetState()) + ok, err := cli.IsLanguageSupported(context.TODO(), "C++") + require.NoError(err) + require.True(ok) +} + func TestSessionBblfshClientNoConnection(t *testing.T) { require := require.New(t) From c9df82c3b7da30c569571fdccc2484a1393c3e94 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 19 Jun 2019 17:01:49 +0200 Subject: [PATCH 2/3] Get list of installed drivers Signed-off-by: Antonio Navarro Perez --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2c99676b1..97f1445a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ before_install: before_script: - docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd:v2.14.0-drivers + - docker exec -it bblfshd bblfshctl driver list - go get -v github.com/go-sql-driver/mysql/... - go get gopkg.in/src-d/go-git-fixtures.v3/... From 49b8e34393534c53dc632b03d1950c22d16cb3cb Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 19 Jun 2019 17:13:01 +0200 Subject: [PATCH 3/3] Remove mount on bblfshd container Signed-off-by: Antonio Navarro Perez --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 97f1445a8..6c8676512 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_install: - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90 before_script: - - docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd:v2.14.0-drivers + - docker run -d --name bblfshd --privileged -p 9432:9432 bblfsh/bblfshd:v2.14.0-drivers - docker exec -it bblfshd bblfshctl driver list - go get -v github.com/go-sql-driver/mysql/... - go get gopkg.in/src-d/go-git-fixtures.v3/...