Equals in EL: what if the first operand is null? - el

If I have an EL expression like this one:
#{a == b}
what happens if a is null? There is some difference between different versions of EL?
Where can I found an official specs that explain that?

From official EL specs 2.1 section 1.8.2:
If A is null or B is null return false
There are special cases for BigDecimal and BigInteger. I don't know for the other specs.
Thank you all for the help and support.

Related

Is there a LLVM Matcher for any conditional?

Is there a LLVM AST matcher for the use of a C conditional? I know there is the hasCondition() option for ifStmt, but that is only good for an if statement. In particular, I'm looking to match for a boolean condition that has no operator (e.g. if (flag), while(flag), or (flag ? x : y)). But I'd also be interested in the more generic case of any conditional.
The closest I could find was for ifStmt, whileStmt or doStmt:
xxxStmt(unless(hasCondition(binaryOperator(isComparisonOperator()))))
which allows me to also check for things like if (!flag)
For the case flag ? x : y, one can match conditionalOperator() then determine if the expression has a comparison operator.

libpqxx prepared statements nonnull checks for pointer types

I'm a newbie to SQL overall and libpqxx as well.I'm trying to build a basic application where I just need to use prepared statements to execute very simple jobs.
I have started with libpxx 4.0 version and I implemented codes like this:
pqxx::work txn( *conn );
auto result = txn.prepared( "my_insert" )( x->getId( ), x->isIdSet( ) )( x->getUser( ), x->isUserSet( ) )(x->getCreatedAt( ), x->isCreatedAtSet( ) ).exec( );
txn.commit();
Now I had to change to version 6.4 and realized the prepared function is deprecated and I should use the exec_prepared function. Okay. BUT I'm really missing the "nonnull" condition. For certain reasons I'm working with a lot of pointers and I need a convenient way to pass on these values to the database API. I could write something like:
auto result = txn.exec_prepared( "my_insert", (x->isIdSet() ? std::to_string(x-getId()) : "null"), ....);
This could work in some cases but when I try to insert "null" as string into a smallint field I get an sql error (what is reasonable though).
As types differ I can't use the ?: operator to return string/int/etc... on true branch and nullptr on false branch.
I couldn't find a proper documentation about the library. They have a doc here but if you want to find out more about a certain function there's literally nothing there.
Honestly even the deprecated .prepared(...) function doesn't work properly with 6.4 for me. I tried txn.prepared("whatever")(y->z->getA(), y->z != nullptr).exec() form and I got segmentation fault when y was a valid non-null pointer type and z was null-pointer. I expected the function wouldn't touch the value before checking on the condition but apparently it's not the case.
I have a prepared statement with 8 parameters 6 of them being a pointer type (shared_ptr) and it would be extremely messy if I have to come up with a ridiculous solution to check all the parameters one-by-one and having to write 200 lines just to be able to call this function properly.
Anyone out there having a proper solution? As I mentioned I'm a newbie so I might miss an important part there. Help me out please ^^
I know this question is old. But here's what you do:
const auto& id{ x->isIdSet()
? std::optional<std::string>{x-getId()} : std::nullopt };
auto result{ txn.exec_prepared("my_insert", id, ....) };

Ignore case of xpath extracted value in Mule expression

The Mule expression that I have is:
xpath3('//CallingSourceSystemNm') == "CIMLOOKUP"
and I want to pass this condition even when there is value like
"CIMLOOKUP" that is upper
"CIMLOOKup" that is mixed
"cimlookup" that is lower
I tried the mule documentation and blogs before asking this question here. Let me know here if anybody has any clue about this.
org.apache.commons.lang3.StringUtils.upperCase(xpath3('//CallingSourceSystemNm')) =="CIMLOOKUP"
I figured this out this way.
Thanks
Dhanjeet

NCalc evaluation is wrong?

I am trying to evaluate the following expression:
7088.800/(((((((24.65995+24.43061+24.54517+24.65192)/4)-32.0)*5/9)+273.15)/288.15)^.5)
If you are asking yourself why I didn't use Sqrt() instead of ^0.5 it's because I'm doing some things with the string beforehand that require there be no letters.
I am using this simple code:
Expression.CacheEnabled = False
x = New Expression(xEquation)
y = New Expression(yEquation)
System.Diagnostics.Debug.Write(x.Error)
System.Diagnostics.Debug.Write(y.Error)
Return New PointF(x.Evaluate, y.Evaluate)
The answer I get is: 7088.800
The correct answer is:7336.46922305(according to google)
I am using .net 3.5 and ncalc 1.3.8
I suspect it doesn't like the amount of brackets there are but I can't find any mention of that being a problem anywhere...
Thanks!
I cannot get Ncalc or Ncalc-edge (v1.4.1) to use the exponentiation operator ^ and produce the correct result. E.g., "4 ^ 2" gives 6. It does not accept ** as an operator.
A little bit of investigation shows that it uses ^ as the Xor operator, in the style of C#. C# does not have an exponentiation operator, so you will have to devise a way of parsing your actual input string and using Sqrt.
There are currently were some requests on the Ncalc discussion forum regarding this, such as Override ^ operator (link now dead, and it's not even available on the Wayback Machine).

In how many languages is Null not equal to anything not even Null?

In how many languages is Null not equal to anything not even Null?
It's this way in SQL (as a logic language) because null means unknown/undefined.
However, in programming languages (like say, C++ or C#), a null pointer/reference is a specific value with a specific meaning -- nothing.
Two nothings are equivilent, but two unknowns are not. The confusion comes from the fact that the same name (null) is used for both concepts.
In VB6 the expression Null = Null will produce Null instead of True as you would expect.
This will cause a runtime error if you try to assign it to a Boolean, however if you use it
as the condition of "If ... Then" it will act like False. Moreover Null <> Null will also
produce Null, so:
In VB6 you could say that Null is neither equal to itself (or anything else), nor unequal!
You're supposed to test for it using the IsNull() function.
VB6 also has other special values:
Nothing for object references. Nothing = Nothing is a compile error. (you're supposed to compare it using "is")
Missing for optional parameters which haven't been given. It has no literal representation so you can't even write Missing = Missing. (the test is IsMissing(foo))
Empty for uninitialized variables. This one does test equal to itself although there's also a function IsEmpty().
... let me know if I've forgotten one
I remember being a bit disgusted with VB.
Oracle is this way.
SELECT * FROM dual WHERE NULL=null; --no rows returned
MySQL has a null-safe equality operator, <=>, which returns true if both sides are equal or both sides are null. See MySQL Docs.
In C#, Nullable<bool> has interesting properties with respect to logical operators, but the equality operator is the same as other types in that language (i.e., ((bool?)null == (bool?)null) == true).
To preserve the short-circuited behavior of the short-circuited logical operators, and to preserve consistency with the non-short-circuited logical operators, the nullable boolean has some interesting properties. For example: true || null == true. false && null == false, etc. This stands in direct contradiction with other three-valued logic languages such as ANSI SQL.
You can make ruby work that way:
class Null
def self.==(other);false;end
end
n=Null
print "Null equals nothing" if n!=Null
In SQL you would have to do something like:
WHERE column is NULL
rather than
WHERE column = NULL