isNullorEmpty

Hi,

For the above expression rule, if I try to add a!isNullorEmpty(local!ID), then I can getting false, but I am expecting true.

Am I doing anything wrong here.

  Discussion posts and replies are publicly visible

Parents
  • Yes, see below code and screenshot for the difference. It's subtle but technically a list containing all null indexes, even if that's a single index, isn't actually empty. This is good that this happens!

    To get the behavior you want you can either reject all nulls from the list or cast to the scalar (single) integer data type. Both behaviors are demonstrated below.

    a!localVariables(
      local!nullInteger: tointeger(
        null
      ),
      local!listOfNullInteger: cast(
        a!listType(1),
        local!nullInteger
      ),
      local!rejectNulls: reject(
        fn!isnull,
        local!listOfNullInteger
      ),
      local!castToScalarInteger: cast(
        typeof(1),
        local!listOfNullInteger
      ),
      {
        nullInteger: a!isNullOrEmpty(local!nullInteger),
        listOfNullInteger: a!isNullOrEmpty(local!listOfNullInteger),
        rejectNulls: a!isNullOrEmpty(local!rejectNulls),
        castToScalarInteger: a!isNullOrEmpty(local!castToScalarInteger)
      }
    )
     

Reply
  • Yes, see below code and screenshot for the difference. It's subtle but technically a list containing all null indexes, even if that's a single index, isn't actually empty. This is good that this happens!

    To get the behavior you want you can either reject all nulls from the list or cast to the scalar (single) integer data type. Both behaviors are demonstrated below.

    a!localVariables(
      local!nullInteger: tointeger(
        null
      ),
      local!listOfNullInteger: cast(
        a!listType(1),
        local!nullInteger
      ),
      local!rejectNulls: reject(
        fn!isnull,
        local!listOfNullInteger
      ),
      local!castToScalarInteger: cast(
        typeof(1),
        local!listOfNullInteger
      ),
      {
        nullInteger: a!isNullOrEmpty(local!nullInteger),
        listOfNullInteger: a!isNullOrEmpty(local!listOfNullInteger),
        rejectNulls: a!isNullOrEmpty(local!rejectNulls),
        castToScalarInteger: a!isNullOrEmpty(local!castToScalarInteger)
      }
    )
     

Children