2
0

Simply typed nil and driver.Valuer handling

* Convert typed nils to untyped nils at beginning of encoding process.
* Restore v4 json/jsonb null behavior
* Add anynil internal package
This commit is contained in:
Jack Christensen
2022-03-05 19:45:44 -06:00
parent 39d2e3dc3f
commit 1cef9075d9
7 changed files with 66 additions and 94 deletions
+2 -2
View File
@@ -48,8 +48,8 @@ func TestJSONCodec(t *testing.T) {
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
{map[string]interface{}(nil), new(string), isExpectedEq(`null`)},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte("null"))},
{map[string]interface{}(nil), new(*string), isExpectedEq((*string)(nil))},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
})
+2 -2
View File
@@ -21,8 +21,8 @@ func TestJSONBTranscode(t *testing.T) {
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
{map[string]interface{}(nil), new(string), isExpectedEq(`null`)},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte("null"))},
{map[string]interface{}(nil), new(*string), isExpectedEq((*string)(nil))},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
})