File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,20 @@ where
196
196
}
197
197
}
198
198
199
+ impl < DB > Type < DB > for Box < JsonRawValue >
200
+ where
201
+ for < ' a > Json < & ' a Self > : Type < DB > ,
202
+ DB : Database ,
203
+ {
204
+ fn type_info ( ) -> DB :: TypeInfo {
205
+ <Json < & Self > as Type < DB > >:: type_info ( )
206
+ }
207
+
208
+ fn compatible ( ty : & DB :: TypeInfo ) -> bool {
209
+ <Json < & Self > as Type < DB > >:: compatible ( ty)
210
+ }
211
+ }
212
+
199
213
// We don't have to implement Encode for JsonRawValue because that's covered by the default
200
214
// implementation for Encode
201
215
impl < ' r , DB > Decode < ' r , DB > for & ' r JsonRawValue
@@ -207,3 +221,13 @@ where
207
221
<Json < Self > as Decode < DB > >:: decode ( value) . map ( |item| item. 0 )
208
222
}
209
223
}
224
+
225
+ impl < ' r , DB > Decode < ' r , DB > for Box < JsonRawValue >
226
+ where
227
+ Json < Self > : Decode < ' r , DB > ,
228
+ DB : Database ,
229
+ {
230
+ fn decode ( value : <DB as Database >:: ValueRef < ' r > ) -> Result < Self , BoxDynError > {
231
+ <Json < Self > as Decode < DB > >:: decode ( value) . map ( |item| item. 0 )
232
+ }
233
+ }
Original file line number Diff line number Diff line change @@ -465,7 +465,9 @@ mod json {
465
465
. await ?;
466
466
467
467
let value: & JsonRawValue = row. try_get ( 0 ) ?;
468
+ assert_eq ! ( value. get( ) , "{\" hello\" : \" world\" }" ) ;
468
469
470
+ let value: Box < JsonRawValue > = row. try_get ( 0 ) ?;
469
471
assert_eq ! ( value. get( ) , "{\" hello\" : \" world\" }" ) ;
470
472
471
473
// prepared, binary API
@@ -474,7 +476,9 @@ mod json {
474
476
. await ?;
475
477
476
478
let value: & JsonRawValue = row. try_get ( 0 ) ?;
479
+ assert_eq ! ( value. get( ) , "{\" hello\" : \" world\" }" ) ;
477
480
481
+ let value: Box < JsonRawValue > = row. try_get ( 0 ) ?;
478
482
assert_eq ! ( value. get( ) , "{\" hello\" : \" world\" }" ) ;
479
483
480
484
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments