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

Allow hashing of ErrorDetail #5932

Merged
merged 1 commit into from Apr 20, 2018
Merged

Allow hashing of ErrorDetail #5932

merged 1 commit into from Apr 20, 2018

Conversation

craiga
Copy link
Contributor

@craiga craiga commented Apr 11, 2018

Description

Allow hashing of ErrorDetail objects to address #5919.

I'm not entirely sure if hash(ErrorDetail('msg')) == hash('msg') should be true. I'd love some feedback on this.

@carltongibson
Copy link
Collaborator

carltongibson commented Apr 11, 2018

Hmmm. I can see multiple errors occurring in the same place. Are they the same error? Probably not.

How sophisticated to we need to be here? I might be inclined just to use the id() — Would that solve our use-case?

@craiga
Copy link
Contributor Author

craiga commented Apr 11, 2018

I've assumed that a hash should behave in the same way that == does, which feels correct because it's following the principle of least astonishment.

TBH, my client's code which led me to this ticket is breaking my brain. They appear to somehow be getting a field name as an ErrorDetail, which breaks when they effectively do this:

my_error_dict = {
    ErrorDetail('field_name'): ErrorDetail('Some validation message.'),
}

Is this something which should happen?

If so, my_error_dict['field_name'] seems reasonable.

@craiga craiga changed the title Allow hashing of ErrorDetail to fix #5919 Allow hashing of ErrorDetail Apr 12, 2018
@craiga
Copy link
Contributor Author

craiga commented Apr 13, 2018

@carltongibson Please let me know if there's anything else I can do to have this PR included in the next release.

@carltongibson
Copy link
Collaborator

carltongibson commented Apr 13, 2018

@craiga Will do. I'm just having a little think about it. 👍

@carltongibson carltongibson added this to the 3.8.3 Release milestone Apr 20, 2018
Copy link
Collaborator

@carltongibson carltongibson left a comment

OK. This looks fine to me. We can address anything more complex as and when there's a demonstrated need for it. (i.e. a test case 🙂)

Thanks for the input @craiga!

@carltongibson carltongibson merged commit 2ebd479 into encode:master Apr 20, 2018
1 check passed
@nitrag
Copy link

nitrag commented Jun 4, 2018

Sorry to bother, when can I see this in a new release? It's been a while...

@carltongibson
Copy link
Collaborator

carltongibson commented Jun 4, 2018

Hi @nitrag. It looks like we’re targeting the end of this month for 3.9. Pip has first class VCS support if you need it urgently.

@rpkilby rpkilby modified the milestones: 3.8.3 Release, 3.9 Release Aug 29, 2018
@craiga craiga deleted the hash-error-detail branch Nov 9, 2018
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
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.

None yet

4 participants