Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is immediately published even though updating with draft: true option #6307

Open
ikenox opened this issue May 10, 2024 · 0 comments
Open
Labels
[possible-bug] Possible bug which hasn't been reproduced yet

Comments

@ikenox
Copy link

ikenox commented May 10, 2024

Link to reproduction

ikenox@3b88f98

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.

ikenox@3b88f98

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 (9df5ab8)

Adapters and Plugins

db-postgres

@ikenox ikenox added the [possible-bug] Possible bug which hasn't been reproduced yet label May 10, 2024
@ikenox ikenox changed the title data is immediately published even if updating with draft: true option Data is immediately published even if updating with draft: true option May 10, 2024
@ikenox ikenox changed the title Data is immediately published even if updating with draft: true option Data is immediately published even though updating with draft: true option May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[possible-bug] Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant