Conversation
Reorganize x/sqlite/TODO.md into Correctness, Functionality, Test Gaps, and Performance sections based on a full driver audit against CouchDB behavior. Add Flusher fallback no-op item to V5.md.
Operator-based selectors ($gt, $lt, etc.) set selectorComplete=true, bypassing the in-memory mango filter. SQLite's type guards don't implement CouchDB's cross-type ordering, so queries on mixed-type fields returned incorrect results (e.g. nulls and booleans included by $gt on a number). Change else-if to independent if so complete=false whenever a field value contains operators, ensuring the safety net runs.
Add PurgeSeq to driver.DBStats and kivik.DBStats, with CouchDB version- aware deserialization (number in 1.x, string in 2.x+). Implement purge_seq in the SQLite driver, incrementing on every Purge() call to match CouchDB behavior. Consolidate the single-purpose Security table into a generic Metadata key-value table. Combine Stats() into a single query for atomicity.
When a Find query includes use_index with a valid ddoc and index name, resolve the corresponding SQLite index name and inject INDEXED BY into the leaves CTE, forcing SQLite to use the specified index rather than relying on its automatic index selection.
Previously, updating a design document created new map tables for the new revision but never dropped the old ones, leaking orphaned tables. Now dropOldMapTables runs before inserting new Design rows, cleaning up stale map tables. Note: in conflict scenarios this drops too aggressively (all revisions, not just the parent); tracked in TODO for a follow-up fix.
Previously dropOldMapTables dropped map tables for all revisions of a design doc, which would incorrectly destroy other branches' tables in a conflict scenario. Now filters by the specific parent revision being superseded, and also calls updateDesignDoc in the new_edits=false path so replicated design docs get their entries and map tables created.
Offset() was hardcoded to 0. CouchDB returns the skip value as offset, so expose PaginationOptions.Skip() and wire it through to the rows struct.
CouchDB's _sum supports element-wise summing of arrays, with bare numbers treated as single-element arrays and shorter arrays zero-padded.
CouchDB's _sum supports recursive field-wise summing of objects. Objects with overlapping keys have their numeric values summed; nested objects are merged recursively.
Dispatch to object or numeric path based on the first non-nil value encountered in the main loop, avoiding a separate pre-scan. Also flag null handling as incorrect per CouchDB (errors, not skips).
…nd larger datasets
Callers now control cancellation policy by passing a context to MapFunc and ReduceFunc, rather than relying on a hardcoded timeout in the js package. Threads real request contexts from query.go and changes.go through the reduce pipeline to JavaScript execution.
Extends the context-based cancellation pattern to Filter, matching Map and Reduce. The changes.go caller now passes its request context through to the filter JS execution.
Extends context-based cancellation to Validate, completing the pattern for Filter/Validate. The validate.go caller now passes its request context through to JavaScript execution.
Completes context-based cancellation across all JS functions (Map, Reduce, Filter, Validate, Update). The update.go caller now passes its request context through to JavaScript execution.
Adds a Runtime struct with a configurable timeout and converts Map to a method on *Runtime. The Runtime enforces its timeout on every invocation, independent of the caller's context deadline. Package-level Map() remains as a convenience wrapper with no timeout.
…support Completes the Runtime conversion for all JS functions. Each method enforces the configured timeout independently of the caller's context. Package-level functions remain as zero-timeout convenience wrappers.
…timeouts Add a *js.Runtime field to client and db structs, initialized with a 5s default timeout matching CouchDB's os_process_timeout. All JS compilation calls now go through d.js instead of package-level functions. Fix a race condition in watchContext by using context.AfterFunc instead of a manual goroutine, ensuring VM interrupt cleanup is properly synchronized.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1166 +/- ##
=======================================
Coverage 61.79% 61.79%
=======================================
Files 293 293
Lines 19362 19365 +3
=======================================
+ Hits 11964 11966 +2
- Misses 6826 6827 +1
Partials 572 572 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
No description provided.