Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2466

ColumnMapping literal not working

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.11.1
    • 3.0.0, 2.11.2
    • Appenders
    • None
    • Important

    Description

      If i set a literal value in column mapping:

      <Jdbc name="..." tableName="..." ....>
      <DataSource jndiName="...." />
      <ColumnMapping name="...." />
      <ColumnMapping name="my_col" literal="'my_value'" />

      ....

      generated sql is wrong:

      INSERT INTO ... (..) VALUES (?, ... 'myvalue'?, ...)

       

      I think the problem should be in class JdbcDatabaseManager, row 374. Maybe an else is missing. Please check.

       

      for (final ColumnMapping mapping : data.columnMappings) {
      final String mappingName = mapping.getName();
      if (Strings.isNotEmpty(mapping.getLiteralValue())) {
      logger().trace("Adding INSERT VALUES literal for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getLiteralValue());
      sb.append(mapping.getLiteralValue());
      }
      *** missing else *** if (Strings.isNotEmpty(mapping.getParameter())) {
      logger().trace("Adding INSERT VALUES parameter for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getParameter());
      sb.append(mapping.getParameter());
      columnMappings.add(mapping);
      } else {
      logger().trace("Adding INSERT VALUES parameter marker for ColumnMapping[{}]: {}={} ", i, mappingName, PARAMETER_MARKER);
      sb.append(PARAMETER_MARKER);
      columnMappings.add(mapping);
      }
      sb.append(',');
      i++;
      }

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ggregory Gary D. Gregory
            pbit Paolo Bonanomi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment