Skip to content

Commit c9584a9

Browse files
authored
fix(ui): scheduled publish not showing related events in postgres (#10481)
Since postgres uses number IDs by default, when we were storing the relationship field value with postgres we weren't able to query it This fixes that problem by casting the ID to always a string making it safe for querying inside the JSON field
1 parent 69fac59 commit c9584a9

File tree

2 files changed

+16
-9
lines changed
  • packages
    • payload/src/versions/schedule
    • ui/src/elements/PublishButton/ScheduleDrawer

2 files changed

+16
-9
lines changed

packages/payload/src/versions/schedule/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CollectionSlug, GlobalSlug } from '../../index.js'
33
export type SchedulePublishTaskInput = {
44
doc?: {
55
relationTo: CollectionSlug
6-
value: number | string
6+
value: string
77
}
88
global?: GlobalSlug
99
locale?: string

packages/ui/src/elements/PublishButton/ScheduleDrawer/index.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Where } from 'payload'
55

66
import { useModal } from '@faceless-ui/modal'
77
import { getTranslation } from '@payloadcms/translations'
8+
import * as qs from 'qs-esm'
89
import React from 'react'
910
import { toast } from 'sonner'
1011

@@ -78,7 +79,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
7879
}, [localization, i18n])
7980

8081
const fetchUpcoming = React.useCallback(async () => {
81-
const params: { sort: string; where: Where } = {
82+
const query: { sort: string; where: Where } = {
8283
sort: 'waitUntil',
8384
where: {
8485
and: [
@@ -97,29 +98,35 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
9798
}
9899

99100
if (collectionSlug) {
100-
params.where.and.push({
101+
query.where.and.push({
101102
'input.doc.value': {
102-
equals: id,
103+
equals: String(id),
103104
},
104105
})
105-
106-
params.where.and.push({
106+
query.where.and.push({
107107
'input.doc.relationTo': {
108108
equals: collectionSlug,
109109
},
110110
})
111111
}
112112

113113
if (globalSlug) {
114-
params.where.and.push({
114+
query.where.and.push({
115115
'input.global': {
116116
equals: globalSlug,
117117
},
118118
})
119119
}
120120

121121
const { docs } = await requests
122-
.get(`${serverURL}${api}/payload-jobs`, { params })
122+
.post(`${serverURL}${api}/payload-jobs`, {
123+
body: qs.stringify(query),
124+
headers: {
125+
'Accept-Language': i18n.language,
126+
'Content-Type': 'application/x-www-form-urlencoded',
127+
'X-HTTP-Method-Override': 'GET',
128+
},
129+
})
123130
.then((res) => res.json())
124131

125132
setUpcomingColumns(buildUpcomingColumns({ dateFormat, docs, i18n, localization, t }))
@@ -146,7 +153,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
146153
doc: collectionSlug
147154
? {
148155
relationTo: collectionSlug,
149-
value: id,
156+
value: String(id),
150157
}
151158
: undefined,
152159
global: globalSlug || undefined,

0 commit comments

Comments
 (0)