@@ -227,25 +227,101 @@ describe("Sender message builder test suite (anything not covered in client inte
227227 } ) ;
228228 sender . table ( "tableName" ) ;
229229 expect ( ( ) => sender . arrayColumn ( "arrayCol" , [ ] ) ) . toThrow (
230- "zero length array not supported" ,
230+ "Zero length array not supported" ,
231231 ) ;
232232 expect ( ( ) => sender . arrayColumn ( "arrayCol" , [ [ ] , [ ] ] ) ) . toThrow (
233- "zero length array not supported" ,
233+ "Zero length array not supported" ,
234234 ) ;
235235 await sender . close ( ) ;
236236 } ) ;
237237
238- it ( "does not accept irregular array" , async function ( ) {
238+ it ( "does not accept irregularly sized array" , async function ( ) {
239239 const sender = new Sender ( {
240240 protocol : "tcp" ,
241241 protocol_version : "2" ,
242242 host : "host" ,
243243 init_buf_size : 1024 ,
244244 } ) ;
245245 expect ( ( ) =>
246- sender . table ( "tableName" ) . arrayColumn ( "arrayCol" , [ [ 1.1 , 2.2 ] , [ 3.3 ] ] ) ,
246+ sender . table ( "tableName" ) . arrayColumn ( "arrayCol" , [
247+ [
248+ [ 1.1 , 2.2 ] ,
249+ [ 3.3 , 4.4 ] ,
250+ [ 5.5 , 6.6 ] ,
251+ ] ,
252+ [
253+ [ 1.1 , 2.2 ] ,
254+ [ 3.3 , 4.4 ] ,
255+ [ 5.5 , 6.6 ] ,
256+ ] ,
257+ [
258+ [ 1.1 , 2.2 ] ,
259+ [ 3.3 , 4.4 ] ,
260+ [ 5.5 , 6.6 ] ,
261+ ] ,
262+ [ [ 1.1 , 2.2 ] , [ 3.3 ] , [ 5.5 , 6.6 ] ] ,
263+ ] ) ,
247264 ) . toThrow (
248- "length does not match array dimensions [dimensions=[2,2], length=1]" ,
265+ "Length of arrays do not match [expected=2, actual=1, dimensions=[4,3,2], path=[3][1]]" ,
266+ ) ;
267+ await sender . close ( ) ;
268+ } ) ;
269+
270+ it ( "does not accept non-homogenous array" , async function ( ) {
271+ const sender = new Sender ( {
272+ protocol : "tcp" ,
273+ protocol_version : "2" ,
274+ host : "host" ,
275+ init_buf_size : 1024 ,
276+ } ) ;
277+ sender . table ( "tableName" ) ;
278+ expect ( ( ) =>
279+ sender . arrayColumn ( "arrayCol" , [
280+ [
281+ [ 1.1 , 2.2 ] ,
282+ [ 3.3 , 4.4 ] ,
283+ [ 5.5 , 6.6 ] ,
284+ ] ,
285+ [
286+ [ 1.1 , 2.2 ] ,
287+ [ 3.3 , 4.4 ] ,
288+ [ 5.5 , 6.6 ] ,
289+ ] ,
290+ [
291+ [ 1.1 , 2.2 ] ,
292+ [ 3.3 , 4.4 ] ,
293+ [ 5.5 , 6.6 ] ,
294+ ] ,
295+ [
296+ [ 1.1 , 2.2 ] ,
297+ [ 3.3 , "4.4" ] ,
298+ [ 5.5 , 6.6 ] ,
299+ ] ,
300+ ] ) ,
301+ ) . toThrow (
302+ "Mixed types found [expected=number, current=string, path=[3][1][1]]" ,
303+ ) ;
304+ expect ( ( ) =>
305+ sender . arrayColumn ( "arrayCol" , [
306+ [
307+ [ 1.1 , 2.2 ] ,
308+ [ 3.3 , 4.4 ] ,
309+ [ 5.5 , 6.6 ] ,
310+ ] ,
311+ [
312+ [ 1.1 , 2.2 ] ,
313+ [ 3.3 , 4.4 ] ,
314+ [ 5.5 , 6.6 ] ,
315+ ] ,
316+ [
317+ [ 1.1 , 2.2 ] ,
318+ [ 3.3 , 4.4 ] ,
319+ [ 5.5 , 6.6 ] ,
320+ ] ,
321+ [ [ 1.1 , 2.2 ] , 3.3 , [ 5.5 , 6.6 ] ] ,
322+ ] ) ,
323+ ) . toThrow (
324+ "Mixed types found [expected=array, current=number, path=[3][1]]" ,
249325 ) ;
250326 await sender . close ( ) ;
251327 } ) ;
@@ -258,11 +334,21 @@ describe("Sender message builder test suite (anything not covered in client inte
258334 init_buf_size : 1024 ,
259335 } ) ;
260336 sender . table ( "tableName" ) ;
261- expect ( ( ) => sender . arrayColumn ( "col" , [ 'str' ] ) ) . toThrow ( "unsupported array type [type=string]" ) ;
262- expect ( ( ) => sender . arrayColumn ( "col" , [ true ] ) ) . toThrow ( "unsupported array type [type=boolean]" ) ;
263- expect ( ( ) => sender . arrayColumn ( "col" , [ { } ] ) ) . toThrow ( "unsupported array type [type=object]" ) ;
264- expect ( ( ) => sender . arrayColumn ( "col" , [ null ] ) ) . toThrow ( "unsupported array type [type=object]" ) ;
265- expect ( ( ) => sender . arrayColumn ( "col" , [ undefined ] ) ) . toThrow ( "unsupported array type [type=undefined]" ) ;
337+ expect ( ( ) => sender . arrayColumn ( "col" , [ "str" ] ) ) . toThrow (
338+ "Unsupported array type [type=string]" ,
339+ ) ;
340+ expect ( ( ) => sender . arrayColumn ( "col" , [ true ] ) ) . toThrow (
341+ "Unsupported array type [type=boolean]" ,
342+ ) ;
343+ expect ( ( ) => sender . arrayColumn ( "col" , [ { } ] ) ) . toThrow (
344+ "Unsupported array type [type=object]" ,
345+ ) ;
346+ expect ( ( ) => sender . arrayColumn ( "col" , [ null ] ) ) . toThrow (
347+ "Unsupported array type [type=object]" ,
348+ ) ;
349+ expect ( ( ) => sender . arrayColumn ( "col" , [ undefined ] ) ) . toThrow (
350+ "Unsupported array type [type=undefined]" ,
351+ ) ;
266352 await sender . close ( ) ;
267353 } ) ;
268354
@@ -275,17 +361,29 @@ describe("Sender message builder test suite (anything not covered in client inte
275361 } ) ;
276362 sender . table ( "tableName" ) ;
277363 // @ts -expect-error - Testing invalid input
278- expect ( ( ) => sender . arrayColumn ( "col" , 12.345 ) ) . toThrow ( "The value must be an array [value=12.345, type=number]" ) ;
364+ expect ( ( ) => sender . arrayColumn ( "col" , 12.345 ) ) . toThrow (
365+ "The value must be an array [value=12.345, type=number]" ,
366+ ) ;
279367 // @ts -expect-error - Testing invalid input
280- expect ( ( ) => sender . arrayColumn ( "col" , 42 ) ) . toThrow ( "The value must be an array [value=42, type=number]" ) ;
368+ expect ( ( ) => sender . arrayColumn ( "col" , 42 ) ) . toThrow (
369+ "The value must be an array [value=42, type=number]" ,
370+ ) ;
281371 // @ts -expect-error - Testing invalid input
282- expect ( ( ) => sender . arrayColumn ( "col" , "str" ) ) . toThrow ( "The value must be an array [value=\"str\", type=string]" ) ;
372+ expect ( ( ) => sender . arrayColumn ( "col" , "str" ) ) . toThrow (
373+ 'The value must be an array [value="str", type=string]' ,
374+ ) ;
283375 // @ts -expect-error - Testing invalid input
284- expect ( ( ) => sender . arrayColumn ( "col" , "" ) ) . toThrow ( "The value must be an array [value=\"\", type=string]" ) ;
376+ expect ( ( ) => sender . arrayColumn ( "col" , "" ) ) . toThrow (
377+ 'The value must be an array [value="", type=string]' ,
378+ ) ;
285379 // @ts -expect-error - Testing invalid input
286- expect ( ( ) => sender . arrayColumn ( "col" , true ) ) . toThrow ( "The value must be an array [value=true, type=boolean]" ) ;
380+ expect ( ( ) => sender . arrayColumn ( "col" , true ) ) . toThrow (
381+ "The value must be an array [value=true, type=boolean]" ,
382+ ) ;
287383 // @ts -expect-error - Testing invalid input
288- expect ( ( ) => sender . arrayColumn ( "col" , { } ) ) . toThrow ( "The value must be an array [value={}, type=object]" ) ;
384+ expect ( ( ) => sender . arrayColumn ( "col" , { } ) ) . toThrow (
385+ "The value must be an array [value={}, type=object]" ,
386+ ) ;
289387 await sender . close ( ) ;
290388 } ) ;
291389
0 commit comments