flat-fuchsiaβ€’16mo ago

Inferencer disregards null-value fields

Hi there πŸ‘‹ So I'm making actual progress using the library with the modifications I've used to the Inferencers, but now I have something that I'm not sure I can access and wanted to discuss with you guys. In the Create and Edit Inferencer components (well, in all of the Inferencers but I'm mostly interested in those component), I don't see fields that have null values in them (probably in the first record? Because some records have values in these fields). I thought there's some null-checks in the Inferencer that disregards null-value fields but I see that the renderer function doesn't even receive those fields from createInferencer, so I assume it's happening in the field type check, perhaps in the useInferFetch? Haven't dug too deep yet. Anyways, in the case that I don't have those fields on creation - I also won't have them on editing as well, so essentially unless I have some default value that is not null in those fields, I'll never be able to change them. Is this a known issue perhaps? Or another one of my weird use case problems
3 Replies
refine-support-botβ€’16mo ago
Hey, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and could not find an answer. Please wait for someone from the refine core team or the community to try to help you. πŸ‘Š
foreign-sapphireβ€’16mo ago
Hey @YechiamTK, looks like this is one of the flaws we have in the inferencer package. We're using the first record of the getList response when generating the code for the create views and the response of the getOne call when generating the code for the edit views. For create and list views, it will probably be better if we just use multiple records to infer the fields rather than using just one which fails for some fields in the cases like yours. Not sure about the edit views though, I think they are good with just using their own data πŸ˜… Those fields with null values are removed from the fields array and therefore they may not be editable through fieldTransformer function. I think we can update this to allow users to pass custom field values for null values and let them get rendered πŸ€” Do you think this will be good for your case?
flat-fuchsiaβ€’16mo ago
Hi @aliemirs, is there a particular reason to disregard null-value fields? Obviously you can't infer its type (unless as you say you try to get it from another record, but that might also not work - what if the field itself is all null-valued currently?), but perhaps treating those as a default string type fields will be enough? And then on next render if there is indeed a value you try to infer again and might catch the correct type. The big question is, was it a conscious decision to exclude null-value fields? Is it messing up something in the library? Perhaps with datagrid?