Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
adding type for array elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jprobinson committed Feb 6, 2018
1 parent fe47e16 commit c81d64c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spannerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type (
// Type will be used to populate the spanner.Type.Code field. More details
// can be found here: https://godoc.org/google.golang.org/api/spanner/v1#Type
Type string
// ArrayElementType will be used to populate the spanner.Type.Code field of a
// nested array type. More details can be found here:
// https://godoc.org/google.golang.org/api/spanner/v1#Type
ArrayElementType string
}

sessionInfo struct {
Expand Down Expand Up @@ -168,7 +172,11 @@ func (s *Session) ExecuteSQL(ctx context.Context, params []*Param, sql, queryMod
pVals = map[string]interface{}{}
)
for _, p := range params {
pTypes[p.Name] = spanner.Type{Code: p.Type}
var aryType *spanner.Type
if p.ArrayElementType != "" {
aryType = &spanner.Type{Code: p.ArrayElementType}
}
pTypes[p.Name] = spanner.Type{Code: p.Type, ArrayElementType: aryType}
pVals[p.Name] = p.Value
}
pJSON, err := json.Marshal(pVals)
Expand Down

0 comments on commit c81d64c

Please sign in to comment.