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

fix: handle null emits #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Guiqft
Copy link

@Guiqft Guiqft commented Oct 14, 2022

This PR verifies when the parsed expression returns a empty value and properly emits null, so Directus can take care of the empty field.

Closes #7

@Guiqft
Copy link
Author

Guiqft commented Oct 26, 2022

Now, this is the field behavior:
ezgif-1-58331795ff

@Guiqft Guiqft changed the title Properly updates model value fix: handle null emits Oct 26, 2022
const expression = match.slice(2, -2).trim();
return parseExpression(expression, values.value);
});

if (!computedValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If computedValue is a valid falsy value (0, false), it would still return null. That is not intended in some cases such as subtract or boolean expression.

const valueA = parseExpression(a, values);
if (!valueA) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above if valueA is a valid falsy value.

@duydvu
Copy link
Contributor

duydvu commented Oct 27, 2022

Because all types are valid, even null (NULL & NOT_NULL operators), we cannot pre-check whether a value is valid or not. I think it is best to leave the responsibility of checking unintended values to the operators.

I still can't reproduce your issue with {{ MULTIPLY(numero,2) }}. It may be due to something else, because null * 2 is still 0, right?

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.

Updating empty values
2 participants