Fix Postgres compatibility for shipping methods queries - #31
Merged
Merged
Conversation
…patibility
EmDash's .query({ where: ... }) builds SQLite-style SQL that fails on
Postgres with 'syntax error at or near "="'. This affects live Railway
demo on Neon (Postgres).
Changes:
- cart/shipping-methods: Fetch all methods, filter by zoneId + enabled in JS
- cart/shipping-method: Same fetch+filter pattern
- admin-api deleteShippingZone: Fetch all methods, check zoneId match in JS
All queries now fetch with limit and filter in JavaScript, working across
both SQLite and Postgres. Handles enabled field as both boolean (true) and
numeric (1) for cross-database compatibility.
Verified:
- All tests pass (85 pass, 0 fail)
- Typecheck clean
- Build succeeds
Co-authored-by: Timchosen Uzua <timchosen@gmail.com>
cavewebs
commented
Sep 15, 2026
cavewebs
left a comment
Contributor
Author
There was a problem hiding this comment.
Eng review — APPROVE
Matches the validated live hot-patch: drop EmDash storage where on shipping_methods (Postgres syntax error near =), fetch+JS filter on zoneId + enabled (true or 1). Also correctly fixes deleteShippingZone the same way.
CI still running on this SHA. Non-blocking: no new unit test for the filter path (live QA already PASS $5 / Stripe). Indent in cart.ts looks a bit shifted in the diff — worth a format pass if prettier complains.
Ready to merge after CI green + your call (Railway still needs upgrade past hot-patch/0.1.3 for durable deploy).
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.
Problem
Live Railway demo (EmDash storage on Neon Postgres) fails
cart/shipping-methodsAPI when attempting to query shipping methods with:Error:
syntax error at or near "="on PostgresRoot cause: EmDash's
.query({ where: ... })implementation builds SQLite-style SQL that doesn't translate correctly to Postgres syntax. The WHERE clause generation is broken for Postgres databases.Solution
Replace all problematic
.wherequeries with a fetch+filter pattern that works across both SQLite and Postgres:Changes Made
packages/core/src/routes/cart.tscart/shipping-methodsroute: Fetch all methods, filter byzoneIdandenabledin JavaScriptcart/shipping-methodroute: Same fetch+filter patternwhereoptional in query optionspackages/core/src/routes/admin-api.tsdeleteShippingZonehandler: Fetch all methods, checkzoneIdmatch in JavaScript instead of using.whereCross-Database Compatibility
The
enabledfield is checked as both boolean (true) and numeric (1) because:booleanVerification
✅ All tests pass: 85 pass, 0 fail
✅ Typecheck clean: No TypeScript errors
✅ Build succeeds: Package compiles without issues
Testing Steps
To verify the fix on Railway/Neon:
POST /cart/shipping-methodswith a valid shipping addressPOST /cart/shipping-methodwith amethodIdto select a methodNotes
.whereclause building remains broken on Postgres.whereclauses entirely in shipping-related queries.whereclauses; they should be audited if Postgres support is requiredRelated