Skip to content

Commit 64ebafe

Browse files
committed
[ga-format-pr] Run ./format_repo.sh to fix formatting
1 parent 5f71687 commit 64ebafe

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

enginetest/queries/query_plans.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sql/plan/str_expr.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plan
22

33
import (
44
"github.com/dolthub/go-mysql-server/sql"
5+
"github.com/dolthub/go-mysql-server/sql/expression"
56
"github.com/dolthub/go-mysql-server/sql/transform"
67
)
78

@@ -20,6 +21,14 @@ func AliasSubqueryString(e sql.Expression) string {
2021
if err != nil {
2122
panic(err)
2223
}
24+
25+
// String literal values are quoted when their String() method is called, so to avoid that, we
26+
// check if we're dealing with a string literal and use it's raw value if so.
27+
if literal, ok := e.(*expression.Literal); ok {
28+
if s, ok := literal.Value().(string); ok {
29+
return s
30+
}
31+
}
2332
return e.String()
2433
}
2534

sql/planbuilder/project.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ func selectExprNeedsAlias(e *ast.AliasedExpr, expr sql.Expression) bool {
242242
return true
243243
}
244244
})
245+
if complex {
246+
return true
247+
}
245248

246249
// If the expression's string representation is quoted, trim the quotes before comparing it to the input expression.
247250
// InputExpression is assigned in the Vitess layer, and it always trims quotes at that time, too.
@@ -250,7 +253,7 @@ func selectExprNeedsAlias(e *ast.AliasedExpr, expr sql.Expression) bool {
250253
exprString = exprString[1 : len(exprString)-1]
251254
}
252255

253-
// If the expression's input value matches expr.String(), then we know that it is referenceable and
254-
// does not need an alias.
255-
return complex || e.InputExpression != exprString
256+
// If the expression's input value does not match expr.String(), then we know that it is not
257+
// referenceable and will need an alias.
258+
return e.InputExpression != exprString
256259
}

sql/types/typecheck_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ package types
1717
import (
1818
"testing"
1919

20-
"github.com/dolthub/go-mysql-server/sql"
2120
"github.com/stretchr/testify/assert"
21+
22+
"github.com/dolthub/go-mysql-server/sql"
2223
)
2324

2425
func TestIsGeometry(t *testing.T) {

0 commit comments

Comments
 (0)