File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,42 @@ mod tests {
220
220
Ok ( ( ) )
221
221
}
222
222
223
+ /// Postgres encodes values differently in prepared statements and in "simple" queries
224
+ /// <https://www.postgresql.org/docs/9.1/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY>
225
+ #[ actix_web:: test]
226
+ async fn test_postgres_prepared_types ( ) -> anyhow:: Result < ( ) > {
227
+ let Some ( db_url) = db_specific_test ( "postgres" ) else {
228
+ return Ok ( ( ) ) ;
229
+ } ;
230
+ let mut c = sqlx:: AnyConnection :: connect ( & db_url) . await ?;
231
+ let row = sqlx:: query (
232
+ "SELECT
233
+ '2024-03-14'::DATE as date,
234
+ '13:14:15'::TIME as time,
235
+ '2024-03-14 13:14:15+02:00'::TIMESTAMPTZ as timestamptz,
236
+ INTERVAL '-01:02:03' as time_interval,
237
+ '{\" key\" : \" value\" }'::JSON as json,
238
+ 1234.56::MONEY as money_val
239
+ where $1" ,
240
+ )
241
+ . bind ( true )
242
+ . fetch_one ( & mut c)
243
+ . await ?;
244
+
245
+ expect_json_object_equal (
246
+ & row_to_json ( & row) ,
247
+ & serde_json:: json!( {
248
+ "date" : "2024-03-14" ,
249
+ "time" : "13:14:15" ,
250
+ "timestamptz" : "2024-03-14T11:14:15+00:00" ,
251
+ "time_interval" : "-01:02:03" ,
252
+ "json" : { "key" : "value" } ,
253
+ "money_val" : "" // TODO: fix this bug: https://github.com/sqlpage/SQLPage/issues/983
254
+ } ) ,
255
+ ) ;
256
+ Ok ( ( ) )
257
+ }
258
+
223
259
#[ actix_web:: test]
224
260
async fn test_mysql_types ( ) -> anyhow:: Result < ( ) > {
225
261
let db_url = db_specific_test ( "mysql" ) . or_else ( || db_specific_test ( "mariadb" ) ) ;
You can’t perform that action at this time.
0 commit comments