Skip to content

Add ability to query using Composite Batch Api#114

Open
stevenskim wants to merge 1 commit into
mainfrom
cdaw-580-activeforce-add-ability-to-query-using-composite-batch-api
Open

Add ability to query using Composite Batch Api#114
stevenskim wants to merge 1 commit into
mainfrom
cdaw-580-activeforce-add-ability-to-query-using-composite-batch-api

Conversation

@stevenskim
Copy link
Copy Markdown
Contributor

@stevenskim stevenskim commented Feb 27, 2026

Summary

Automatically routes SOQL queries through the Salesforce Composite Batch API when the query length exceeds a configurable threshold, bypassing URL/header size limits on standard GET requests (~16,000–20,000 characters). The Composite Batch API supports the full SOQL length limit of 100,000 characters.

Changes

  • ActiveForce.composite_batch_query_threshold — New configurable threshold (default: 100_000). The default matches the SOQL max length, effectively disabling composite batch routing unless explicitly lowered. Accepts an integer or a callable (proc/lambda) for dynamic evaluation (e.g., feature flags).
  • ActiveQuery#result — Routes to CompositeBatchQuery when SOQL length ≥ threshold; otherwise uses the existing sfdc_client.query.
  • CompositeBatchQuery — New class that executes SOQL via Restforce#batch. Raises typed Restforce::ErrorCode exceptions for error responses (status ≥ 300).

Usage

# Lower the threshold to opt in to composite batch routing
ActiveForce.composite_batch_query_threshold = 25_000

# Dynamic threshold via callable (e.g., feature flag)
ActiveForce.composite_batch_query_threshold = -> { MyFeatureFlag.enabled?(:composite_batch) ? 25_000 : 100_000 }

Tests

  • spec/active_force/composite_batch_query_spec.rb — Covers successful queries, error handling, and client delegation.
  • spec/active_force/active_query_spec.rb — Covers routing logic based on threshold.
  • spec/active_force_spec.rb — Covers threshold configuration (default, static, callable).

@stevenskim stevenskim force-pushed the cdaw-580-activeforce-add-ability-to-query-using-composite-batch-api branch from df60fd8 to 2334fc0 Compare February 27, 2026 17:22
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.35%. Comparing base (f7f8888) to head (2334fc0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #114      +/-   ##
==========================================
+ Coverage   97.26%   97.35%   +0.08%     
==========================================
  Files          24       25       +1     
  Lines         951      982      +31     
==========================================
+ Hits          925      956      +31     
  Misses         26       26              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stevenskim stevenskim requested a review from asedge February 27, 2026 18:41
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