While working on a solution for #364 which is based on SQL functions, I hit the following problem.
The Go methods generated from calls to SQL functions, that return SETOF, should return the correct DB model.
Same example as in #940.
Given the following definition for PostgreSQL:
CREATE TABLE foo (
            id     INTEGER,
            bar    varchar(100)
);
INSERT INTO foo VALUES (null, 'foo'), (1, 'bar');
CREATE OR REPLACE FUNCTION select1(_id INTEGER)
  RETURNS SETOF foo as
$func$
BEGIN
  IF _id IS NULL THEN
    RETURN QUERY EXECUTE 'select * from foo where id IS NULL';
  ELSE
    RETURN QUERY EXECUTE FORMAT('select * from foo where id = %L', _id);
  END IF;
END
$func$ LANGUAGE plpgsql CALLED ON NULL INPUT;and the query definition:
-- name: GetSelect1 :many
SELECT select1($1);
the following Go method signature is generated:
func (q *Queries) GetSelect1(ctx context.Context, ID int32) ([]interface{}, error) {This Go method does return []interface{} instead of []Foo from models.go.
Update: fix typo