Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Last active December 21, 2015 05:38
Show Gist options
  • Save adamcameron/6257903 to your computer and use it in GitHub Desktop.
Save adamcameron/6257903 to your computer and use it in GitHub Desktop.
Demonstrates incompat between CF and Railo in how Railo handles to TOP attribute for arrays and queries.
<cfscript>
q = queryNew("");
queryAddColumn(q, "id", "integer", [1,2,3,4,5,6]);
a = makeArray(6);
st = makeStruct(6);
writeDump(var=q, top="3");
writeDump(var=a, top="3");
writeDump(var=st, top="3");
struct function makeStruct(x){
if (x<=1) return {"#x#"=x-1};
var st = {};
for (var i=1; i <= x; i++){
st[i] = makeStruct(x-1);
}
return st;
}
array function makeArray(x){
if (x<=1) return [x-1];
var a = [];
for (var i=1; i <= x; i++){
a[i] = makeArray(x-1);
}
return a;
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment