This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
ServiceStack.OrmLite.PostgreSQL.Tests
ServiceStack.OrmLite.PostgreSQL Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -55,11 +55,14 @@ public void Can_save_complex_types_as_JSON()
5555 db . Insert ( row ) ;
5656
5757 var result = db . Select < ModelWithJsonType > (
58- "complex_type_json->'sub_type'->>'name' = 'SubType2'" ) ;
58+ "complex_type_json->'SubType'->>'Name' = 'SubType2'" ) ;
59+
60+ db . GetLastSql ( ) . Print ( ) ;
5961
6062 Assert . That ( result . Count , Is . EqualTo ( 1 ) ) ;
61- Assert . That ( result [ 0 ] . Id , Is . EqualTo ( 2 ) ) ;
62- Assert . That ( result [ 0 ] . ComplexTypeJson . SubType , Is . EqualTo ( "SubType2" ) ) ;
63+ Assert . That ( result [ 0 ] . Id , Is . EqualTo ( 1 ) ) ;
64+ Assert . That ( result [ 0 ] . ComplexTypeJson . Id , Is . EqualTo ( 2 ) ) ;
65+ Assert . That ( result [ 0 ] . ComplexTypeJson . SubType . Name , Is . EqualTo ( "SubType2" ) ) ;
6366 }
6467 }
6568 }
Original file line number Diff line number Diff line change 33using System . Data ;
44using System . Text ;
55using Npgsql ;
6+ using NpgsqlTypes ;
67using ServiceStack . Text ;
78
89namespace ServiceStack . OrmLite . PostgreSQL
@@ -324,5 +325,15 @@ public override long InsertAndGetLastInsertId<T>(IDbCommand dbCmd)
324325
325326 return dbCmd . ExecLongScalar ( ) ;
326327 }
328+ public override void SetParameter ( FieldDefinition fieldDef , IDbDataParameter p )
329+ {
330+ if ( fieldDef . CustomFieldDefinition == "json" )
331+ {
332+ p . ParameterName = this . GetParam ( SanitizeFieldNameForParamName ( fieldDef . FieldName ) ) ;
333+ ( ( NpgsqlParameter ) p ) . NpgsqlDbType = NpgsqlDbType . Json ;
334+ return ;
335+ }
336+ base . SetParameter ( fieldDef , p ) ;
337+ }
327338 }
328339}
You can’t perform that action at this time.
0 commit comments