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

ReferenceInput with a blank SelectInput #115

Open
stats opened this issue Jun 21, 2022 · 1 comment
Open

ReferenceInput with a blank SelectInput #115

stats opened this issue Jun 21, 2022 · 1 comment

Comments

@stats
Copy link

stats commented Jun 21, 2022

With a simple self referential setup where a category can be the child of another category using

child_category.parent_id = parent_category.id

The following code results in an error when the SelectInput is left blank.

<ReferenceInput label="Parent" source="parent_id" reference="categories">
  <SelectInput optionText="name"/>
</ReferenceInput>

The error reads

{"errors":[{"extensions":{"path":"$.selectionSet.insert_categories.args.objects","code":"data-exception"},"message":"invalid input syntax for type integer: \"\""}]}

This is because the value passed for parent_id is a blank string.

Ra-data-hasura should see this blank string being passed to an integer field and then remove it from the list of parameters submitted when encountered.

@stats
Copy link
Author

stats commented Jun 26, 2022

I believe the issue can be resolved by adding a similar step in typeAwareKeyValueReducer.js that is used for a date field for the Int type.

The problem is that this results in an MUI warning

You have provided an out-of-range value `null` for the select (name="[int field]") component.
Consider providing a value that matches one of the available options or ''.

Is there a better location to change the variable type that would not result in this error?

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

1 participant