When adding row to query as struct of column keys, arrays are handled wrong

Description

The fol*lowin*g code is handled correctly up until the point where I try to add an array to the query as a value. (Yes, I put complex objects into query columns on purpose. It's very handy for ad-hoc structured data)

var qryResult = queryNew( 'column1,column2' ); qryResult.addRow( { column1 : 'foo', column2 : 'bar' } ); qryResult.addRow( { column1 : 1, column2 : 2 } ); qryResult.addRow( { column1 : { brad : 'wood' }, column2 : { luis : 'majano' } } ); qryResult.addRow( { column1 : [ 1 ], column2 : [ 'a', 'b', 'c' ] } ); writeDump( qryResult );

Screenshot is attached of what the query object looks like when dumped out.

I know why this happens-- it's because of the behavior where you can pass an array for a column and Lucee adds a row for each index in the array. I think that should still continue to work as it does for functions like queryAddColumn() but in this case that behavior doesn't make sense since I'm clearly adding a single record to my query as defined by the struct. Each struct key is meant to represent a single value for that row. When arrays are passed inside of a struct for a single row to be added, they should be taken as a single discrete value and added only to that row.

I've added a second screenshot that shows what the query object should look like (Only 4 records where the 4th record contains arrays)

Environment

None

Attachments

2

Activity

Pothys - MitrahSoft 
12 July 2021 at 14:27

Michael Offner 
12 July 2021 at 11:06

fix breaks the function queryNew

Pothys - MitrahSoft 
5 December 2019 at 13:52

I've added a fix for this ticket.

Pull Request: https://github.com/lucee/Lucee/pull/813

Michael Offner 
27 March 2017 at 15:02

it is treated as multiple values ...

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Created 22 February 2017 at 16:52
Updated 9 June 2023 at 16:44
Resolved 2 June 2021 at 15:03