Previous topic  Top  Next topic  Print this Topic

Important Note for Datatype Conversions


Working with type conversions can be tricky. There are a couple of problems that might lead to unexpected query results.


Some examples:

<- string2number("35",35.0).

will result in "true". The query

<- string2number("35.0",35.0).

will return "true", too.

But this query

<- string2number(X,35.0) AND equal(X,"35").

will return "false". The reason is that X will be bound with "35.0" by the string2number builtin and the equal builtin correctly evaluates that the string "35.0" is not equal to the string "35". But if the optimizer "EqualUnifyRewriter" is turned on it will eliminate the equal builtin and will rewrite this rule to

<- string2number("35",35.0).

and this rule will again return "true".