@@ -74,16 +74,17 @@ func convertJSONValue(v interface{}) (val interface{}, inRange sql.ConvertInRang
7474
7575// Convert implements Type interface.
7676func (t JsonType ) Convert (c context.Context , v interface {}) (doc interface {}, inRange sql.ConvertInRange , err error ) {
77+ docVal := v
7778 switch v := v .(type ) {
7879 case sql.JSONWrapper :
7980 return v , sql .InRange , nil
8081 case []byte :
81- doc , inRange , err = convertJSONValue (v )
82+ docVal , inRange , err = convertJSONValue (v )
8283 if err != nil {
8384 return nil , inRange , err
8485 }
8586 case string :
86- doc , inRange , err = convertJSONValue (v )
87+ docVal , inRange , err = convertJSONValue (v )
8788 if err != nil {
8889 return nil , inRange , err
8990 }
@@ -93,7 +94,7 @@ func (t JsonType) Convert(c context.Context, v interface{}) (doc interface{}, in
9394 if err != nil {
9495 return nil , sql .OutOfRange , err
9596 }
96- doc , inRange , err = convertJSONValue (str )
97+ docVal , inRange , err = convertJSONValue (str )
9798 if err != nil {
9899 return nil , inRange , err
99100 }
@@ -123,7 +124,7 @@ func (t JsonType) Convert(c context.Context, v interface{}) (doc interface{}, in
123124 // if |v| can be marshalled, it contains
124125 // a valid JSON document representation
125126 if b , berr := json .Marshal (v ); berr == nil {
126- doc , inRange , err = convertJSONValue (b )
127+ docVal , inRange , err = convertJSONValue (b )
127128 if err != nil {
128129 return nil , inRange , err
129130 }
@@ -132,7 +133,7 @@ func (t JsonType) Convert(c context.Context, v interface{}) (doc interface{}, in
132133 if err != nil {
133134 return nil , sql .OutOfRange , err
134135 }
135- return JSONDocument {Val : doc }, sql .InRange , nil
136+ return JSONDocument {Val : docVal }, sql .InRange , nil
136137}
137138
138139// Equals implements the Type interface.
0 commit comments