Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast: fix return err value in Restore (#224) #226

Merged
merged 4 commits into from
Mar 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
ctx.WritePlain("/*+ ")
for i, tableHint := range n.TableHints {
if err := tableHint.Restore(ctx); err != nil {
errors.Annotatef(err, "An error occurred while restore SelectStmt.TableHints[%d]", i)
return errors.Annotatef(err, "An error occurred while restore SelectStmt.TableHints[%d]", i)
}
}
ctx.WritePlain("*/ ")
Expand All @@ -802,15 +802,15 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
ctx.WritePlain(",")
}
if err := field.Restore(ctx); err != nil {
errors.Annotatef(err, "An error occurred while restore SelectStmt.Fields[%d]", i)
return errors.Annotatef(err, "An error occurred while restore SelectStmt.Fields[%d]", i)
}
}
}

if n.From != nil {
ctx.WriteKeyWord(" FROM ")
if err := n.From.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.From")
return errors.Annotate(err, "An error occurred while restore SelectStmt.From")
}
}

Expand All @@ -820,21 +820,21 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
if n.Where != nil {
ctx.WriteKeyWord(" WHERE ")
if err := n.Where.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.Where")
return errors.Annotate(err, "An error occurred while restore SelectStmt.Where")
}
}

if n.GroupBy != nil {
ctx.WritePlain(" ")
if err := n.GroupBy.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.GroupBy")
return errors.Annotate(err, "An error occurred while restore SelectStmt.GroupBy")
}
}

if n.Having != nil {
ctx.WritePlain(" ")
if err := n.Having.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.Having")
return errors.Annotate(err, "An error occurred while restore SelectStmt.Having")
}
}

Expand All @@ -845,22 +845,22 @@ func (n *SelectStmt) Restore(ctx *RestoreCtx) error {
ctx.WritePlain(",")
}
if err := windowsSpec.Restore(ctx); err != nil {
errors.Annotatef(err, "An error occurred while restore SelectStmt.WindowSpec[%d]", i)
return errors.Annotatef(err, "An error occurred while restore SelectStmt.WindowSpec[%d]", i)
}
}
}

if n.OrderBy != nil {
ctx.WritePlain(" ")
if err := n.OrderBy.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.OrderBy")
return errors.Annotate(err, "An error occurred while restore SelectStmt.OrderBy")
}
}

if n.Limit != nil {
ctx.WritePlain(" ")
if err := n.Limit.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore SelectStmt.Limit")
return errors.Annotate(err, "An error occurred while restore SelectStmt.Limit")
}
}

Expand Down Expand Up @@ -982,7 +982,7 @@ func (n *UnionSelectList) Restore(ctx *RestoreCtx) error {
ctx.WritePlain("(")
}
if err := selectStmt.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore UnionSelectList.SelectStmt")
return errors.Annotate(err, "An error occurred while restore UnionSelectList.SelectStmt")
}
if selectStmt.IsInBraces {
ctx.WritePlain(")")
Expand Down Expand Up @@ -1022,20 +1022,20 @@ type UnionStmt struct {
// Restore implements Node interface.
func (n *UnionStmt) Restore(ctx *RestoreCtx) error {
if err := n.SelectList.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore UnionStmt.SelectList")
return errors.Annotate(err, "An error occurred while restore UnionStmt.SelectList")
}

if n.OrderBy != nil {
ctx.WritePlain(" ")
if err := n.OrderBy.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore UnionStmt.OrderBy")
return errors.Annotate(err, "An error occurred while restore UnionStmt.OrderBy")
}
}

if n.Limit != nil {
ctx.WritePlain(" ")
if err := n.Limit.Restore(ctx); err != nil {
errors.Annotate(err, "An error occurred while restore UnionStmt.Limit")
return errors.Annotate(err, "An error occurred while restore UnionStmt.Limit")
}
}
return nil
Expand Down