Skip to content

Commit 6c4f571

Browse files
committed
*: remove old uast serialization option
Signed-off-by: Manuel Carmona <[email protected]>
1 parent 5978e16 commit 6c4f571

File tree

5 files changed

+112
-259
lines changed

5 files changed

+112
-259
lines changed

cmd/gitbase/command/server.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ type Server struct {
5656
DisableGit bool `long:"no-git" description:"disable the load of git standard repositories."`
5757
DisableSiva bool `long:"no-siva" description:"disable the load of siva files."`
5858
Verbose bool `short:"v" description:"Activates the verbose mode"`
59-
OldUast bool `long:"old-uast-serialization" description:"serialize uast in the old format" env:"GITBASE_UAST_SERIALIZATION"`
6059
}
6160

6261
type jaegerLogrus struct {
@@ -157,17 +156,12 @@ func (c *Server) Execute(args []string) error {
157156
c.engine,
158157
gitbase.NewSessionBuilder(c.pool,
159158
gitbase.WithSkipGitErrors(c.SkipGitErrors),
160-
gitbase.WithOldUASTSerialization(c.OldUast),
161159
),
162160
)
163161
if err != nil {
164162
return err
165163
}
166164

167-
if c.OldUast {
168-
function.UASTExpressionType = sql.Array(sql.Blob)
169-
}
170-
171165
logrus.Infof("server started and listening on %s:%d", c.Host, c.Port)
172166
return s.Start()
173167
}

internal/function/uast.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ func init() {
3838
}
3939
}
4040

41-
var (
42-
// UASTExpressionType represents the returned SQL type by
43-
// the functions uast, uast_mode, uast_xpath and uast_children.
44-
UASTExpressionType sql.Type = sql.Blob
45-
)
46-
4741
// uastFunc shouldn't be used as an sql.Expression itself.
4842
// It's intended to be embedded in others UAST functions,
4943
// like UAST and UASTMode.
@@ -73,7 +67,7 @@ func (u *uastFunc) Resolved() bool {
7367

7468
// Type implements the Expression interface.
7569
func (u *uastFunc) Type() sql.Type {
76-
return UASTExpressionType
70+
return sql.Blob
7771
}
7872

7973
// Children implements the Expression interface.
@@ -236,7 +230,7 @@ func (u *uastFunc) getUAST(
236230
}
237231
}
238232

239-
return marshalNodes(ctx, nodes)
233+
return marshalNodes(nodes)
240234
}
241235

242236
// UAST returns an array of UAST nodes as blobs.
@@ -341,7 +335,7 @@ func NewUASTXPath(uast, xpath sql.Expression) sql.Expression {
341335

342336
// Type implements the Expression interface.
343337
func (UASTXPath) Type() sql.Type {
344-
return UASTExpressionType
338+
return sql.Blob
345339
}
346340

347341
// Eval implements the Expression interface.
@@ -360,7 +354,7 @@ func (f *UASTXPath) Eval(ctx *sql.Context, row sql.Row) (out interface{}, err er
360354
return nil, err
361355
}
362356

363-
nodes, err := getNodes(ctx, left)
357+
nodes, err := getNodes(left)
364358
if err != nil {
365359
return nil, err
366360
}
@@ -388,7 +382,7 @@ func (f *UASTXPath) Eval(ctx *sql.Context, row sql.Row) (out interface{}, err er
388382
filtered = append(filtered, ns...)
389383
}
390384

391-
return marshalNodes(ctx, filtered)
385+
return marshalNodes(filtered)
392386
}
393387

394388
func (f UASTXPath) String() string {
@@ -446,7 +440,7 @@ func (u *UASTExtract) Eval(ctx *sql.Context, row sql.Row) (out interface{}, err
446440
return nil, err
447441
}
448442

449-
nodes, err := getNodes(ctx, left)
443+
nodes, err := getNodes(left)
450444
if err != nil {
451445
return nil, err
452446
}
@@ -541,7 +535,7 @@ func (u *UASTChildren) String() string {
541535

542536
// Type implements the sql.Expression interface.
543537
func (u *UASTChildren) Type() sql.Type {
544-
return UASTExpressionType
538+
return sql.Blob
545539
}
546540

547541
// TransformUp implements the sql.Expression interface.
@@ -570,7 +564,7 @@ func (u *UASTChildren) Eval(ctx *sql.Context, row sql.Row) (out interface{}, err
570564
return nil, err
571565
}
572566

573-
nodes, err := getNodes(ctx, child)
567+
nodes, err := getNodes(child)
574568
if err != nil {
575569
return nil, err
576570
}
@@ -580,7 +574,7 @@ func (u *UASTChildren) Eval(ctx *sql.Context, row sql.Row) (out interface{}, err
580574
}
581575

582576
children := flattenChildren(nodes)
583-
return marshalNodes(ctx, children)
577+
return marshalNodes(children)
584578
}
585579

586580
func flattenChildren(nodes []*uast.Node) []*uast.Node {

0 commit comments

Comments
 (0)