这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@JohnVillalovos
Copy link
Contributor

@JohnVillalovos JohnVillalovos commented Jul 11, 2025

When using the API to update a resource it would cause multiple custom attributes with the same ID to be stored in the
custom_attribute_values table in the database.

For example if currently have the custom attribute "Test Number" set to 1 for the resource. And then use the API to change it to a value of 2. In the custom_attribute_values table there will now be both entries stored. When using the web interface to edit the custom attribute it will delete the old value from the database table and then add new value.

Change it so that the old value will be deleted and the new value added.

Closes: #680

@JohnVillalovos JohnVillalovos force-pushed the jlvillal/attributes branch 2 times, most recently from ae0da75 to 43ccff6 Compare July 11, 2025 19:12
@JohnVillalovos JohnVillalovos requested a review from Copilot July 13, 2025 15:52

This comment was marked as outdated.

Copy link

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.

Pull Request Overview

This pull request fixes a bug where the API would create duplicate custom attribute values in the database instead of updating existing ones. The fix simplifies the ChangeAttributes method to use the existing ChangeAttribute method for each attribute, ensuring proper update behavior.

  • Replaces complex diff-based logic with simpler per-attribute processing
  • Eliminates duplicate custom attribute storage by using the existing ChangeAttribute method
  • Aligns API behavior with web interface behavior for custom attribute updates

…sources

When using the API to update a resource it would cause multiple custom
attributes with the same ID to be stored in the
`custom_attribute_values` table in the database.

For example if currently have the custom attribute "Test Number" set to
1 for the resource. And then use the API to change it to a value of 2.
In the `custom_attribute_values` table there will now be both entries
stored. When using the web interface to edit the custom attribute it
will delete the old value from the database table and then add new
value.

Change it so that the old value will be deleted and the new value added.

Closes: #680
@JohnVillalovos
Copy link
Contributor Author

I tested this using the API on over 1000 records. I read a resource, wrote the resource, and then verified the resource was the same as before. I also checked the SQL database and saw that the extra entries in custom_attribute_values were removed as they should be.

@JohnVillalovos JohnVillalovos merged commit 2351c60 into develop Jul 24, 2025
11 checks passed
@JohnVillalovos JohnVillalovos deleted the jlvillal/attributes branch July 24, 2025 15:14
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.

[BUG] Using the API to update a resource causes multiple CustomAttributes values to be added

2 participants