test(plugins): reproduce Postgres plugin-storage query/count/index/order bugs (red baseline for #1) - #4
Open
vedanshujain wants to merge 1 commit into
Open
Conversation
…der bugs
`_plugin_storage.data` is a plain `text` column and plugin storage had only
ever been exercised on SQLite. On Postgres the query/count/index/order paths
build the JSON accessor as an uncast `data ->> 'field'`, which is broken four
ways. This adds a dialect-parametric regression suite (via describeEachDialect)
pinning each failure mode:
(a) numeric RangeFilter across a multi-digit boundary (9/10/100, gte:10) —
`'9' >= '10'` is TRUE lexically, so 9 leaks in (over-count / oversell)
(b) count() with the same numeric guard returns 3 instead of 2
(c) createStorageIndexes over `data ->> 'sku'` raises
"operator does not exist: text ->> unknown"
(d) numeric orderBy returns [10, 100, 9] instead of [9, 10, 100]
The suite passes on SQLite (json_extract is already typed) and FAILS on the
Postgres dialect on this branch — it is the red baseline. The stacked fix
(#1, jsonb + numeric cast) turns the Postgres dialect green.
Postgres runs only when EMDASH_TEST_PG is set.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TX9YciGFRZX9aF2UcQ6rUW
|
This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity. If you're still working on this, please push an update or leave a 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.
Why this PR is first in the stack
_plugin_storage.datais a plaintextcolumn, and plugin storage had only everbeen exercised on SQLite. On Postgres the query / count / index / order paths build
the JSON accessor as an uncast
data ->> 'field', which is broken four distinctways. This PR adds a dialect-parametric regression suite (wired through
describeEachDialect) that pins each failure mode, so reviewers can see the bugreproduced before the fix.
This PR is the red baseline. The Postgres dialect fails here on purpose; the
stacked fix (#1) turns it green. SQLite passes throughout, because
json_extractalready returns a typed value — which is exactly why the bug went unnoticed.
Failure modes covered
RangeFilteracross a multi-digit boundary — store9 / 10 / 100,query
{ stock: { gte: 10 } }.'9' >= '10'is TRUE lexically, so9leaks intothe result — an over-count / oversell. Asserts exactly
{10, 100}.count({ stock: { gte: 10 } })— asserts2, not the lexical3.createStorageIndexesUNIQUE expression index overdata ->> 'sku'— onPostgres this raises
operator does not exist: text ->> unknown. Assertserrors: [], index created, duplicate insert rejected.orderBy— asserts[9, 10, 100], not the lexical[10, 100, 9].Evidence (
EMDASH_TEST_PGset → localurumi-pg-teston 127.0.0.1:55432)On this branch (no fix) — RED on Postgres, GREEN on SQLite:
With #1 stacked on top — GREEN on both dialects:
CI note
The
Testsjob runs a real Postgres service withEMDASH_TEST_PGset and thedefault vitest config picks up
tests/integration/plugins/**, so the Postgresjob is red on this PR by design. It goes green once #1 lands on top of it. The
Integration Testsjob (no Postgres) stays green. This is a stacked, test-first PR— it is meant to merge as part of the stack, not standalone.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TX9YciGFRZX9aF2UcQ6rUW