Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

.pluck() fails when a key has a null value #28

@DiscountDarcy

Description

@DiscountDarcy

I finally got an opportunity to play some with cfcollection a month ago or so and ran into a small issue when dealing with collections that may have null keys. See this example:

var data = [ { 'foo' : 'bar', 'baz' : 'frobozz' }, { 'foo' : 'also bar', 'baz' : javacast( "null", "" ) } ];

var collection = wirebox.getInstance( name = "Collection@cfcollection", initArguments = { collection : data } );

dump( collection.toArray() );

Good so far!

But if you try this:

dump( collection.pluck( 'baz' ) );

It will throw:

Error: the value from key [baz] is NULL, which is the same as not existing in CFML (expression)

on Collection.cfc : 87 (ID: ??, Type: cfml)

Which is this line:

  return item[ keys[ 1 ] ];

This works as a workaround:

   return ( item[ keys[ 1 ] ] ?: '' );

Do you prefer a different solution or shall I submit that as a PR?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions