QueryAddRow manipulates structs with number keys

Description

This code will insert a query row with a 1 as the value for the lineData column:

testQry = queryNew( "lineData" ); row = { lineData : { 1 : 0 } }; // ROW 1 queryAddRow( testQry, row ); // inserts a "1" integer writeDump( testQry ); // ROW 2 queryAddRow( testQry, 1 ); testQry[ "lineData" ][2] = row[ "lineData" ]; // inserts a struct writeDump( testQry );

On ACF2016, ACF2018, and ACF2021 this code inserts a full struct.

See gist on TryCF:

https://trycf.com/scratch-pad/gist/efa47a1225207f53dbbfa863a1eb2803

Attached screenshots of result queries.

Attachments

3
  • 14 Nov 2022, 06:29 pm
  • 14 Nov 2022, 03:52 pm
  • 14 Nov 2022, 03:52 pm

Activity

Pothys - MitrahSoft 
15 November 2022 at 14:03

I closed the ticket as mentioned by the

Michael Born @ Ortus 
14 November 2022 at 18:31

So we can probably close this as a dupe… but I do want to see this symptom of https://luceeserver.atlassian.net/browse/LDEV-3933 fixed along with that ticket.

Michael Born @ Ortus 
14 November 2022 at 18:29

Ok, after reviewing with I concur that this is due to the idiotic-on-purpose treatment of numbered-key structs as arrays.

This code, for example, adds THREE rows to the query… and if the struct keys don’t match the query row numbers, the values themselves are omitted:

testQry = queryNew( "lineData" ); row = { lineData : { 1 : 0, // inserted into row 1 2 : 1, // inserted into row 2 8 : 7 // this "7" is not inserted. Instead, a NULL is inserted for line 3. } }; queryAddRow( testQry, row );

Brad Wood 
14 November 2022 at 16:57

I think this may be a duplicate of this ticket

https://luceeserver.atlassian.net/browse/LDEV-3933

and this ticket:

https://luceeserver.atlassian.net/browse/LDEV-1206

Can you check and see if they are the same scenario.

Duplicate

Details

Assignee

Reporter

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

Affects versions

Priority

Created 14 November 2022 at 15:52
Updated 15 November 2022 at 14:04
Resolved 15 November 2022 at 14:04