Repository navigation
Conversation
… bind limit (#1223) - Chunk order item IDs in batches of 400 in attachEffectiveAddons for order_item_addons and order_audit_log queries - Chunk order IDs and table IDs in batches of 400 in CloudSyncService.decorateOrders - Add regression test covering 164 orders with 200 items each (32,800 items) exceeding SQLite bind limits
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Chunk order and addon queries to prevent exceeding SQLite bind limit
What Changed
order_item_addonsandorder_audit_logqueries inattachEffectiveAddonsinto 400-item ID chunks.order_items,tables, andbillsqueries inCloudSyncService.decorateOrdersinto 400-ID chunks when assembling live order snapshots.tests/cloud-live-orders-batching.test.tsverifying order snapshot assembly handles 32,800 items without exceeding SQLite bind variable limits.Risk Assessment
✅ Low: The changes cleanly chunk SQLite query parameter bindings in batches of 400 without altering return shapes, ordering, or error handling, and include targeted regression test coverage.
Testing
Successfully verified the SQLite bind limit fix by driving the live Express server and CloudSyncService against an isolated database with 450-500 orders/items; all chunked queries for order items, addons, audit logs, tables, and bills passed with 200 OK and no SQLite variable errors.
Evidence: POS Orders API Response (450 Items across Chunk Threshold)
{ "scenario": "Staff member retrieves POS orders via HTTP API with over 450 line items and associated addons", "http_status": 200, "total_items": 450, "chunk_size": 400, "sample_item_start": { "product_name": "Special Item 1", "addons": [{"name": "Custom Spice 1"}], "edit_version": 1 }, "sample_item_boundary_chunk1": { "product_name": "Special Item 400", "addons": [{"name": "Custom Spice 400"}], "edit_version": 400 }, "sample_item_boundary_chunk2": { "product_name": "Special Item 401", "addons": [{"name": "Custom Spice 401"}], "edit_version": 401 }, "sample_item_end": { "product_name": "Special Item 450", "addons": [{"name": "Custom Spice 450"}], "edit_version": 450 } }Evidence: KDS Kitchen Active Orders API Response
{ "scenario": "Kitchen staff retrieves KDS active orders via HTTP API across chunk threshold with attached addons intact", "http_status": 200, "kds_orders_count": 1, "items_count": 450, "sample_kds_item": { "id": 1, "product_name": "Special Item 1", "addons": [{"name": "Custom Spice 1"}] }, "sample_kds_boundary_item": { "id": 401, "product_name": "Special Item 401", "addons": [{"name": "Custom Spice 401"}] } }Evidence: Cloud Sync Live Orders Snapshot & Decoration Summary
{ "scenario": "Cloud sync processes live orders snapshot exceeding SQLite bind limit with 500 orders and thousands of items", "total_orders_decorated": 500, "orders_chunk_size": 400, "total_items_in_batch": 1500, "order_sample_chunk1": { "order_index": 0, "table": "T-1", "bills_count": 1, "items_count": 3 }, "order_sample_boundary_chunk1": { "order_index": 399, "table": "T-400", "bills_count": 1, "items_count": 3 }, "order_sample_boundary_chunk2": { "order_index": 400, "table": "T-401", "bills_count": 1, "items_count": 3 }, "order_sample_end_chunk2": { "order_index": 499, "table": "T-500", "bills_count": 1, "items_count": 3 } }Evidence: Live Product Validation Transcript
=== Starting Live Product Validation for SQLite Bind Limit Fix === Timestamp: 2026-10-18T19:10:18.535Z [Server] Live server successfully listening on http://127.0.0.1:39101 --- Scenario 1: POS orders API retrieval with 450 line items crossing chunk boundaries --- Seeded order ORD-POS-LARGE-1 with 450 items and addons into live SQLite database. HTTP GET /api/orders response status: 200 OK Returned order items count: 450 ✓ Successfully verified chunk boundary traversal (chunk 1: items 1-400, chunk 2: items 401-450) ✓ Addons and audit logs attached seamlessly across chunk boundaries without SQLite bind limit errors --- Scenario 2: KDS active orders API retrieval across chunk boundary --- HTTP GET /api/kitchen/orders response status: 200 OK KDS order active items count: 450 ✓ KDS items hydrated with effective addons across chunk boundaries via live API --- Scenario 3: Cloud sync live-orders command with 500 orders, tables, bills, and 1,500 items --- Seeding 500 orders, 500 tables, 1500 items, and 500 bills... Database seeded: 500 orders, 500 tables, 1,500 items + addons, 500 bills. Executing cloudService.runCommand({ type: 'orders.live' })... liveOrders returned 200 orders. ✓ liveOrders command succeeded with all relations decorated Executing decorateOrders on full batch of 500 orders (exceeding CHUNK_SIZE=400)... ✓ decorateOrders successfully processed 500 orders across chunks of 400 without bind errors ✓ Verified order 1, order 400, order 401 (chunk 2), and order 500 had tables, bills, items, and addons intact = ALL 3 LIVE SCENARIOS PASSED WITH VERIFIED EVIDENCE! =Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:cloud-live-orders-batchingAuthenticatedGET /api/orders?perPage=50against live Express server on port 39101 for order with 450 items and addons crossing chunk boundariesAuthenticatedGET /api/kitchen/ordersagainst live Express server on port 39101 for KDS tickets with 450 items across chunk boundariesCloudSyncService.runCommand({ type: 'orders.live' })anddecorateOrdersagainst live database with 500 orders, 1,500 items, 500 tables, and 500 bills exceeding CHUNK_SIZE=400✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.