| 1 | package rethinkdbscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ |
| 2 | |
| 3 | import ( |
| 4 | "reflectscip-go gomod github.com/golang/go/src go1.14 reflect/" |
| 5 | "strconvscip-go gomod github.com/golang/go/src go1.14 strconv/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.14 strings/" |
| 7 | "sync/atomicscip-go gomod github.com/golang/go/src go1.14 `sync/atomic`/" |
| 8 | |
| 9 | "gopkg.in/rethinkdb/rethinkdb-go.v6/encodingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/" |
| 10 | pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/ "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2scip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/" |
| 11 | ) |
| 12 | |
| 13 | // Helper functions for constructing terms |
| 14 | |
| 15 | // constructRootTerm is an alias for creating a new term. |
| 16 | func constructRootTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructRootTerm().(name string, termType pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_TermTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_TermType#, args []interface{}, optArgs map[string]interface{}) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 17 | return Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#{ |
| 18 | namescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#name.: name, |
| 19 | rootTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#rootTerm.: true, |
| 20 | termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType.: termType, |
| 21 | argsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#args.: convertTermListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermList().(args), |
| 22 | optArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#optArgs.: convertTermObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermObj().(optArgs), |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // constructMethodTerm is an alias for creating a new term. Unlike constructRootTerm |
| 27 | // this function adds the previous expression in the tree to the argument list to |
| 28 | // create a method term. |
| 29 | func constructMethodTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructMethodTerm().(prevVal Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#, name string, termType pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_TermTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_TermType#, args []interface{}, optArgs map[string]interface{}) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 30 | args = append([]interface{}{prevVal}, args...) |
| 31 | |
| 32 | return Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#{ |
| 33 | namescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#name.: name, |
| 34 | rootTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#rootTerm.: false, |
| 35 | termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType.: termType, |
| 36 | argsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#args.: convertTermListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermList().(args), |
| 37 | optArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#optArgs.: convertTermObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermObj().(optArgs), |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // Helper functions for creating internal RQL types |
| 42 | |
| 43 | func newQueryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/newQuery().(t Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#, qopts map[string]interface{}, copts *ConnectOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts#) (q Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#, err error) { |
| 44 | queryOpts := map[string]interface{}{} |
| 45 | for k, v := range qopts { |
| 46 | queryOpts[k], err = Exprscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Expr().(v).Buildscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Build().() |
| 47 | if err != nil { |
| 48 | return |
| 49 | } |
| 50 | } |
| 51 | if copts.Databasescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts#Database. != "" { |
| 52 | queryOpts["db"], err = DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().(copts.Databasescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts#Database.).Buildscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Build().() |
| 53 | if err != nil { |
| 54 | return |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | builtTerm, err := t.Buildscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Build().() |
| 59 | if err != nil { |
| 60 | return q, err |
| 61 | } |
| 62 | |
| 63 | // Construct query |
| 64 | return Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#{ |
| 65 | Typescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#Type.: pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Query_STARTscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Query_START., |
| 66 | Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#Term.: &t, |
| 67 | Optsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#Opts.: queryOpts, |
| 68 | builtTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#builtTerm.: builtTerm, |
| 69 | }, nil |
| 70 | } |
| 71 | |
| 72 | // makeArray takes a slice of terms and produces a single MAKE_ARRAY term |
| 73 | func makeArrayscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/makeArray().(args termsListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsList#) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 74 | return Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#{ |
| 75 | namescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#name.: "[...]", |
| 76 | termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType.: pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_MAKE_ARRAYscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_MAKE_ARRAY., |
| 77 | argsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#args.: args, |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // makeObject takes a map of terms and produces a single MAKE_OBJECT term |
| 82 | func makeObjectscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/makeObject().(args termsObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsObj#) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 83 | return Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#{ |
| 84 | namescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#name.: "{...}", |
| 85 | termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType.: pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_MAKE_OBJscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_MAKE_OBJ., |
| 86 | optArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#optArgs.: args, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | var nextVarIDscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/nextVarID. int64 |
| 91 | |
| 92 | func makeFuncscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/makeFunc().(f interface{}) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 93 | value := reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.14 reflect/ValueOf().(f) |
| 94 | valueType := value.Typescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Type().() |
| 95 | |
| 96 | var argNums = make([]interface{}, valueType.NumInscip-go gomod github.com/golang/go/src go1.14 reflect/Type#NumIn().()) |
| 97 | var args = make([]reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Valuescip-go gomod github.com/golang/go/src go1.14 reflect/Value#, valueType.NumInscip-go gomod github.com/golang/go/src go1.14 reflect/Type#NumIn().()) |
| 98 | for i := 0; i < valueType.NumInscip-go gomod github.com/golang/go/src go1.14 reflect/Type#NumIn().(); i++ { |
| 99 | // Get a slice of the VARs to use as the function arguments |
| 100 | varID := atomicscip-go gomod github.com/golang/go/src go1.14 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.14 `sync/atomic`/AddInt64().(&nextVarIDscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/nextVarID., 1) |
| 101 | args[i] = reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.14 reflect/ValueOf().(constructRootTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructRootTerm().("var", pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_VARscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_VAR., []interface{}{varID}, map[string]interface{}{})) |
| 102 | argNums[i] = varID |
| 103 | |
| 104 | // make sure all input arguments are of type Term |
| 105 | argValueTypeName := valueType.Inscip-go gomod github.com/golang/go/src go1.14 reflect/Type#In().(i).Stringscip-go gomod github.com/golang/go/src go1.14 reflect/Type#String().() |
| 106 | if argValueTypeName != "rethinkdb.Term" && argValueTypeName != "interface {}" { |
| 107 | panic("Function argument is not of type Term or interface {}") |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | if valueType.NumOutscip-go gomod github.com/golang/go/src go1.14 reflect/Type#NumOut().() != 1 { |
| 112 | panic("Function does not have a single return value") |
| 113 | } |
| 114 | |
| 115 | body := value.Callscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Call().(args)[0].Interfacescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Interface().() |
| 116 | argsArr := makeArrayscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/makeArray().(convertTermListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermList().(argNums)) |
| 117 | |
| 118 | return constructRootTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructRootTerm().("func", pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_FUNCscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_FUNC., []interface{}{argsArr, body}, map[string]interface{}{}) |
| 119 | } |
| 120 | |
| 121 | func funcWrapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/funcWrap().(value interface{}) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 122 | val := Exprscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Expr().(value) |
| 123 | |
| 124 | if implVarScanscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/implVarScan().(val) && val.termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType. != pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_ARGSscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_ARGS. { |
| 125 | return makeFuncscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/makeFunc().(func(x Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 126 | return val |
| 127 | }) |
| 128 | } |
| 129 | return val |
| 130 | } |
| 131 | |
| 132 | func funcWrapArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/funcWrapArgs().(args []interface{}) []interface{} { |
| 133 | for i, arg := range args { |
| 134 | args[i] = funcWrapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/funcWrap().(arg) |
| 135 | } |
| 136 | |
| 137 | return args |
| 138 | } |
| 139 | |
| 140 | // implVarScan recursivly checks a value to see if it contains an |
| 141 | // IMPLICIT_VAR term. If it does it returns true |
| 142 | func implVarScanscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/implVarScan().(value Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) bool { |
| 143 | if value.termTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#termType. == pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_IMPLICIT_VARscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_IMPLICIT_VAR. { |
| 144 | return true |
| 145 | } |
| 146 | for _, v := range value.argsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#args. { |
| 147 | if implVarScanscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/implVarScan().(v) { |
| 148 | return true |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | for _, v := range value.optArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#optArgs. { |
| 153 | if implVarScanscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/implVarScan().(v) { |
| 154 | return true |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return false |
| 159 | } |
| 160 | |
| 161 | // Convert an opt args struct to a map. |
| 162 | func optArgsToMapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/optArgsToMap().(optArgs OptArgsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OptArgs#) map[string]interface{} { |
| 163 | data, err := encodescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/encode().(optArgs) |
| 164 | |
| 165 | if err == nil && data != nil { |
| 166 | if m, ok := data.(map[string]interface{}); ok { |
| 167 | return m |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | return map[string]interface{}{} |
| 172 | } |
| 173 | |
| 174 | // Convert a list into a slice of terms |
| 175 | func convertTermListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermList().(l []interface{}) termsListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsList# { |
| 176 | if len(l) == 0 { |
| 177 | return nil |
| 178 | } |
| 179 | |
| 180 | terms := make(termsListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsList#, len(l)) |
| 181 | for i, v := range l { |
| 182 | terms[i] = Exprscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Expr().(v) |
| 183 | } |
| 184 | |
| 185 | return terms |
| 186 | } |
| 187 | |
| 188 | // Convert a map into a map of terms |
| 189 | func convertTermObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/convertTermObj().(o map[string]interface{}) termsObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsObj# { |
| 190 | if len(o) == 0 { |
| 191 | return nil |
| 192 | } |
| 193 | |
| 194 | terms := make(termsObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsObj#, len(o)) |
| 195 | for k, v := range o { |
| 196 | terms[k] = Exprscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Expr().(v) |
| 197 | } |
| 198 | |
| 199 | return terms |
| 200 | } |
| 201 | |
| 202 | // Helper functions for debugging |
| 203 | |
| 204 | func allArgsToStringSlicescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/allArgsToStringSlice().(args termsListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsList#, optArgs termsObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsObj#) []string { |
| 205 | allArgs := make([]string, len(args)+len(optArgs)) |
| 206 | i := 0 |
| 207 | |
| 208 | for _, v := range args { |
| 209 | allArgs[i] = v.Stringscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#String().() |
| 210 | i++ |
| 211 | } |
| 212 | for k, v := range optArgs { |
| 213 | allArgs[i] = k + "=" + v.Stringscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#String().() |
| 214 | i++ |
| 215 | } |
| 216 | |
| 217 | return allArgs |
| 218 | } |
| 219 | |
| 220 | func argsToStringSlicescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/argsToStringSlice().(args termsListscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsList#) []string { |
| 221 | allArgs := make([]string, len(args)) |
| 222 | |
| 223 | for i, v := range args { |
| 224 | allArgs[i] = v.Stringscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#String().() |
| 225 | } |
| 226 | |
| 227 | return allArgs |
| 228 | } |
| 229 | |
| 230 | func optArgsToStringSlicescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/optArgsToStringSlice().(optArgs termsObjscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/termsObj#) []string { |
| 231 | allArgs := make([]string, len(optArgs)) |
| 232 | i := 0 |
| 233 | |
| 234 | for k, v := range optArgs { |
| 235 | allArgs[i] = k + "=" + v.Stringscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#String().() |
| 236 | i++ |
| 237 | } |
| 238 | |
| 239 | return allArgs |
| 240 | } |
| 241 | |
| 242 | func splitAddressscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/splitAddress().(address string) (hostname string, port int) { |
| 243 | hostname = "localhost" |
| 244 | port = 28015 |
| 245 | |
| 246 | addrParts := stringsscip-go gomod github.com/golang/go/src go1.14 strings/.Splitscip-go gomod github.com/golang/go/src go1.14 strings/Split().(address, ":") |
| 247 | |
| 248 | if len(addrParts) >= 1 { |
| 249 | hostname = addrParts[0] |
| 250 | } |
| 251 | if len(addrParts) >= 2 { |
| 252 | port, _ = strconvscip-go gomod github.com/golang/go/src go1.14 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.14 strconv/Atoi().(addrParts[1]) |
| 253 | } |
| 254 | |
| 255 | return |
| 256 | } |
| 257 | |
| 258 | func encodescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/encode().(data interface{}) (interface{}, error) { |
| 259 | if _, ok := data.(Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#); ok { |
| 260 | return data, nil |
| 261 | } |
| 262 | |
| 263 | v, err := encodingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/.Encodescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/Encode().(data) |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | |
| 268 | return v, nil |
| 269 | } |
| 270 | |
| 271 | // shouldRetryQuery checks the result of a query and returns true if the query |
| 272 | // should be retried |
| 273 | func shouldRetryQueryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/shouldRetryQuery().(q Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#, err error) bool { |
| 274 | if err == nil { |
| 275 | return false |
| 276 | } |
| 277 | |
| 278 | if _, ok := err.(RQLConnectionErrorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/RQLConnectionError#); ok { |
| 279 | return true |
| 280 | } |
| 281 | |
| 282 | return err == ErrConnectionClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ErrConnectionClosed. |
| 283 | } |