Skip to content

feat(model): add bulk insert and upsert operations#2101

Merged
bpamiri merged 3 commits intodevelopfrom
peter/bulk-operations
Apr 15, 2026
Merged

feat(model): add bulk insert and upsert operations#2101
bpamiri merged 3 commits intodevelopfrom
peter/bulk-operations

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 15, 2026

Summary

  • Adds insertAll() and upsertAll() class-level methods to the Wheels ORM via new model/bulk.cfc mixin
  • Implements database-specific UPSERT syntax for all 7 adapters:
    • PostgreSQL/CockroachDB/SQLite: ON CONFLICT ... DO UPDATE
    • MySQL: ON DUPLICATE KEY UPDATE
    • SQL Server/Oracle: MERGE
    • H2: MERGE INTO ... KEY
  • Auto-batches records (1000 per batch) to avoid parameter limits
  • Supports automatic timestamp injection (createdAt/updatedAt)
  • Includes BulkItem test model and comprehensive BDD spec

Closes the bulk operations gap (insert_all/upsert_all) identified in docs/wheels-vs-frameworks.md.

Test plan

  • Run bash tools/test-local.sh — all existing tests pass
  • New tests in vendor/wheels/tests/specs/model/bulkOperationsSpec.cfc pass
  • Test with SQLite adapter (default test DB)
  • Verify across Lucee and Adobe CF engines

🤖 Generated with Claude Code

bpamiri and others added 3 commits April 14, 2026 22:44
Adds insertAll() and upsertAll() class-level methods to the ORM with
database-specific UPSERT syntax for all 7 adapters (PostgreSQL, MySQL,
SQL Server, SQLite, H2, CockroachDB, Oracle). Includes BulkItem test
model and comprehensive BDD spec.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove dead quoteFunc parameter from all $upsertSQL adapter signatures.
Register insertAll/upsertAll in application function defaults for
proper parameterize handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Oracle: Replace string-interpolated SELECT FROM dual values with
parameterized $buildBulkParam (fixes SQL injection vulnerability).
Restructure to use single MERGE with UNION ALL of SELECT FROM dual
so multi-row batches execute as one statement instead of being
split with semicolons (which JDBC rejects).

H2: Combine multi-row batches into single MERGE INTO ... VALUES (...)
statement instead of multiple statements separated by semicolons.
Also quote identifiers consistently with other adapters.

Test: Verify createdAt/updatedAt are empty when timestamps=false.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri force-pushed the peter/bulk-operations branch from ad691f3 to de093eb Compare April 15, 2026 05:46
@bpamiri bpamiri merged commit 21dde0e into develop Apr 15, 2026
3 checks passed
@bpamiri bpamiri deleted the peter/bulk-operations branch April 15, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant