cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Helma van der Linden (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (COCOON-789) [PATCH] SQLTransformer to optionally preserve case of column names
Date Tue, 25 Oct 2005 14:01:00 GMT
     [ http://issues.apache.org/jira/browse/COCOON-789?page=all ]
     
Helma van der Linden reopened COCOON-789:
-----------------------------------------


reopened just to set the resolution to fixed

> [PATCH] SQLTransformer to optionally preserve case of column names
> ------------------------------------------------------------------
>
>          Key: COCOON-789
>          URL: http://issues.apache.org/jira/browse/COCOON-789
>      Project: Cocoon
>         Type: Improvement
>   Components: * Cocoon Core
>     Versions: 2.1.8-dev (Current SVN)
>  Environment: Operating System: All
> Platform: All
>     Reporter: Steve Schwarz
>     Assignee: Cocoon Developers Team
>     Priority: Minor

>
> It would be very helpful if there was a parameter to control SQLTransformer's
> handling of the case of database column names. Currently it lowercases all
> column names. The current behavior could be the default with a configuration
> parameter for specifying preserving the case as retrieved from the database.
> The attached diff implements this feature as described above.
> (a more thorough solution could support multiple options including transforming
> column case: preserve, upcase, lowercase, Title Case, camelCase, etc. Seems
> overkill :^)
> This diff is against 2.1rc2"
> --- SQLTransformer.java.old	2003-08-08 10:59:05.000000000 -0500
> +++ SQLTransformer.java	2003-08-08 11:35:02.000000000 -0500
> @@ -108,6 +108,8 @@
>      public static final String MAGIC_VALUE = "value";
>      public static final String MAGIC_DOC_ELEMENT = "doc-element";
>      public static final String MAGIC_ROW_ELEMENT = "row-element";
> +    /** Should ResultSet rows have db column names lowercased (default) */
> +    public static final String MAGIC_PRESERVE_COLUMN_CASE = "preserve-column-case";
>      public static final String MAGIC_IN_PARAMETER = "in-parameter";
>      public static final String MAGIC_IN_PARAMETER_NR_ATTRIBUTE = "nr";
>      public static final String MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE = "value";
> @@ -281,7 +283,8 @@
>              getLogger().debug( "ROW-ELEMENT: " + parameters.getParameter(
> SQLTransformer.MAGIC_ROW_ELEMENT, "row" ) );
>              getLogger().debug( "NS-URI: " + parameters.getParameter(
> SQLTransformer.MAGIC_NS_URI_ELEMENT, NAMESPACE ) );
>              getLogger().debug( "NS-PREFIX: " + parameters.getParameter(
> SQLTransformer.MAGIC_NS_PREFIX_ELEMENT, "" ) );
> -			      getLogger().debug( "CLOB_ENCODING: " + clobEncoding );
> +	    getLogger().debug( "CLOB_ENCODING: " + clobEncoding );
> +            getLogger().debug( "PRESERVE_COLUMN_CASE: " +
> parameters.getParameter( SQLTransformer.MAGIC_PRESERVE_COLUMN_CASE, "" ) );
>          }
>     }
>  
> @@ -872,6 +875,9 @@
>          /** Mapping out parameters - objectModel **/
>          protected HashMap outParametersNames = null;
>  
> +	/** Check if we should not lowercase column names in results */
> +	protected boolean preserveColumnCase = false; 
> +
>          protected Query( SQLTransformer transformer, int query_index ) {
>              this.transformer = transformer;
>              this.query_index = query_index;
> @@ -1032,6 +1038,7 @@
>          protected void execute() throws SQLException {
>              this.rowset_name = properties.getParameter(
> SQLTransformer.MAGIC_DOC_ELEMENT, "rowset" );
>              this.row_name = properties.getParameter(
> SQLTransformer.MAGIC_ROW_ELEMENT, "row" );
> +	    this.preserveColumnCase = properties.getParameterAsBoolean(
> SQLTransformer.MAGIC_PRESERVE_COLUMN_CASE, false );
>  
>              Enumeration enum = query_parts.elements();
>              StringBuffer sb = new StringBuffer();
> @@ -1241,9 +1248,12 @@
>              AttributesImpl attr = new AttributesImpl();
>              if ( !isupdate && !isstoredprocedure ) {
>                  for ( int i = 1; i <= md.getColumnCount(); i++ ) {
> -                    transformer.start( md.getColumnName( i ).toLowerCase(), attr );
> +		    String columnName = md.getColumnName( i );
> +		    if (this.preserveColumnCase != true)
> +			columnName = columnName.toLowerCase();
> +                    transformer.start( columnName, attr );
>                      this.serializeData(manager, getColumnValue( i ) );
> -                    transformer.end( md.getColumnName( i ).toLowerCase() );
> +                    transformer.end( columnName );
>                  }
>              } else if ( isupdate && !isstoredprocedure ) {
>                  transformer.start( "returncode", attr );
> @@ -1280,13 +1290,16 @@
>                                  while ( rs.next() ) {
>                                      transformer.start( this.row_name, attr );
>                                      for ( int i = 1; i <= md.getColumnCount();
> i++ ) {
> -                                        transformer.start( md.getColumnName( i
> ).toLowerCase(), attr );
> +					String columnName = md.getColumnName( i );
> +					if (this.preserveColumnCase != true)
> +					    columnName = columnName.toLowerCase();
> +                                        transformer.start( columnName, attr );
>                                          if ( md.getColumnType( i ) == 8 ) { 
> //prevent nasty exponent notation
>                                              this.serializeData(manager,
> SQLTransformer.getStringValue( rs.getBigDecimal( i ) ));
>                                          } else {
>                                              this.serializeData(manager,
> SQLTransformer.getStringValue( rs.getObject( i ) ));
>                                          }
> -                                        transformer.end( md.getColumnName( i
> ).toLowerCase() );
> +                                        transformer.end(columnName);
>                                      }
>                                      transformer.end( this.row_name );
>                                  }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message