payload
payload copied to clipboard
Data is immediately published even though updating with `draft: true` option
Link to reproduction
https://github.com/ikenox/payload/commit/3b88f981d9c66297759a83fd725b8822e7d43568
Describe the Bug
Even if specifying draft: true option when update, the data is published immediately.
I previously using payload v2.11.1 and it doesn't have this behavior, so it seems to be appeared on recent payload version.
To Reproduce
I added a failing test.
https://github.com/ikenox/payload/commit/3b88f981d9c66297759a83fd725b8822e7d43568
Command:
pnpm test:int:postgres _community
Result:
FAIL test/_community/int.spec.ts (8.231 s)
_Community Tests
✕ local API example (42 ms)
● _Community Tests › local API example
expect(received).toEqual(expected) // deep equality
Expected: "LOCAL API EXAMPLE"
Received: "UPDATED"
68 | })
69 |
> 70 | expect(currentPost.text).toEqual('LOCAL API EXAMPLE')
| ^
71 | })
72 | })
73 |
at Object.toEqual (test/_community/int.spec.ts:70:30)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 8.261 s, estimated 9 s
Ran all test suites matching /_community/i.
ELIFECYCLE Command failed with exit code 1.
Database state:
# select * from posts;
id | text | updated_at | created_at | _status
----+--------------+----------------------------+----------------------------+-----------
1 | example post | 2024-05-10 02:23:15.056+00 | 2024-05-10 02:23:15.056+00 | draft
2 | UPDATED | 2024-05-10 02:23:15.324+00 | 2024-05-10 02:23:15.272+00 | published
# select * from _posts_v;
id | version_text | version_updated_at | version_created_at | version__status | created_at | updated_at | latest
----+-------------------+----------------------------+----------------------------+-----------------+----------------------------+----------------------------+--------
1 | example post | 2024-05-10 02:23:15.061+00 | 2024-05-10 02:23:15.056+00 | draft | 2024-05-10 02:23:15.056+00 | 2024-05-10 02:23:15.056+00 | t
3 | UPDATED | 2024-05-10 02:23:15.333+00 | 2024-05-10 02:23:15.272+00 | draft | 2024-05-10 02:23:15.314+00 | 2024-05-10 02:23:15.314+00 | t
2 | LOCAL API EXAMPLE | 2024-05-10 02:23:15.277+00 | 2024-05-10 02:23:15.272+00 | published | 2024-05-10 02:23:15.272+00 | 2024-05-10 02:23:15.272+00 | f
This database state seems inconsistent, because text=UPDATED is published on posts table but not on _posts_v table.
Payload Version
2.16.1 (9df5ab8a1)
Adapters and Plugins
db-postgres