Support request for multiple return types aka when len(results.List) > 1
Opened this issue · 2 comments
Line 129 in a744149
Hi @microo8 sorry to bothering you again could you add support for multiple return types. I thought I could make a PR but my go skills still need some work lol. BUT I've made my homework here is the AST on my package :
33 . . . Type: *ast.FuncType {
34 . . . . Func: returned-values.go:5:1
35 . . . . Params: *ast.FieldList {
36 . . . . . Opening: returned-values.go:5:7
37 . . . . . Closing: returned-values.go:5:8
38 . . . . }
39 . . . . Results: *ast.FieldList {
40 . . . . . Opening: returned-values.go:5:10
41 . . . . . List: []*ast.Field (len = 3) {
42 . . . . . . 0: *ast.Field {
43 . . . . . . . Type: *ast.ArrayType {
44 . . . . . . . . Lbrack: returned-values.go:5:11
45 . . . . . . . . Elt: *ast.Ident {
46 . . . . . . . . . NamePos: returned-values.go:5:13
47 . . . . . . . . . Name: "float64"
48 . . . . . . . . }
49 . . . . . . . }
50 . . . . . . }
51 . . . . . . 1: *ast.Field {
52 . . . . . . . Type: *ast.ArrayType {
53 . . . . . . . . Lbrack: returned-values.go:5:22
54 . . . . . . . . Elt: *ast.Ident {
55 . . . . . . . . . NamePos: returned-values.go:5:24
56 . . . . . . . . . Name: "float64"
57 . . . . . . . . }
58 . . . . . . . }
59 . . . . . . }
60 . . . . . . 2: *ast.Field {
61 . . . . . . . Type: *ast.ArrayType {
62 . . . . . . . . Lbrack: returned-values.go:5:33
63 . . . . . . . . Elt: *ast.Ident {
64 . . . . . . . . . NamePos: returned-values.go:5:35
65 . . . . . . . . . Name: "float64"
66 . . . . . . . . }
67 . . . . . . . }
68 . . . . . . }
69 . . . . . }
The results.List
must be just one. You are writing functions that are called from sql.
What do you expect to get when calling select E()
?
Well a possible solution could be :
- Composite types implemented like this in C in combination with Composite arguments to make a query like that
SELECT (E(inputed_floats)).outCA, (E(inputed_floats)).outB, (E(inputed_floats)).outC FROM some_table;
With my E func being slightly changed for the example :
func E(inA float64, inB float64, inC float64,) (outA []float64, outB []float64, outC []float64) {
return []float64{inA}, []float64{inB}, []float64{inC}
}
I expect the result to be like that :
outA | outB | outC
-----------+-------------+-----------
{inAvalue} | {inBvalue} | {inCvalue}
(1 row)
I guess we'll have to parse the returned values variable names for the composite types. Let me know what do you think of my proposal.