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

Add support for alternative IDs using Hashids #2564

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

Conversation

gabrielgiroe1
Copy link
Collaborator

@gabrielgiroe1 gabrielgiroe1 commented Mar 6, 2024

Description

Fixes #2563

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

@gabrielgiroe1 gabrielgiroe1 marked this pull request as draft March 6, 2024 14:28
Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
Copy link

codeclimate bot commented Mar 6, 2024

Code Climate has analyzed commit d58b9c6 and detected 0 issues on this pull request.

View more on Code Climate.

@gabrielgiroe1 gabrielgiroe1 marked this pull request as ready for review March 7, 2024 10:19
Copy link
Contributor

github-actions bot commented Apr 3, 2024

This PR has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Apr 3, 2024
@Paul-Bob Paul-Bob removed the Stale label Apr 3, 2024
@adrianthedev
Copy link
Collaborator

What is the status on this one?

@Paul-Bob Paul-Bob marked this pull request as draft April 18, 2024 09:34
@adrianthedev
Copy link
Collaborator

@gabrielgiroe1 what is the status on this one?

@gabrielgiroe1 gabrielgiroe1 marked this pull request as ready for review April 18, 2024 20:36
@Paul-Bob
Copy link
Contributor

The real ID is leaking on attach request params, let's try to find out more spots like this one and fix them.

Paul-Bob and others added 10 commits May 8, 2024 20:51
…2749)

Bumps the npm_and_yarn group with 1 update in the / directory: [trix](https://github.com/basecamp/trix).


Updates `trix` from 2.1.0 to 2.1.1
- [Release notes](https://github.com/basecamp/trix/releases)
- [Commits](basecamp/trix@v2.1.0...v2.1.1)

---
updated-dependencies:
- dependency-name: trix
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com>
Co-authored-by: Adrian Marin <adrian@adrianthedev.com>
git reset
Gemfile Outdated Show resolved Hide resolved
* tweaks

* .

* lint

* .

* test

* tweak

* revert tests on special branch
Copy link
Collaborator

@adrianthedev adrianthedev left a comment

Choose a reason for hiding this comment

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

The PR is generally ok.
I have a couple of questions and one more critical change request.

Good job taking it this far!

lib/avo/plugin_manager.rb Outdated Show resolved Hide resolved
lib/avo/fields/belongs_to_field.rb Outdated Show resolved Hide resolved
lib/avo/base_resource.rb Outdated Show resolved Hide resolved
Comment on lines 241 to 242
def target_resource(record: @record, polymorphic_model_class: value&.class)
@target_resource ||= if use_resource.present?
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not right.
We can't memoize a value in a method if the method takes arguments.

If one time the record is a User, it will get memoized as that user. Then, the second time when the record is a team, it will return the first user, resulting in a bug.

Did I read that correctly?

@@ -229,22 +238,22 @@ def database_id
id
end

def target_resource
def target_resource(record: @record, polymorphic_model_class: value&.class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I'd like to maintain target_resource as a method without params so we can quickly call field.target_resource when we need to.

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

Successfully merging this pull request may close these issues.

Support for Alternative IDs (e.g., Hashid)
3 participants