Skip to content
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
9 changes: 7 additions & 2 deletions internal/compiler/output_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,24 @@ func sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, error) {
var tables []*Table
for _, item := range list.Items {
switch n := item.(type) {

case *ast.FuncName:
// If the function or table can't be found, don't error out. There
// are many queries that depend on functions unknown to sqlc.
fn, err := qc.GetFunc(n)
if err != nil {
return nil, err
continue
}
table, err := qc.GetTable(&ast.TableName{
Catalog: fn.ReturnType.Catalog,
Schema: fn.ReturnType.Schema,
Name: fn.ReturnType.Name,
})
if err != nil {
return nil, err
continue
}
tables = append(tables, table)

case *ast.RangeSubselect:
cols, err := outputColumns(qc, n.Subquery)
if err != nil {
Expand Down Expand Up @@ -345,6 +349,7 @@ func sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, error) {
}
}
tables = append(tables, table)

default:
return nil, fmt.Errorf("sourceTable: unsupported list item type: %T", n)
}
Expand Down
35 changes: 35 additions & 0 deletions internal/endtoend/testdata/func_return/go/query.sql.go

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

5 changes: 5 additions & 0 deletions internal/endtoend/testdata/func_return/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
SELECT *
FROM users_func()
WHERE first_name != '';

/* name: GenerateSeries :many */
SELECT ($1::inet) + i
FROM generate_series(0, $2::int) AS i
LIMIT 1;