File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
"github.com/src-d/gitquery"
8
8
"github.com/src-d/gitquery/internal/format"
9
+ "github.com/src-d/gitquery/internal/function"
9
10
10
11
"gopkg.in/src-d/go-git.v4/utils/ioutil"
11
12
sqle "gopkg.in/src-d/go-mysql-server.v0"
@@ -38,7 +39,7 @@ func (c *cmdQueryBase) buildDatabase() error {
38
39
}
39
40
40
41
c .engine .AddDatabase (gitquery .NewDatabase (c .name , & pool ))
41
- return err
42
+ return function . Register ( c . engine . Catalog )
42
43
}
43
44
44
45
func (c * cmdQueryBase ) executeQuery (sql string ) (sql.Schema , sql.RowIter , error ) {
Original file line number Diff line number Diff line change
1
+ package function
2
+
3
+ import "gopkg.in/src-d/go-mysql-server.v0/sql"
4
+
5
+ var functions = map [string ]interface {}{
6
+ "is_tag" : NewIsTag ,
7
+ "is_remote" : NewIsRemote ,
8
+ }
9
+
10
+ // Register all the gitquery functions in the SQL catalog.
11
+ func Register (c * sql.Catalog ) error {
12
+ for k , v := range functions {
13
+ if err := c .RegisterFunction (k , v ); err != nil {
14
+ return err
15
+ }
16
+ }
17
+
18
+ return nil
19
+ }
Original file line number Diff line number Diff line change
1
+ package function
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/require"
7
+ "gopkg.in/src-d/go-mysql-server.v0/sql"
8
+ )
9
+
10
+ func TestRegister (t * testing.T ) {
11
+ require := require .New (t )
12
+ catalog := sql .NewCatalog ()
13
+ require .NoError (Register (catalog ))
14
+
15
+ for fn := range functions {
16
+ _ , err := catalog .Function (fn )
17
+ require .NoError (err , "expected to find function: %s" , fn )
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments