Skip to content

Commit

Permalink
Fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuyuanp committed Aug 19, 2019
1 parent 0eb6d29 commit 6966a18
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion exp/window.go
Expand Up @@ -7,7 +7,7 @@ type sqlWindowExpression struct {
orderCols ColumnListExpression
}

func NewWindowExpression(window string, parent string, partitionCols, orderCols ColumnListExpression) WindowExpression {
func NewWindowExpression(window, parent string, partitionCols, orderCols ColumnListExpression) WindowExpression {
if partitionCols == nil {
partitionCols = NewColumnListExpression()
}
Expand Down
23 changes: 13 additions & 10 deletions sql_dialect.go
Expand Up @@ -529,7 +529,7 @@ func (d *sqlDialect) WindowSQL(b sb.SQLBuilder, we exp.WindowExpression, withNam
}
if withName {
name := we.Name()
if len(name) == 0 {
if name == "" {
b.SetError(errNoWindowName)
return
}
Expand Down Expand Up @@ -1209,15 +1209,18 @@ func (d *sqlDialect) sqlFunctionExpressionSQL(b sb.SQLBuilder, sqlFunc exp.SQLFu
b.WriteStrings(sqlFunc.Name())
d.Literal(b, sqlFunc.Args())

if sqlWinFunc, ok := sqlFunc.(exp.SQLWindowFunctionExpression); ok {
b.Write(d.dialectOptions.WindowOverFragment)
if sqlWinFunc.HasWindowName() {
d.Literal(b, I(sqlWinFunc.WindowName()))
} else if sqlWinFunc.HasWindow() {
d.WindowSQL(b, sqlWinFunc.Window(), false)
} else {
d.WindowSQL(b, emptyWindow, false)
}
sqlWinFunc, ok := sqlFunc.(exp.SQLWindowFunctionExpression)
if !ok {
return
}
b.Write(d.dialectOptions.WindowOverFragment)
switch {
case sqlWinFunc.HasWindowName():
d.Literal(b, I(sqlWinFunc.WindowName()))
case sqlWinFunc.HasWindow():
d.WindowSQL(b, sqlWinFunc.Window(), false)
default:
d.WindowSQL(b, emptyWindow, false)
}
}

Expand Down
1 change: 0 additions & 1 deletion sql_dialect_test.go
Expand Up @@ -1431,7 +1431,6 @@ func (dts *dialectTestSuite) TestWindowSQL() {

opts.SupportsWindowFunction = true
d = sqlDialect{dialect: "test", dialectOptions: opts}
b = sb.NewSQLBuilder(false)

b = sb.NewSQLBuilder(false)
anErr := errors.New("something wrong")
Expand Down

0 comments on commit 6966a18

Please sign in to comment.