Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix raising on nullable fields part ofUniqueConstraint#9531

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

browniebroke
Copy link
Member

@browniebrokebrowniebroke commentedSep 11, 2024
edited
Loading

Description

Fix#9378

  • Add a few failing tests
  • Fix cause of the problem

Copy link
Member

@auvipyauvipy left a comment

Choose a reason for hiding this comment

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

any progress here?

@browniebroke
Copy link
MemberAuthor

any progress here?

Not really, I've dropped the ball a bit on this one. Will try to make some progress...

@browniebrokebrowniebroke marked this pull request as ready for reviewOctober 14, 2024 18:14
@browniebroke
Copy link
MemberAuthor

Oh well, that's all passing now... Hopefully that covers the main use case reported in#9378

There is also the other semi-related bug#9358 which is NOT in scope of this PR, I believe it will be fixed by#9360

@SorianoMarmol
Copy link

Is a new version expected with this fix and others related like#9360 ? The support for UniqueConstraint is not complete and may cause issues…

Copy link
Member

@pauloxnetpauloxnet left a comment

Choose a reason for hiding this comment

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

LGTM

BillSchumacher reacted with heart emoji
@auvipyauvipy merged commita8595a8 intoencode:masterDec 14, 2024
8 checks passed
@auvipy
Copy link
Member

thanks!

pauloxnet reacted with thumbs up emojibrowniebroke reacted with hooray emoji

@auvipyauvipy added the Bug labelDec 14, 2024
@browniebrokebrowniebroke deleted the nullable-unique-constraint-fields branchDecember 14, 2024 10:58
@browniebrokebrowniebroke added this to the3.16 milestoneJan 16, 2025
@mdellweg
Copy link

I'm not entirely sure under which circumstances, but this change turns aSerializerMethodField() whose name appears in the uniqueness constraint of the underlying model into aHiddenField(default=None).

I'll keep investigating.

@mdellweg
Copy link

mdellweg commentedApr 7, 2025
edited
Loading

Here is a (minimal???) reproducer:

deftest_tba():classTestModel(models.Model):field_1=models.IntegerField(null=True)field_2=models.IntegerField(null=True)classMeta:unique_together= (("field_1","field_2"),)classTestSerializer(serializers.ModelSerializer):field_1=serializers.SerializerMethodField()defget_field_1(self)->str:return"TEST"classMeta:model=TestModelfields= ["field_1","field_2"]fields=TestSerializer().fieldsassertisinstance(fields["field_1"],serializers.SerializerMethodField)
    assert isinstance(fields["field_1"], serializers.SerializerMethodField)E   AssertionError: assert FalseE    +  where False = isinstance(HiddenField(default=None), <class 'rest_framework.fields.SerializerMethodField'>)E    +    where <class 'rest_framework.fields.SerializerMethodField'> = serializers.SerializerMethodField

@stianjensen
Copy link
Contributor

I'm not entirely sure under which circumstances, but this change turns a SerializerMethodField() whose name appears in the uniqueness constraint of the underlying model into a HiddenField(default=None).

I'll keep investigating.

Seeing the same thing in my codebase when upgrading to 3.16!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@pauloxnetpauloxnetpauloxnet approved these changes

@auvipyauvipyauvipy approved these changes

@SorianoMarmolSorianoMarmolSorianoMarmol approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
3.16
Development

Successfully merging this pull request may close these issues.

3.15 is raising required error on model nullable fields
6 participants
@browniebroke@SorianoMarmol@auvipy@mdellweg@stianjensen@pauloxnet

[8]ページ先頭

©2009-2025 Movatter.jp