From ccba67f488edeac95171de0bbd9feff92a1fb077 Mon Sep 17 00:00:00 2001 From: Saravanamuthu Aka CF Mitrah Date: Thu, 1 Apr 2021 20:49:02 +0530 Subject: [PATCH] Added a test case and fix for LDEV-2637 (#828) --- .../runtime/functions/query/QuerySetCell.java | 2 +- test/tickets/LDEV2637.cfc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/tickets/LDEV2637.cfc diff --git a/core/src/main/java/lucee/runtime/functions/query/QuerySetCell.java b/core/src/main/java/lucee/runtime/functions/query/QuerySetCell.java index 4079f9a14c..608c4838ae 100644 --- a/core/src/main/java/lucee/runtime/functions/query/QuerySetCell.java +++ b/core/src/main/java/lucee/runtime/functions/query/QuerySetCell.java @@ -38,7 +38,7 @@ public static boolean call(PageContext pc, Query query, String columnName, Objec public static boolean call(PageContext pc, Query query, String columnName, Object value, double rowNumber) throws PageException { if (rowNumber == -9999) rowNumber = query.getRecordcount();// used for named arguments - query.setAt(KeyImpl.init(columnName), (int) rowNumber, value); + query.setAt(KeyImpl.init(columnName.trim()), (int) rowNumber, value); return true; } diff --git a/test/tickets/LDEV2637.cfc b/test/tickets/LDEV2637.cfc new file mode 100644 index 0000000000..fe137c863b --- /dev/null +++ b/test/tickets/LDEV2637.cfc @@ -0,0 +1,19 @@ +component extends="org.lucee.cfml.test.LuceeTestCase" { + + function run( testResults , testBox ) { + myQuery = QueryNew("myCol1, myCol2,myCol3", "varchar,varchar,varchar"); + QueryAddRow(myQuery, 1); + + describe( "test suite for LDEV2637", function() { + it(title = "QuerySetCell column name without spaces", body = function( currentSpec ) { + QuerySetCell(myQuery,"myCol2","Lucee", 1); + expect("Lucee").toBe(myQuery.myCol2); + }); + + it(title = "QuerySetCell column name with spaces", body = function( currentSpec ) { + QuerySetCell(myQuery," myCol2","Lucee", 1); + expect("Lucee").toBe(myQuery.myCol2); + }); + }); + } +} \ No newline at end of file