Uploaded image for project: 'Lucee Development'
  1. LDEV-949

arrayToList fails on arrays passed as part of query object

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: New
    • Resolution: Fixed
    • Affects Version/s: 5.0.0.252
    • Fix Version/s: 5.0.1.42
    • Labels:
      None
    • Environment:

      Debian 8.5 (Jessie) Kernel 3.16.0-4-amd64, Tomcat 8.5.3, Oracle Java 1.8.0_91 (Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode), PostgreSQL 9.2

      Description

      Using ArrayToList on a query result column throws an exception.

      <cfquery name="test" datasource="#mydatasource#">
      	SELECT ARRAY [1,15,9] AS foo
      </cfquery>
      <cfscript>
      foo=test.foo;
      
      writeOutput('<br />');
      writeoutput('ArrayToList: ');
      	try {
      		foo = ArrayToList(test.foo);
      		writeOutput('working.');
      	} catch (Any e) {
      		writeOutput('not working.');
      	}
      
      writeOutput('<br />');
      writeoutput('ArrayToList detached: ');
      	try {
      		foo = ArrayToList(foo);
      		writeOutput('working.');
      	} catch (Any e) {
      		writeOutput('not working.');
      	}
      </cfscript>
      

      Output:
      ArrayToList: not working.
      ArrayToList detached: working.

      StackTracke:
      {{"ERROR","ajp-nio-8009-exec-1","07/28/2016","13:04:17","",";this method is no longer supported, use instead get(int,Object);lucee.runtime.exp.DeprecatedException: this method is no longer supported, use instead get(int,Object)
      at lucee.runtime.type.QueryColumnImpl.get(QueryColumnImpl.java:279)
      at lucee.runtime.type.QueryColumnImpl.getE(QueryColumnImpl.java:799)
      at lucee.runtime.functions.list.ArrayToList.call(ArrayToList.java:55)
      at lucee.runtime.functions.list.ArrayToList.call(ArrayToList.java:35)
      at some.package.path.myclass_cfc$cf.udfCall8(/var/www/somepath/some/package/path/myclass.cfc:12345)}}

      The problem here seems to me in ArrayToList, line 55:

      if(len==1)return Caster.toString(array.getE(1));

      This is calling getE(1) on the array that was passed. For an ordinary array, this would probably resolve to the getE(int key) on line 155 of ArrayImpl.java and we'd be fine, however in case of an array passed as part of a query result, we end up in QueryColumnImpl.java instead, where getE(int row) is probably not what we want - this does a get(row) wich in turn throws the DeprecatedException in line 279, advising to use the method just below.

      I don't actually know how to build Lucee, nor am I much of a Java developer and I'm a bit out of my depth when it comes to deciding how to resolve the issue here. The getE(int)-method of QueryColumnImpl.java seems to me completely broken, as we'd always end up in the deprecated get(int). So I assume that there was some work going on here, but it didn't get quite finished.

      This does in fact for in ACF (tested with 8), so it is both a bug and an incompatibility. ArrayFirst, ArrayLast, ArrayReverse and ArraySlice seem to be working, so I hope that the fix for ArrayToList ist not too difficult.

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              mwollny Markus Wollny
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: