You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`SELECT ARRAY[1, 2, 3] AS _int_array, 3.14::REAL AS _float, 'DATA' AS _text, '{"test": "foo", "arr": [1,2,3]}'::JSONB AS _json, 'Y'::BOOLEAN AS _bool`,
123
+
`SELECT
124
+
'Y'::BOOLEAN AS _bool,
125
+
3.14::REAL AS _float,
126
+
ARRAY[1, 2, 3] AS _int_array,
127
+
'{"test": "foo", "arr": [1,2,3]}'::JSONB AS _jsonb,
128
+
'DATA' AS _text
129
+
;`,
123
130
);
124
131
125
132
assertEquals(result.rows,[
126
133
{
127
134
_bool: true,
128
135
_float: 3.14,
129
136
_int_array: [1,2,3],
130
-
_json: {test: "foo",arr: [1,2,3]},
137
+
_jsonb: {test: "foo",arr: [1,2,3]},
131
138
_text: "DATA",
132
139
},
133
140
]);
@@ -141,15 +148,21 @@ Deno.test(
141
148
withClient(
142
149
async(client)=>{
143
150
constresult=awaitclient.queryObject(
144
-
`SELECT ARRAY[1, 2, 3] AS _int_array, 3.14::REAL AS _float, 'DATA' AS _text, '{"test": "foo", "arr": [1,2,3]}'::JSONB AS _json, 'Y'::BOOLEAN AS _bool`,
151
+
`SELECT
152
+
'Y'::BOOLEAN AS _bool,
153
+
3.14::REAL AS _float,
154
+
ARRAY[1, 2, 3] AS _int_array,
155
+
'{"test": "foo", "arr": [1,2,3]}'::JSONB AS _jsonb,
156
+
'DATA' AS _text
157
+
;`,
145
158
);
146
159
147
160
assertEquals(result.rows,[
148
161
{
149
162
_bool: "t",
150
163
_float: "3.14",
151
164
_int_array: "{1,2,3}",
152
-
_json: '{"arr": [1, 2, 3], "test": "foo"}',
165
+
_jsonb: '{"arr": [1, 2, 3], "test": "foo"}',
153
166
_text: "DATA",
154
167
},
155
168
]);
@@ -158,6 +171,75 @@ Deno.test(
158
171
),
159
172
);
160
173
174
+
Deno.test(
175
+
"Custom decoders",
176
+
withClient(
177
+
async(client)=>{
178
+
constresult=awaitclient.queryObject(
179
+
`SELECT
180
+
0::BOOLEAN AS _bool,
181
+
(DATE '2024-01-01' + INTERVAL '2 months')::DATE AS _date,
182
+
7.90::REAL AS _float,
183
+
100 AS _int,
184
+
'{"foo": "a", "bar": [1,2,3], "baz": null}'::JSONB AS _jsonb,
185
+
'MY_VALUE' AS _text,
186
+
DATE '2024-10-01' + INTERVAL '2 years' - INTERVAL '2 months' AS _timestamp
0 commit comments