Type promotion

In general, EQL performs type promotion when there is no risk of loss of information.

In some cases, EQL supports automatic value promotion of integers (to doubles) and strings (to managed attribute values).

Promotion of integers

Promotion of integers to doubles occurs in the following contexts:
  • Arguments to the COALESCE expression when called with a mix of integer and double.
  • Arguments to the following operators when called with a mix of integer and double:

    + - * = <>

  • Integer arguments to the following functions are always converted to double.
    • / (division operator; note that duration arguments are not converted)
    • CEIL
    • COS
    • EXP
    • FLOOR
    • LN
    • LOG
    • SIN
    • MOD
    • POWER
    • SIN
    • SQRT
    • TAN
    • TO_GEOCODE
    • TRUNC
  • When the clauses in a CASE expression return a mix of integer and double results, the integers are promoted to double.

For example, in the expression 1 + 3.5, 1 is an integer and 3.5 is a double. The integer value is promoted to a double, and the overall result is 4.5.

In contexts other than the above, automatic type promotion is not performed and an explicit conversion is required. For example, if Quantity is an integer and SingleOrder is a Boolean, then an expression such as the following is not allowed:
COALESCE(Quantity, SingleOrder)
An explicit conversion from Boolean to integer such as the following is required:
COALESCE(Quantity, TO_INTEGER(SingleOrder))

Promotion of strings

Strings can also be promoted to managed attribute values. These strings must be string literals; other kinds of expressions that produce strings are not converted.

String promotion applies to arguments to the following functions when they are called with a mix of string and managed-attribute arguments:
  • CASE
  • COALESCE
  • GET_LCA
  • IS_ANCESTOR
  • IS_DESCENDANT

For example, in CASE expressions, if some clauses produce values in a managed attribute hierarchy and others produce string literals, then the string literals are automatically converted to values in the hierarchy.

Note that for all the functions listed above, all managed-attribute arguments must be from the same underlying hierarchy.