Skip to content

fix: 🐛 Correctly switch coalesce() result .NotNull value #1664

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 13 additions & 7 deletions internal/compiler/output_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ func outputColumns(qc *QueryCatalog, node ast.Node) ([]*Column, error) {
if res.Name != nil {
name = *res.Name
}
var found bool
var firstColumn *Column
var shouldNotBeNull bool
for _, arg := range n.Args.Items {
if found {
if _, ok := arg.(*ast.A_Const); ok {
shouldNotBeNull = true
continue
}
Comment on lines +154 to 157
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is it sufficient that asserting only A_Const and ColumnRef?

if ref, ok := arg.(*ast.ColumnRef); ok {
Expand All @@ -159,14 +161,18 @@ func outputColumns(qc *QueryCatalog, node ast.Node) ([]*Column, error) {
return nil, err
}
for _, c := range columns {
found = true
c.NotNull = true
c.skipTableRequiredCheck = true
cols = append(cols, c)
if firstColumn == nil {
firstColumn = c
}
shouldNotBeNull = shouldNotBeNull || c.NotNull
Comment on lines +164 to +167
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: What are the differences between n.Args.Items and their inner columns?

}
}
}
if !found {
if firstColumn != nil {
firstColumn.NotNull = shouldNotBeNull
firstColumn.skipTableRequiredCheck = true
cols = append(cols, firstColumn)
} else {
Comment on lines +171 to +175
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is this really correct that using first column on this way?

cols = append(cols, &Column{Name: name, DataType: "any", NotNull: false})
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.