Skip to content

Support New DT-Import Non-Overwrite Setting #2668

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

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

Conversation

kodinkat
Copy link
Contributor

@kodinkat kodinkat commented Apr 9, 2025

No description provided.

@corsacca corsacca requested a review from Copilot April 10, 2025 13:48
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (3)
  • dt-posts/dt-posts-endpoints.php: Language not supported
  • dt-posts/dt-posts-hooks.php: Language not supported
  • dt-posts/dt-posts.php: Language not supported

@corsacca
Copy link
Member

@kodinkat does dt_ignore_duplicated_post_fields check if the 2 values are different or if any value exists on the existing record? I'm having trouble following the logic.
The previous behavior is that all fields are updated.
The new behavior:

  • for single values fields: we don't update the field if it already has a value
  • for multiple value fields: we only add new values if they don't already exist

Does that sound right?

@corsacca
Copy link
Member

I'm curious about adding this feature to the update_post function. Something like do_not_overwrite_exsting_fields param is past in, then it does the check there.

We'll also need to write some unit tests for this. AI should be good at this part.

@kodinkat
Copy link
Contributor Author

@kodinkat does dt_ignore_duplicated_post_fields check if the 2 values are different or if any value exists on the existing record? I'm having trouble following the logic. The previous behavior is that all fields are updated. The new behavior:

  • for single values fields: we don't update the field if it already has a value
  • for multiple value fields: we only add new values if they don't already exist

Does that sound right?

This is correct, as new logic only updates/adds value if field does not already contain it. Therefore, ignoring any duplicates.

@kodinkat
Copy link
Contributor Author

I'm curious about adding this feature to the update_post function. Something like do_not_overwrite_exsting_fields param is past in, then it does the check there.

We'll also need to write some unit tests for this. AI should be good at this part.

Sounds good, maybe tackle as a new ticket, once functionality has been merged in?

@corsacca
Copy link
Member

On this one lets go slower.
Lets move the do not overwrite to the update post
and lets create unit tests to check that things are working as expected.

@kodinkat
Copy link
Contributor Author

@corsacca pls see latest shape and let me know if this holds up for you...

@corsacca
Copy link
Member

corsacca commented Jun 2, 2025

@kodinkat can you make sure there are tests for each field type?

@corsacca
Copy link
Member

corsacca commented Jun 18, 2025

@kodinkat

A clarification.

$original = [
"name" => "bob",
"phone" => "1234"
]
$update = [
"name" => "Fred",
"phone" => "2903",
"email" => "test@test.com"
]

The results should be

[
"name" => "bob",
"phone" => "1234",
"email" => "test@test.com"
]

Because we have the "dont_overwrite_existing_fields" set to true.

Right now the result is

[
"name" => "Fred",
"phone" => "2903",
"email" => "test@test.com"
]

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

Successfully merging this pull request may close these issues.

2 participants