Skip to content

Commit 1848576

Browse files
committed
internal/function: make use of typed arity functions
Signed-off-by: Miguel Molina <[email protected]>
1 parent 12ee2a0 commit 1848576

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

cmd/gitquery/query_base.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func (c *cmdQueryBase) buildDatabase() error {
3939
}
4040

4141
c.engine.AddDatabase(gitquery.NewDatabase(c.name, &pool))
42-
return function.Register(c.engine.Catalog)
42+
function.Register(c.engine.Catalog)
43+
return nil
4344
}
4445

4546
func (c *cmdQueryBase) executeQuery(sql string) (sql.Schema, sql.RowIter, error) {

internal/function/is_remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type IsRemote struct {
1414
}
1515

1616
// NewIsRemote creates a new IsRemote function.
17-
func NewIsRemote(e sql.Expression) *IsRemote {
17+
func NewIsRemote(e sql.Expression) sql.Expression {
1818
return &IsRemote{expression.UnaryExpression{Child: e}}
1919
}
2020

internal/function/is_tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type IsTag struct {
1414
}
1515

1616
// NewIsTag creates a new IsTag function.
17-
func NewIsTag(e sql.Expression) *IsTag {
17+
func NewIsTag(e sql.Expression) sql.Expression {
1818
return &IsTag{expression.UnaryExpression{Child: e}}
1919
}
2020

internal/function/registry.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ package function
22

33
import "gopkg.in/src-d/go-mysql-server.v0/sql"
44

5-
var functions = map[string]interface{}{
6-
"is_tag": NewIsTag,
7-
"is_remote": NewIsRemote,
5+
var functions = map[string]sql.Function{
6+
"is_tag": sql.Function1(NewIsTag),
7+
"is_remote": sql.Function1(NewIsRemote),
88
}
99

1010
// Register all the gitquery functions in the SQL catalog.
11-
func Register(c *sql.Catalog) error {
11+
func Register(c *sql.Catalog) {
1212
for k, v := range functions {
13-
if err := c.RegisterFunction(k, v); err != nil {
14-
return err
15-
}
13+
c.RegisterFunction(k, v)
1614
}
17-
18-
return nil
1915
}

internal/function/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func TestRegister(t *testing.T) {
1111
require := require.New(t)
1212
catalog := sql.NewCatalog()
13-
require.NoError(Register(catalog))
13+
Register(catalog)
1414

1515
for fn := range functions {
1616
_, err := catalog.Function(fn)

0 commit comments

Comments
 (0)