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

Authorize uuid for update_positions on ResourceController #4992

Conversation

julienanne
Copy link
Contributor

@julienanne julienanne commented Mar 23, 2023

Summary

In the backend section, from Ref 248b39f we can't sort object list when we use uuid for the object's id.
We need to allow records save for the case of uuid.
This change need to be backported until the version 3.1.0 if I'm right ;)

Hope it can help.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@julienanne julienanne requested a review from a team as a code owner March 23, 2023 13:58
@github-actions github-actions bot added the changelog:solidus_backend Changes to the solidus_backend gem label Mar 23, 2023
@julienanne julienanne marked this pull request as draft March 23, 2023 14:14
@julienanne
Copy link
Contributor Author

Sorry seems the CI have not the function gen_random_uuid() on postgres for instance so this PR can be closed if uuid is not in your vision at short terms ;)

Have a nice day ;)

@kennyadsl
Copy link
Member

It seems like Postgres needs to load pgcrypto extension for gen_random_uuid to work. I don't know if we can give for granted that people have that installed, and if we add it, it's a breaking change for people already using Solidus.

What if we keep the change without the UUIDs test you added? Do you see any cons for those who are not using UUIDs?

@julienanne
Copy link
Contributor Author

@kennyadsl thanks for answer true fact for the breaking change.

Indeed good idea to keep the code even if the spec don't show the need of change but in this particular case it is ok in my opinion.

And I see no cons due to the fact that "already in place" specs are green on my computer. So ok for me for people who are not using UUIDs.

I will modify this PR.

Thanks

@julienanne julienanne force-pushed the improve-update-positions-compatibility-with-uuid branch 2 times, most recently from 5667c49 to 7fea311 Compare April 12, 2023 08:08
@julienanne
Copy link
Contributor Author

@kennyadsl it seems that I have doing something wrong (CI is red) but I don't know what, can you help me please ?

@kennyadsl
Copy link
Member

Should be fixed when we merge #5010, I will ask you for a rebase when done, thanks!

@kennyadsl
Copy link
Member

@julienanne please rebase now!

@julienanne julienanne force-pushed the improve-update-positions-compatibility-with-uuid branch from 7fea311 to cae6e5e Compare April 12, 2023 08:51
@julienanne
Copy link
Contributor Author

@kennyadsl seems better thanks ;)

@julienanne julienanne marked this pull request as ready for review April 12, 2023 09:47
@kennyadsl
Copy link
Member

@solidusio/core-team thoughts?

Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

👍

@@ -82,7 +82,7 @@ def update_positions
records = model_class.where(id: positions.keys).to_a

positions.each do |id, index|
records.find { |r| r.id == id.to_i }&.set_list_position(index)
records.find { |r| r.id.to_s == id }&.set_list_position(index)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking, but given we're not testing it, adding a code comment here would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I write a com, good idea indeed when two implementations make the spec green and we want one implementation more than the other.
But my English is not accurate so feel free to suggest something more accurate if needed ;)
Thanks ;)

@julienanne julienanne force-pushed the improve-update-positions-compatibility-with-uuid branch from cae6e5e to 5832d47 Compare April 13, 2023 06:44
@julienanne
Copy link
Contributor Author

No spec red on my local machine, flaky test ?

@kennyadsl kennyadsl merged commit 554d335 into solidusio:master Apr 14, 2023
@kennyadsl
Copy link
Member

@julienanne thanks for your contribution! 🎉

@julienanne
Copy link
Contributor Author

@kennyadsl Do you need backports for v3.3, v3.2 and v3.1 or you think it is not necessary ?
If yes if I remember right I have to do one PR per branch.

Have a nice day

@kennyadsl
Copy link
Member

The backport would have been automatic if I remembered to add the proper labels to the PR, I'm sorry! Let me see if we can trigger the workflow anyway after the PR is merged.

@kennyadsl
Copy link
Member

@waiting-for-dev suggested to add the labels even if the PR is merged, and it should work. Let me try!

@github-actions
Copy link

💚 All backports created successfully

Status Branch Result
v3.2
v3.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@github-actions
Copy link

💚 All backports created successfully

Status Branch Result
v3.2
v3.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@kennyadsl
Copy link
Member

Backport done @julienanne! 3.1 is not supported anymore following our policy here, though.

@julienanne
Copy link
Contributor Author

Thanks
Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v3.3 Backport this pull-request to v3.3 changelog:solidus_backend Changes to the solidus_backend gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants