-
Notifications
You must be signed in to change notification settings - Fork 885
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
} | ||
if ref, ok := arg.(*ast.ColumnRef); ok { | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: What are the differences between |
||
} | ||
} | ||
} | ||
if !found { | ||
if firstColumn != nil { | ||
firstColumn.NotNull = shouldNotBeNull | ||
firstColumn.skipTableRequiredCheck = true | ||
cols = append(cols, firstColumn) | ||
} else { | ||
Comment on lines
+171
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}) | ||
} | ||
|
||
|
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.
There was a problem hiding this comment.
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
andColumnRef
?