@@ -85,6 +85,9 @@ type BetweenExpr struct {
85
85
86
86
// Restore implements Node interface.
87
87
func (n * BetweenExpr ) Restore (ctx * format.RestoreCtx ) error {
88
+ if ctx .Flags .HasRestoreBracketAroundBetweenExpr () {
89
+ ctx .WritePlain ("(" )
90
+ }
88
91
if err := n .Expr .Restore (ctx ); err != nil {
89
92
return errors .Annotate (err , "An error occurred while restore BetweenExpr.Expr" )
90
93
}
@@ -100,6 +103,9 @@ func (n *BetweenExpr) Restore(ctx *format.RestoreCtx) error {
100
103
if err := n .Right .Restore (ctx ); err != nil {
101
104
return errors .Annotate (err , "An error occurred while restore BetweenExpr.Right " )
102
105
}
106
+ if ctx .Flags .HasRestoreBracketAroundBetweenExpr () {
107
+ ctx .WritePlain (")" )
108
+ }
103
109
return nil
104
110
}
105
111
@@ -175,6 +181,8 @@ func (n *BinaryOperationExpr) Restore(ctx *format.RestoreCtx) error {
175
181
if ctx .Flags .HasRestoreBracketAroundBinaryOperation () {
176
182
ctx .WritePlain ("(" )
177
183
}
184
+ originalFlags := ctx .Flags
185
+ ctx .Flags |= format .RestoreBracketAroundBetweenExpr
178
186
if err := n .L .Restore (ctx ); err != nil {
179
187
return errors .Annotate (err , "An error occurred when restore BinaryOperationExpr.L" )
180
188
}
@@ -184,6 +192,7 @@ func (n *BinaryOperationExpr) Restore(ctx *format.RestoreCtx) error {
184
192
if err := n .R .Restore (ctx ); err != nil {
185
193
return errors .Annotate (err , "An error occurred when restore BinaryOperationExpr.R" )
186
194
}
195
+ ctx .Flags = originalFlags
187
196
if ctx .Flags .HasRestoreBracketAroundBinaryOperation () {
188
197
ctx .WritePlain (")" )
189
198
}
0 commit comments