Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#34644 closed Uncategorized (invalid)

social-app-django's JSONField doesn't work as expected.

Reported by: Shaheed Haque Owned by: nobody
Component: Database layer (models, ORM) Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Shaheed Haque)

#34539 introduced a change to 4.2.2 which seems to have broken the social_django code I use. AFAIK, the old behaviour was present well before the apparent regression noted in #34539 between 4.1 and 4.2.

I'm not especially knowledgeable about the issues debated above, but here is what I see. First, social_django sets a JSONField extra_data and then saves the value here:

https://github.com/python-social-auth/social-app-django/blob/8d0a2052d1b22a899454571c62237d23aa25af97/social_django/storage.py#L24

Second, on the stack, I have the frames shown in the attachment "stack frames". The important point is that when I enter the two new lines of code added in #34539, value is a dict, but is flattened into a string by the new code. The result is that the database JSONField has the saved string while previously, the dict was saved as expected. I believe that to be incorrect.

(Perhaps the intent here was to only have this change apply to subclasses of JSONField?)

Advice appreciated.

Attachments (1)

stack.png (45.9 KB ) - added by Shaheed Haque 18 months ago.
stack frames

Download all attachments as: .zip

Change History (4)

by Shaheed Haque, 18 months ago

Attachment: stack.png added

stack frames

comment:1 by Shaheed Haque, 18 months ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 18 months ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: invalid
Status: newclosed
Summary: `get_prep_value` now being called for JSONFieldsocial-app-django's JSONField doesn't work as expected.

Thanks for the report, however, social-app-django has custom implementation of JSONField which should be adapted to changes made in 5c23d9f0c32f166c81ecb6f3f01d5077a6084318 and 0ec60661e61b153e6bcec64649b1b7f524eb3e18. Please report this on their issue tracker.

Note: See TracTickets for help on using tickets.
Back to Top