@@ -305,6 +305,39 @@ async def test_insert_many_tx(self, client, simple_args, test_tx):
305305 assert results [0 ].unique_skipped_as_duplicated is False
306306 assert results [0 ].job .id > 0
307307
308+ @pytest .mark .asyncio
309+ async def test_insert_many_preserves_distinct_args (self , client ):
310+ # Insert mixed types and ensure each row retains its own args and kind
311+ from dataclasses import dataclass
312+
313+ @dataclass
314+ class TypeA :
315+ n : int
316+ kind : str = "simple_a"
317+
318+ def to_json (self ) -> str :
319+ return json .dumps ({"a" : self .n })
320+
321+ @dataclass
322+ class TypeB :
323+ s : str
324+ kind : str = "simple_b"
325+
326+ def to_json (self ) -> str :
327+ return json .dumps ({"b" : self .s })
328+
329+ batch = [TypeA (1 ), TypeB ("x" ), TypeA (2 ), TypeB ("y" )]
330+ results = await client .insert_many (batch )
331+
332+ assert len (results ) == 4
333+ for res , arg in zip (results , batch ):
334+ if isinstance (arg , TypeA ):
335+ assert res .job .kind == "simple_a"
336+ assert res .job .args == {"a" : arg .n }
337+ else :
338+ assert res .job .kind == "simple_b"
339+ assert res .job .args == {"b" : arg .s }
340+
308341
309342class TestSyncClient :
310343 #
@@ -502,3 +535,35 @@ def test_insert_many_tx(self, client, simple_args, test_tx):
502535 assert len (results ) == 1
503536 assert results [0 ].unique_skipped_as_duplicated is False
504537 assert results [0 ].job .id > 0
538+
539+ def test_insert_many_preserves_distinct_args (self , client ):
540+ # Insert mixed types and ensure each row retains its own args and kind
541+ from dataclasses import dataclass
542+
543+ @dataclass
544+ class TypeA :
545+ n : int
546+ kind : str = "simple_a"
547+
548+ def to_json (self ) -> str :
549+ return json .dumps ({"a" : self .n })
550+
551+ @dataclass
552+ class TypeB :
553+ s : str
554+ kind : str = "simple_b"
555+
556+ def to_json (self ) -> str :
557+ return json .dumps ({"b" : self .s })
558+
559+ batch = [TypeA (1 ), TypeB ("x" ), TypeA (2 ), TypeB ("y" )]
560+ results = client .insert_many (batch )
561+
562+ assert len (results ) == 4
563+ for res , arg in zip (results , batch ):
564+ if isinstance (arg , TypeA ):
565+ assert res .job .kind == "simple_a"
566+ assert res .job .args == {"a" : arg .n }
567+ else :
568+ assert res .job .kind == "simple_b"
569+ assert res .job .args == {"b" : arg .s }
0 commit comments