fix(drizzle): return point field value on optimized update by ID - #17710
Open
vjymisal0 wants to merge 1 commit into
Open
fix(drizzle): return point field value on optimized update by ID#17710vjymisal0 wants to merge 1 commit into
vjymisal0 wants to merge 1 commit into
Conversation
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
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.
What?
pointfield 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 fromfindManyArgs.columns, ignoringfindManyArgs.extras. Thepointfield type is resolved through a raw SQL extra (ST_AsGeoJSON(...)::jsonb) rather than a plain column (its raw column is explicitly disabled viacolumns[name] = false, since Drizzle handles PostGIS geometry columns poorly - drizzle-team/drizzle-orm#2526). Because the extra was dropped,selectedFieldsended 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.extrasintoselectedFieldsalongside the existingfindManyArgs.columnsmerge, mirroring how the non-optimized path already includesextraswhen re-fetching viadb.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'sdb: postgreslabel.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:postgresin this environment - Docker/Postgres was not available locally, so I'm flagging this honestly rather than claiming a run that didn't happen.