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

          Thank you for your report. I should be able to take a look this weekend.

          ggregory Gary D. Gregory added a comment - Thank you for your report. I should be able to take a look this weekend.

          Commit fc5401d40dcb8eddbabe67147f6b3e242478fc47 in logging-log4j2's branch refs/heads/release-2.x from garydgregory
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=fc5401d ]

          LOG4J2-2466 ColumnMapping literal not working.

          jira-bot ASF subversion and git services added a comment - Commit fc5401d40dcb8eddbabe67147f6b3e242478fc47 in logging-log4j2's branch refs/heads/release-2.x from garydgregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=fc5401d ] LOG4J2-2466 ColumnMapping literal not working.

          Commit 5815d1b7d153ccffe67642b25b0d4b6b1fb450e1 in logging-log4j2's branch refs/heads/master from garydgregory
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=5815d1b ]

          LOG4J2-2466 ColumnMapping literal not working.

          jira-bot ASF subversion and git services added a comment - Commit 5815d1b7d153ccffe67642b25b0d4b6b1fb450e1 in logging-log4j2's branch refs/heads/master from garydgregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=5815d1b ] LOG4J2-2466 ColumnMapping literal not working.

          Committed to git master and release-2.x branches.

          Please verify and close if it works for you.

          ggregory Gary D. Gregory added a comment - Committed to git master and release-2.x branches. Please verify and close if it works for you.
          pbit Paolo Bonanomi added a comment -

          Ok!

          pbit Paolo Bonanomi added a comment - Ok!

          People

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

            Dates

              Created:
              Updated:
              Resolved: