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

[BUGFIX] Serialize null array items as empty strings #8083

Merged

Conversation

camerondubas
Copy link
Contributor

Description

While moving off jquery, I noticed a difference in how the ember-data serializes null in arrays in query params.

jQuery's buildParams (link) checks for null in an array and sets it to an empty string

buildParams(prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]" ...

ember-data doesn't have the explicit null check (link), so null values in arrays get treated like objects.

This results in urls that decode to:

filter[children][0]=&...

rather than the expected

filter[children][]=&...

This PR fixes this by adding an explicit null check.

Would like to see this fix back-ported to 3.28 as that's where I am experiencing it.

Type of PR

What kind of change is this?

  • refactor
  • internal bugfix
  • user-facing bugfix
  • new feature
  • deprecation
  • documentation
  • something else (please describe)
  • tests

@runspired runspired added 🎯 canary PR is targeting canary (default) 🎯 lts The PR should be backported to the most recent LTS 🏷️ bug This PR primarily fixes a reported issue 🎯 lts-prev This PR should be back ported to the second-most recent LTS labels Jul 27, 2022
@runspired runspired merged commit a499b80 into emberjs:master Jul 27, 2022
ajkovar added a commit to ajkovar/data that referenced this pull request Aug 19, 2022
@runspired
Copy link
Contributor

@camerondubas backport to 3.28 in progress

runspired added a commit that referenced this pull request Sep 12, 2022
* backport fix for #7786 from #7882

* schedule watchTypeIfUnseen to prevent loop (#8008)

* schedule watchTypeIfUnseen to prevent loop

fixes #8006

* Update debug-adapter-test.js

* Update index.js

* Update index.js

* fix test

* Update debug-adapter-test.js

* keep Watching Model Types with store.push

* add comment

* fix test

* [BUGFIX] serialize null array items to string (#8083)

* port fix from #7834 for #7824

Co-authored-by: patricklx <patricklx@users.noreply.github.com>
Co-authored-by: Cameron Dubas <camerondubas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🎯 lts The PR should be backported to the most recent LTS 🎯 lts-prev This PR should be back ported to the second-most recent LTS 🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants