Skip to content

fix(rds): star columns, empty where objects, nullable limit/offset - #279

Merged
bentsku merged 1 commit into
mainfrom
fix-rds-utils
Aug 12, 2026
Merged

fix(rds): star columns, empty where objects, nullable limit/offset#279
bentsku merged 1 commit into
mainfrom
fix-rds-utils

Conversation

@bentsku

@bentsku bentsku commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

A customer's AppSync JS resolver calling select({ table, columns: ['*'], limit, offset }) from @aws-appsync/utils/rds fails in several ways. Root causes in this library:

  1. columns: ['*'] rendered SELECT "*", which PostgreSQL rejects with column "*" does not exist (SQLState 42703). AWS leaves a bare * unquoted.
  2. An empty where object ({} or {and: []}) emitted a dangling WHERE keywordSELECT ... WHERE LIMIT :P0syntax error at or near "LIMIT" (SQLState 42601) — in SELECT, UPDATE, and DELETE statements. AWS omits the clause entirely.
  3. limit: 0 / offset: 0 were silently dropped by truthy checks. AWS emits them as parameters.

(The remaining customer symptom — a TypeError when the query has no arguments at all — is a ctx.args construction issue in the AppSync provider, not in this library, and is handled separately.)

Changes

  • rds/index.js:
    • quoteIdentifier(): a bare * stays unquoted. Note AWS does quote a qualified star (persons.*"persons"."*"), so only the exact string * is special-cased.
    • SELECT/UPDATE/DELETE: skip the WHERE keyword when the built clause is empty.
    • limit/offset: nullish checks (!= null) so 0 is emitted and null/omitted is skipped.
  • __tests__/helpers.js: the local harness now exposes ctx.args as {} when the context carries no arguments, matching the AppSync runtime (verified: AWS EvaluateCode normalizes ctx.args even for an entirely empty context).
  • __tests__/resolvers.test.js: new select statement edge cases describe block (10 tests), including the customer's exact resolver shape. All new snapshots recorded from real AWS AppSync EvaluateCode.
  • package.json: version bump to 0.1.3.

Verification

  • npm test: 85 passed, 83 snapshots (10 newly AWS-recorded).
  • End-to-end against the customer reproduction sample with LocalStack Pro dev + APPSYNC_JS_LIBS_VERSION=fix-rds-utils: the DatabaseErrorException is gone and the generated statement executes (SELECT * FROM "domain"."color" LIMIT :P0).

🤖 Generated with Claude Code

select() with columns: ['*'] rendered SELECT "*", which PostgreSQL rejects
(column "*" does not exist, 42703). A bare * now stays unquoted, matching
AWS; a qualified persons.* remains quoted ("persons"."*") as AWS does.

An empty where object ({} or {and: []}) emitted a dangling WHERE keyword
(SELECT ... WHERE  LIMIT :P0 -> syntax error at or near "LIMIT", 42601) in
SELECT/UPDATE/DELETE; the clause is now omitted when it renders empty.

limit/offset now use nullish checks so 0 is emitted as a parameter, and the
local test harness exposes ctx.args as {} when no arguments are passed,
matching the AppSync runtime.

All new snapshots recorded from AWS AppSync EvaluateCode.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bentsku
bentsku marked this pull request as ready for review August 12, 2026 17:06
@bentsku
bentsku merged commit a117752 into main Aug 12, 2026
4 checks passed
@bentsku
bentsku deleted the fix-rds-utils branch August 12, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant