Skip to content

Commit a8c5471

Browse files
martinv13claude
andauthored
Fix max_lines parameter being overwritten in insert_into_temp_tables loop (#63)
The parameter was mutated on the first iteration when no limit was set, causing subsequent batches to use a stale value from whichever table was processed first. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent df6977d commit a8c5471

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/xml2db/document.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,16 @@ def insert_into_temp_tables(self, max_lines: int = -1) -> None:
388388
for query, data in tb.get_insert_temp_records_statements(
389389
self.data.get(tb.type_name, None)
390390
):
391-
if max_lines is None or max_lines < 0:
392-
max_lines = len(data)
391+
batch_size = len(data) if max_lines is None or max_lines < 0 else max_lines
393392
start_idx = 0
394393
while start_idx < len(data):
395394
with self.model.engine.begin() as conn:
396395
self.model.dialect.bulk_insert(
397396
conn,
398397
query.table,
399-
data[start_idx : (start_idx + max_lines)],
398+
data[start_idx : (start_idx + batch_size)],
400399
)
401-
start_idx = start_idx + max_lines
400+
start_idx = start_idx + batch_size
402401

403402
def merge_into_target_tables(self, single_transaction: bool = True) -> int:
404403
"""Merge data into target data model

0 commit comments

Comments
 (0)