tracker issue : CF-3665422

select a category, or use search below
(searches all categories and all time range)
Title:

Looping over a query resultset in CFscript using for-in loop produces different result than traditional loop

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Donald Langhorne / Donald Langhorne (Donald Langhorne)

Created: 11/13/2013

Components: Database

Versions: 10.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: Final / 287188

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Platforms All

Vote Count: 0

Problem Description:
When you have a query that contains boolean values coming from a database, which are always 0/1 the values are "converted" to NO/YES when you perform a for-in loop over the query
Steps to Reproduce:
// Simply modify this simple script to use any table in your DB.  Replace table name and field names to suit.
service = new Query(datasource=Application.Datasource);
result = service.execute(name="getPages",sql="select top 10 pageId, status from pages");
qPages = result.getResult();

// The status field is a boolean field in our pages table.

// This loop works, the values of the status column are output as 0 or 1
for(i=1;i <= qPages.recordcount;i=i+1){
	writeOutput(qPages['status'][i] & "<br />");
}

// This loop CONVERTS the status column values to NO/YES WHY??
for (record in qPages) {
	writeOutput(record.status & "<br />");
}



Actual Result:
values for boolean columns are converted from 0/1 to NO/YES
Expected Result:
query values should never change.  Whatever they are they should not be changed.

Any Workarounds:
Use a different loop mechanism, however the for-in loop is much cleaner and I would much prefer to use that, but apparently at the moment I cannot.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3665422

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: dlangh
External Customer Email:  
External Test Config: My Hardware and Environment details:

I have reproduced this on a Mac running Coldfusion 10.0 as well as Ubuntu 12.04 also running CF 10.  The 2 systems were connecting to different databases on different systems.

Attachments:

Comments:

I really feel that there is no justification for changing data like this, if it's a bug so be it, but if this was some kind of higher-ups decision all I can say is it's wrong. Yes I understand in CF 0/1/NO/YES/FALSE/TRUE are largely interchangeable but in the case of SQL that is NOT the case and since this data is coming from SQL it should not be changed at a minimum and in general no data should ever be reformatted or changed
Comment by External U.
14001 | November 13, 2013 03:15:35 PM GMT