Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359898

Summary: CHAR and GRAPHIC columns fetched from SQL tables do not have trailing blanks truncated.
Product: z_Archived Reporter: Paul Hoffman <hoffmanp>
Component: EDTAssignee: Joseph Vincens <jvincens>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: chenzhh, jqian, jvincens, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Paul Hoffman CLA 2011-10-04 14:54:54 EDT
Build Identifier: EDT 0.7.0.v201110040852

CHAR columns fetched from SQL tables do not have trailing blanks truncated.   Blanks should be truncated on the fetch to be consistent with RBD behavior and RBD char to string assignments.

If blanks are not truncate then statements like the following will throw an exception when the column read contains the value "Some Char 2              ":

if ( row.aString != "Some Char 2" )
 throw new anyexception { message = "Read row 2; row.aChar = '" + row.aChar + "'" } ;			
end

This is a little painful for test case development.   Text fields will have to be clipped before being compared to literals.

Reproducible: Always
Comment 1 Joseph Vincens CLA 2011-10-07 08:46:57 EDT
The idea for EDT is to do as little hidden code as possible while exposing as much of the environment (in this java) functionality as possible. The recommendation that I've found for Java developers is to use a DB function in the select SELECT RTRIM(mycolumn) FROM ... 

So the runtime won't do any auto trimming. 

The tooling CTRL ^ 1 should provide 2 choices for the select statement, the current, and a new one that adds RTRIM to all of the CHAR or NCHAR columns.
Comment 2 Paul Hoffman CLA 2011-10-07 11:32:20 EDT
Java should not be the model for how to handle CHAR columns since Java has no CHAR data type. 

The true models for handling CHAR columns are DB2 and COBOL.   They do not treat trailing blanks as significant in comparing text values.    

Java's implementation has the anomaly that the key value that selects a row from a DB2 table can treated by Java as not equal to the column value returned on the fetch.    Developers have to code around this by using RTRIM.   

An enterprise tool worth its name should be smart enough not to require developers to worry about this.

If you don't want to hide this, use the RTRIM in the default SQL statement built by EGL.   After all, shouldn't our default statement follow recommended practice?
Comment 3 Zhi Zhu CLA 2011-10-10 02:46:48 EDT
I am assuming the defect is found in creating record from SQL database.

And if trailing blanks are truncated, do SQL operations are affected? Based on Paul's comment, they should not be affected.
Comment 4 Zhi Zhu CLA 2011-10-10 02:56:13 EDT
Modify DataToolsSqlColumnTemplate
Comment 5 Paul Hoffman CLA 2011-10-24 12:36:32 EDT
Please explain how this is fixed.   What annotation causes RTRIM to be added to column name select list?
Comment 6 Zhi Zhu CLA 2011-10-25 23:12:43 EDT
for all database type which is mapped to egl string, add rtrim() in default generated SQL
Comment 7 Paul Hoffman CLA 2011-10-26 13:43:21 EDT
RTRIM needs to be added to default SQL statement both in the default statement created at runtime and in the statement suggested in the IDE when the developer hits CNTL-1.
Comment 8 Joseph Vincens CLA 2011-10-26 16:44:39 EDT
fixed
Comment 9 Paul Hoffman CLA 2011-11-01 16:28:19 EDT
Closed and verified