Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/drizzle/src/upsertRow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ export const upsertRow = async <T extends Record<string, unknown> | TypeWithID>(
}
}

// Fields such as `point` are resolved via raw SQL expressions (e.g. ST_AsGeoJSON)
// rather than plain columns, and are tracked in `findManyArgs.extras`. Without
// merging them in here, `.returning()` would either omit them or fall back to
// returning every column (including the raw, unconverted value) once selectedFields
// is non-empty but missing these keys.
if (findManyArgs.extras) {
for (const [name, extra] of Object.entries(findManyArgs.extras)) {
selectedFields[name] = extra
}
}

const docs = await drizzle
.update(adapter.tables[tableName])
.set(row)
Expand Down
29 changes: 29 additions & 0 deletions test/fields/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,35 @@ describe('Fields', () => {
expect(doc.group).toMatchObject(group)
})

it('should return point field on update by id', async () => {
if (payload.db.name === 'sqlite') {
return
}

const created = await payload.create({
collection: 'point-fields',
data: {
group,
localized,
point,
},
})

// Update an unrelated field and ensure the point field is still
// present in the response - https://github.com/payloadcms/payload/issues/17461
const updated = await payload.update({
id: created.id,
collection: 'point-fields',
data: {
group,
},
})

expect(updated.point).toEqual(point)
expect(updated.localized).toEqual(localized)
expect(updated.group).toMatchObject(group)
})

it('should not create duplicate point when unique', async () => {
if (payload.db.name === 'sqlite') {
return
Expand Down
Loading