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

ColumnMapping literal not working

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.11.1
    • Fix Version/s: 3.0.0, 2.11.2
    • Component/s: Appenders
    • Labels:
      None
    • Flags:
      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

            People

            • Assignee:
              ggregory Gary Gregory
              Reporter:
              pbit Paolo Bonanomi
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: