Skip to content

Conversation

robertobarreda
Copy link

Description of the Change

REGRESION (version 2.6)

In previous versions, OneToOneFields without Hyperlink settings in its Serializer doesn't render anything.

In version 2.6, an empty JSON object is rendered.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • changelog entry added to CHANGELOG.md
  • author name in AUTHORS

REGRESION (version 2.6)

In previous versions, OneToOneFields without Hyperlink settings in its Serializer doesn't render anything.

In version 2.6, an empty JSON object is rendered.
@sliverc
Copy link
Member

sliverc commented Oct 8, 2018

Thanks for your contribution.

The specification actually states to return null for empty to-one relationships.
See http://jsonapi.org/format/#document-resource-object-linkage

So I think this means this is actually a bug rather than a regression - the bug is just different in previous versions where relationship is not rendered at all and now where it is rendered as empty dict.

So I would prefer when the PR could be adjusted to return null instead of skipping it. A test would also need to be added so we can make sure that this bug doesn't occur again in the future.

@robertobarreda
Copy link
Author

IMHO I'd pass this fix (be consistent with the previous behaviour) and do another PR to fix the rendering according to the spec.

@sliverc
Copy link
Member

sliverc commented Oct 9, 2018

I do not think we should make Django JSON API releases bugwards-compatible especially as this is not documented anywhere that relationships should be skipped when not available but is actually a bug according to our first DJA goal to be compliant to the JSON API spec.

Kind of seems to be an overkill to me to introduce the old still buggy way again and fix it properly in another PR.

@sliverc
Copy link
Member

sliverc commented Dec 4, 2018

Closing in favor of #526

@sliverc sliverc closed this Dec 4, 2018
@robertobarreda robertobarreda deleted the patch-1 branch December 4, 2018 15:58
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.

2 participants