Solr
  1. Solr
  2. SOLR-888

DateFormatTransformer cannot convert non-string type

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Labels:
      None
    • Environment:

      any

      Description

      When using the DateFormatTransformer, if the source column is of type java.sql.TimeStamp, an exception is thrown converting this to a String. Solution is to not typecast to a String but rather invoke the .toString() method of the object to retrieve the string representation of the object.

      (About line 68)
      } else

      { String value = (String) o; aRow.put(column, process(value, fmt)); }

      should be
      } else

      { String value = o.toString(); aRow.put(column, process(value, fmt)); }

        Activity

        Hide
        Amit Nithian added a comment -

        Lines 69,70 contain the changes. Sorry I didn't download the source from trunk so I am just attaching the entire .java file.

        Show
        Amit Nithian added a comment - Lines 69,70 contain the changes. Sorry I didn't download the source from trunk so I am just attaching the entire .java file.
        Hide
        Noble Paul added a comment -

        I guess you can index TimeStamp directly. You may not need to use DateFormatTransformer

        Show
        Noble Paul added a comment - I guess you can index TimeStamp directly. You may not need to use DateFormatTransformer
        Hide
        Amit Nithian added a comment -

        True but it still might be safer to call toString rather than perform a typecast I think although I didn't read the Javadoc properly on Timestamp before posting the bug (relatively new to JDBC).

        Show
        Amit Nithian added a comment - True but it still might be safer to call toString rather than perform a typecast I think although I didn't read the Javadoc properly on Timestamp before posting the bug (relatively new to JDBC).
        Hide
        Shalin Shekhar Mangar added a comment -

        Committed revision 725618.

        Thanks Amit!

        Show
        Shalin Shekhar Mangar added a comment - Committed revision 725618. Thanks Amit!
        Hide
        Grant Ingersoll added a comment -

        Bulk close for Solr 1.4

        Show
        Grant Ingersoll added a comment - Bulk close for Solr 1.4

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Amit Nithian
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1m
              1m
              Remaining:
              Remaining Estimate - 1m
              1m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development