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

fix(db-postgres): ensure deletion of numbers and texts in upsertRow #11787

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

akhrarovsaid
Copy link
Contributor

@akhrarovsaid akhrarovsaid commented Mar 20, 2025

What?

This PR fixes an issue while using text & number fields with hasMany: true where the last entry would be unreachable, and thus undeletable, because the transformForWrite function did not track these rows for deletion. This causes values that should've been deleted to remain in the edit view form, as well as the db, after a submission.

This PR also properly threads the placeholder value from admin.placeholder to text & number hasMany: true fields.

Why?

To remove rows from the db when a submission is made where these fields are empty arrays, and to properly show an appropriate placeholder when one is set in config.

How?

Adjusting transformForWrite and the traverseFields to keep track of rows for deletion.

Fixes #11781

Before:

Editing---Post-dbpg-before--Payload.webm

After:

Editing---Post--dbpg-hasmany-after-Payload.webm

Copy link
Member

@r1tsuu r1tsuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses integration tests that point at what was fixed.

@akhrarovsaid
Copy link
Contributor Author

Hey @r1tsuu

Thanks for the feedback! I've gone ahead and added two hasMany tests - one for number and one for text fields. Let me know if this is sufficient here, or you'd like more thorough tests.

Thank you!

r1tsuu
r1tsuu previously approved these changes Mar 20, 2025
Copy link
Member

@r1tsuu r1tsuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

@akhrarovsaid akhrarovsaid requested a review from r1tsuu March 21, 2025 14:51
Copy link
Member

@r1tsuu r1tsuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let's also hear @DanRibbens's feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

text hasMany placeholder, text hasMany null
2 participants