Skip to content

Add parameter-aware bulk inserts - #321

Merged
elpete merged 6 commits into
nextfrom
feature/issue-153-insert-bulk
Aug 12, 2026
Merged

Add parameter-aware bulk inserts#321
elpete merged 6 commits into
nextfrom
feature/issue-153-insert-bulk

Conversation

@elpete

@elpete elpete commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Addresses #153

What changed

  • add an insertBulk() API for arrays of structs
  • use one serialized JSON parameter with OPENJSON for SQL Server bulk inserts
  • infer SQL Server column types using the same type-resolution foundation as whereInBulk, with optional sqlTypes overrides
  • preserve SQL Server returning() support through the OUTPUT clause
  • use parameter-aware multi-row insert batches as the portable fallback for grammars without a native strategy
  • accept a positive chunkSize as an explicit cap; consistent with pagination conventions, non-positive values mean all rows subject to fallback grammar parameter limits

Why

Large multi-row inserts can exceed database parameter limits. SQL Server can avoid that limit entirely by sending the rows as one JSON binding and expanding them into a typed rowset with OPENJSON. Other grammars continue to receive safe batching without exposing chunking as the primary API.

Tests

Tests were added first for explicit fallback batching, grammar-limit enforcement, empty input, the non-positive all-rows convention, SQL Server OPENJSON, inferred and explicit SQL types, serialized bindings, and returning().

  • TestBox on Lucee 6: 2,779 passed, 0 failed, 3 skipped
  • box run-script format:check
  • git diff --check

@elpete
elpete force-pushed the feature/issue-153-insert-bulk branch from ff96b64 to d22fbfe Compare August 12, 2026 18:45
@elpete

elpete commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Refactored the bulk insert boundary after review: QueryBuilder now has a preparation method that returns columns and the JSON binding, while SQL generation remains exclusively in the grammar’s compileBulkInsert() method. Generated SQL and binding behavior are unchanged.

Validation: Lucee suite 2,781 passed, 0 failed/errors, 3 skipped; formatting and git diff --check pass.

@elpete
elpete marked this pull request as ready for review August 12, 2026 20:46
@elpete
elpete merged commit bec9280 into next Aug 12, 2026
34 of 35 checks passed
@elpete
elpete deleted the feature/issue-153-insert-bulk branch August 12, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant