@@ -194,14 +194,42 @@ public class Bug3464Class
194194 public string ? SomeString { get ; set ; }
195195 }
196196
197+ [ Test , IssueLink ( "https://github.com/npgsql/npgsql/issues/5475" ) ]
198+ public async Task Read_jarray_from_get_value ( )
199+ {
200+ await using var conn = await JsonDataSource . OpenConnectionAsync ( ) ;
201+
202+ await using var cmd = new NpgsqlCommand { Connection = conn } ;
203+
204+ var json = new JArray ( new JObject { { "name" , "value1" } } ) ;
205+
206+ cmd . CommandText = $ "SELECT @p";
207+ cmd . Parameters . Add ( new ( "p" , json ) ) ;
208+ await cmd . ExecuteScalarAsync ( ) ;
209+ }
197210 [ Test ]
198- [ IssueLink ( "https://github.com/npgsql/npgsql/issues/4537" ) ]
199- public async Task Write_jobject_array_without_npgsqldbtype ( )
211+ public async Task Write_jobject_without_npgsqldbtype ( )
200212 {
201- // By default we map JObject to jsonb
202- if ( ! IsJsonb )
203- return ;
213+ await using var conn = await JsonDataSource . OpenConnectionAsync ( ) ;
214+ var tableName = await TestUtil . CreateTempTable ( conn , "key SERIAL PRIMARY KEY, ingredients json" ) ;
204215
216+ await using var cmd = new NpgsqlCommand { Connection = conn } ;
217+
218+ var jsonObject = new JObject
219+ {
220+ { "name" , "value1" } ,
221+ { "amount" , 1 } ,
222+ { "unit" , "ml" }
223+ } ;
224+
225+ cmd . CommandText = $ "INSERT INTO { tableName } (ingredients) VALUES (@p)";
226+ cmd . Parameters . Add ( new ( "p" , jsonObject ) ) ;
227+ await cmd . ExecuteNonQueryAsync ( ) ;
228+ }
229+
230+ [ Test , IssueLink ( "https://github.com/npgsql/npgsql/issues/4537" ) ]
231+ public async Task Write_jobject_array_without_npgsqldbtype ( )
232+ {
205233 await using var conn = await JsonDataSource . OpenConnectionAsync ( ) ;
206234 var tableName = await TestUtil . CreateTempTable ( conn , "key SERIAL PRIMARY KEY, ingredients json[]" ) ;
207235
0 commit comments