OCLOperators Not
(Created page with ""Not" is the usual Not operator found in most languages. But there are a few things to point out when writing expressions using True, False, nullable booleans and Not. =====...")
 
No edit summary
(One intermediate revision by the same user not shown)
Line 1: Line 1:
"Not" is the usual Not operator found in most languages.
"Not" is the usual Not operator found in most languages.


But there are a few things to point out when writing expressions using True, False, nullable booleans and Not.
However, there are a few things to point out when writing expressions using True, False, nullable booleans, and Not.


===== Avoid the risk with nullable booleans =====
===== Avoid the Risk With Nullable Booleans =====
Consider ''xxxx.DisableEditing = false''
Consider ''xxxx.DisableEditing = false''


When you think you want to use "a boolean" with '''= true/false       ,''' don't - It's almost never correct.
When you think you want to use "a boolean" with '''= true/false,''' don't - it's almost never correct.


The reason is that an nullable boolean is tri-state. '''False''', '''True''' and '''Null'''.  If an expression is xxxx.DisableEditing that is false for BOTH False and Null.
The reason is that a nullable boolean is tri-state. '''False''', '''True,''' and '''Null'''.  If an expression is xxxx.DisableEditing - that is false for BOTH False and Null.


So, almost always use "xxxx.DisableEditing" or "not xxxx.DisableEditing" (there are exceptions, but not many)
So, almost always use "xxxx.DisableEditing" or "not xxxx.DisableEditing" (there are exceptions, but not many).


For example
For example:
  self.ValidTo.notNull and
  self.ValidTo.notNull and
  self.AddedTo.isNull and
  self.AddedTo.isNull and
  (self.Agreement.Facilitator.DisableEditing = false)
  (self.Agreement.Facilitator.DisableEditing = false)
If DisableEditing is Null, then "(self.Agreement.Facilitator.DisableEditing = false)" is actually '''True'''. (the above false/null problem)
If DisableEditing is Null, then "(self.Agreement.Facilitator.DisableEditing = false)" is actually '''True'''. (the above false/null problem).
  self.ValidTo.notNull and
  self.ValidTo.notNull and
  self.AddedToJournalSearch.isNull and
  self.AddedToJournalSearch.isNull and
  not self.Agreement.Facilitator.DisableEditing
  not self.Agreement.Facilitator.DisableEditing
[[Category:OCLOperators]]

Revision as of 07:35, 3 March 2023

"Not" is the usual Not operator found in most languages.

However, there are a few things to point out when writing expressions using True, False, nullable booleans, and Not.

Avoid the Risk With Nullable Booleans

Consider xxxx.DisableEditing = false

When you think you want to use "a boolean" with = true/false, don't - it's almost never correct.

The reason is that a nullable boolean is tri-state. False, True, and Null.  If an expression is xxxx.DisableEditing - that is false for BOTH False and Null.

So, almost always use "xxxx.DisableEditing" or "not xxxx.DisableEditing" (there are exceptions, but not many).

For example:

self.ValidTo.notNull and
self.AddedTo.isNull and
(self.Agreement.Facilitator.DisableEditing = false)

If DisableEditing is Null, then "(self.Agreement.Facilitator.DisableEditing = false)" is actually True. (the above false/null problem).

self.ValidTo.notNull and
self.AddedToJournalSearch.isNull and
not self.Agreement.Facilitator.DisableEditing
This page was edited 75 days ago on 02/10/2024. What links here