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

Send null as id using a custom exporter with fetchRelatedRecord and nullable ids #2353

Closed
Luwangel opened this issue Sep 24, 2018 · 1 comment

Comments

@Luwangel
Copy link
Contributor

We have a list of ids and we want to use fetchRelatedRecords method in a custom Exporter. Theses ids could be null.

const data = [1, 2, 3, null, null, 1, 7, null];

What you were expecting:

The api request should be:

http://example.com/react-admin/table?id[]=1&id[]=2&id[]=3&id[]=7

What happened instead:

The api request is:

http://example.com/react-admin/table?id[]=null&id[]=1&id[]=2&id[]=3&id[]=7

Steps to reproduce:

Pre-Conditions:

  • Have a table containing foreign nullable keys

For example user_category_id is a foreign nullable key:

{
    users: [
        {
            id: 1,
            name: "Logan Schowalter",
            role: "admin",
            user_category_id: null
        },
        {
            id: 2,
            name: "Breanna Gibson",
            role: "user",
            user_category_id: 1
        },
    ],
    user_categories: [
        {
            id: 1,
            label: "premium"
        },
    ]
}

Steps:

  1. Create a custom export of users list
  2. Use fetchRelatedRecords to retrieve user_category label

Related code:

https://codesandbox.io/s/p1k5vol6x

Environment

  • React-admin version: 2.3.x
  • React version: 16.4.x
@fzaninotto
Copy link
Member

Fixed by #2354

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

No branches or pull requests

2 participants