Skip to content

fix(drizzle): return point field value on optimized update by ID - #17710

Open
vjymisal0 wants to merge 1 commit into
payloadcms:3.xfrom
vjymisal0:fix/17461-point-field-update-return-3x
Open

fix(drizzle): return point field value on optimized update by ID#17710
vjymisal0 wants to merge 1 commit into
payloadcms:3.xfrom
vjymisal0:fix/17461-point-field-update-return-3x

Conversation

@vjymisal0

Copy link
Copy Markdown

What?

point field values are missing from the response when updating a document by ID via the optimized single-row update path in @payloadcms/drizzle.

Why?

Fixes #17461

upsertRow's "no joins needed" optimization builds the .returning() selection only from findManyArgs.columns, ignoring findManyArgs.extras. The point field type is resolved through a raw SQL extra (ST_AsGeoJSON(...)::jsonb) rather than a plain column (its raw column is explicitly disabled via columns[name] = false, since Drizzle handles PostGIS geometry columns poorly - drizzle-team/drizzle-orm#2526). Because the extra was dropped, selectedFields ended up empty for collections whose only "column" entry was the disabled point column, so .returning(undefined) fell back to Drizzle's default full-row return - which returns the raw, unconverted geometry value instead of GeoJSON, and gets silently discarded during transform.

How?

Merge findManyArgs.extras into selectedFields alongside the existing findManyArgs.columns merge, mirroring how the non-optimized path already includes extras when re-fetching via db.query[tableName].findFirst(findManyArgs).

Scope: packages/drizzle (used by the postgres/sqlite adapters). SQLite point fields already skip this codepath (if (adapter.name === 'sqlite') break), so this only affects the postgres/postgis-backed adapters, matching the issue's db: postgres label.

Added an int test (test/fields/int.spec.ts) that creates a doc with a point field, updates an unrelated field, and asserts the point field is present and correct in the update response.

Test status: I traced the root cause through the code (confirmed the exact mechanism, matching the fix suggested in the issue itself) and added a regression test, but could not execute pnpm test:int:postgres in this environment - Docker/Postgres was not available locally, so I'm flagging this honestly rather than claiming a run that didn't happen.

The optimized single-row update path in upsertRow only merged
findManyArgs.columns into the returning() selection, dropping any
findManyArgs.extras entries. The 'point' field type resolves its
value via a raw SQL extra (ST_AsGeoJSON) rather than a plain column,
so it was silently excluded from the update response - falling back
to Drizzle's default full-row return, which mishandles PostGIS
geometry columns.

Fixes payloadcms#17461
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