SebTardif opened a new pull request, #4521:
URL: https://github.com/apache/logging-log4j2/pull/4521

   `JdbcAppender` writes a `ColumnMapping` literal into the INSERT text and 
does not create a placeholder for it. The binder still took a JDBC parameter 
when that column's type was a date or a thread-context type, and it restarted 
parameter numbering after filling `MapMessage` values. A later pattern column 
was then stored in an earlier column.
   
   This change binds each placeholder once and skips literals.
   
   The same binder is on `main` under `log4j-jdbc`. This pull request targets 
`2.x`.
   
   ## Validation
   
   Before the change, `JdbcAppenderColumnMappingMixedTest` failed on H2. 
Parameter 1 was a timestamp written into the integer `id` column:
   
   ```
   insert into dsMixedLogEntry (id,stamp,level,message) values 
(?,CURRENT_TIMESTAMP,?,?)
   ```
   
   The driver reported `Data conversion error converting "TIMESTAMP to 
INTEGER"`.
   
   After the change, from a Java 17 JDK:
   
   ```
   ./mvnw -pl log4j-api,log4j-core -am install -DskipTests
   ./mvnw -pl log4j-core,log4j-core-test spotless:check
   ./mvnw -pl log4j-core-test surefire:test \
     
-Dtest=JdbcAppenderColumnMappingMixedTest,JdbcAppenderColumnMappingPatternTest,JdbcAppenderColumnMappingLiteralTest,JdbcAppenderMapMessageDataSourceTest
 \
     -Dsurefire.failIfNoSpecifiedTests=false
   ```
   
   Spotless passed. Tests run: 5, failures: 0 (mixed, pattern, literal, and 
both map-message data-source tests).
   
   Changelog: `src/changelog/.2.x.x/fix_jdbc_column_mapping_parameter_index.xml`
   
   ## Checklist
   
   * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` 
otherwise
   * `./mvnw verify` succeeds ([the build 
instructions](https://logging.apache.org/log4j/2.x/development.html#building))
   * Non-trivial changes contain an entry file in the `src/changelog/.2.x.x` 
directory
   * Tests are provided
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to