Skip to content

Commit

Permalink
cast: JSON is always UTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Apr 29, 2024
1 parent a0a3c2f commit 0bba907
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __tests__/golden.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('golden', () => {
aa: 'aa',
ab: 'foo',
ac: 'foo,bar',
ad: { ad: null },
ad: { ad: null, foo: 'ü' },
ae: uint8ArrayFromHex(
'0x0000000001020000000300000000000000000000000000000000000000000000000000F03F000000000000F03F00000000000000400000000000000000'
),
Expand Down
4 changes: 2 additions & 2 deletions golden/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
"2",
"3",
"7",
"12",
"25",
"61",
"25",
"61",
Expand All @@ -529,7 +529,7 @@
"2",
"-1"
],
"values": "MTExMTExMS4xMS4xMS4xMS4xBzEwMDAtMDEtMDExMDAwLTAxLTAxIDAxOjAxOjAxMTk3MC0wMS0wMSAwMDowMTowMTAxOjAxOjAxMjAwNnBxcgAAAHN0dXZ3eHl6YWFmb29mb28sYmFyeyJhZCI6IG51bGx9AAAAAAECAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAEAAAAAAAAAAAAAAAAABAQAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAQIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAAAAAAAAAEDAAAAAgAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAAAAAAAAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAABAAAAAAAAAAEAAAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8xMTExeGF4YnhjAAB4ZA=="
"values": "MTExMTExMS4xMS4xMS4xMS4xBzEwMDAtMDEtMDExMDAwLTAxLTAxIDAxOjAxOjAxMTk3MC0wMS0wMSAwMDowMTowMTAxOjAxOjAxMjAwNnBxcgAAAHN0dXZ3eHl6YWFmb29mb28sYmFyeyJhZCI6IG51bGwsICJmb28iOiAiw7wifQAAAAABAgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAABAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAECAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAEAAAAAAAAAAAAAAAAABAwAAAAIAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAQAAAAAAAAABAAAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/MTExMXhheGJ4YwAAeGQ="
}
]
}
2 changes: 1 addition & 1 deletion golden/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ INSERT INTO `test` VALUES (
'aa',
'foo',
'foo,bar',
'{"ad":null}',
'{"ad":null,"foo":"ü"}',
ST_GeomFromText('LINESTRING(0 0, 1 1, 2 0)'),
POINT(1, 1),
ST_GeomFromText('LINESTRING(0 0, 1 1, 2 0)'),
Expand Down
2 changes: 1 addition & 1 deletion src/cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function cast(field: Field, value: any): any {
}

if (isJson(field)) {
return JSON.parse(value)
return JSON.parse(decodeUtf8(value))
}

if (isIntegral(field)) {
Expand Down

0 comments on commit 0bba907

Please sign in to comment.