Skip to content
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

Support request for multiple return types aka when len(results.List) > 1 #17

Open
sachaarbonel opened this issue Aug 23, 2018 · 2 comments

Comments

@sachaarbonel
Copy link
Contributor

if len(results.List) > 1 {

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  .  .  .  .  .  }
@microo8
Copy link
Owner

microo8 commented Aug 24, 2018

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()?

@sachaarbonel
Copy link
Contributor Author

Well a possible solution could be :

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants