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

Compare not existing variables with null #176

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

saig0
Copy link
Member

@saig0 saig0 commented Aug 25, 2020

Description

  • comparing a non-existing variable with null returns true
  • comparing a property with null returns true if the property is null, if it doesn't exist, or if its variable is null or doesn't exist
  • new built-in function is defined() that returns true if the given value is present (i.e. is not an error)

Related issues

closes #150

Copy link

@pihme pihme left a comment

Choose a reason for hiding this comment

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

Looking forward to using this.

Minor suggestions for changes.

docs/develop/feel-built-in-functions.md Outdated Show resolved Hide resolved
docs/develop/feel-expression.md Outdated Show resolved Hide resolved
@@ -1150,6 +1153,15 @@ object BuiltinFunctions extends FunctionProvider {
}
)

private def isDefinedFunction =
Copy link

Choose a reason for hiding this comment

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

(Optional) maybe replace it with "is undefined"

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it. I prefer is defined(x) because it looks more intuitive when inverting it with not(is defined(x)). Instead of having a double negation not(is undefined(x)).

* a not-existing variable or property can be compared with null
* new built-in function `is defined()` that returns true if the given value is present (i.e. is not an error)
@saig0 saig0 force-pushed the 150-null-check-for-not-existing branch from 79711f5 to c756a18 Compare August 26, 2020 05:33
@saig0
Copy link
Member Author

saig0 commented Aug 26, 2020

@pihme thank you for the fast review 👍
I applied most of the hints :)

@saig0 saig0 merged commit 21ef10f into master Aug 26, 2020
@saig0 saig0 deleted the 150-null-check-for-not-existing branch August 26, 2020 05:42
saig0 added a commit that referenced this pull request Aug 26, 2020
* a not-existing variable or property can be compared with null
* new built-in function `is defined()` that returns true if the given value is present (i.e. is not an error)

(cherry picked from commit 21ef10f)
saig0 added a commit that referenced this pull request Aug 26, 2020
* a not-existing variable or property can be compared with null
* new built-in function `is defined()` that returns true if the given value is present (i.e. is not an error)

(cherry picked from commit 21ef10f)
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.

Compare not existing variables with Null
2 participants