Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-12155

Raw JsonValue string stored in JSON_MAP columns instead of proper JSON in Hybrid Tables.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • OpenIDM 6.0.0, 6.5.0
    • 6.5.0
    • None

    Description

      In Generic mapped tables, JSON_MAP columns are populated with raw JsonValue content instead of a proper JSON string value.

      OTB we have one example: relationships table in the properties column.

      2 things need to happed to repair the issue:

      1) The GraphTableHandler needs to change how it handles storing JSON_MAP columns.

      2) For back-porting the fix: Any data stored in a column that is mapped as a JSON_MAP column needs to have any previous data migrated to a proper JSON format.  This will require a migration script. EDIT: actually the properties column isn't needed as the data is already stored in the full object.

       

      The code change for #1 is a single line in the populateMappedColumns method of the GenericTableHandler.  'asMap()' needs to be added.

      protected int populateMappedColumns(PreparedStatement stmt, int paramIdx, JsonValue fullobject)
              throws JsonProcessingException, SQLException {
          // TODO set numeric column types here
          for (ColumnMapping column : columnMappings) {
              switch (column.dbColType) {
              case JSON_LIST:
              case JSON_MAP:
                  stmt.setString(paramIdx++, mapper.writeValueAsString(fullobject.get(column.objectColPointer).asMap()));
                  break;
              case FULLOBJECT:
                  stmt.setString(paramIdx++, mapper.writeValueAsString(fullobject.asMap()));
                  break;
              default:
                  stmt.setString(paramIdx++, fullobject.get(column.objectColPointer).asString());
                  break;
              }
          }
      
          return paramIdx;
      }

       

      Here are some samples of bad data:

      {
      "object": {
      "_grantType": "conditional"
      },
      "pointer": {
      "empty": false,
      "value": "\/properties"
      },
      "null": false,
      "map": true,
      "boolean": false,
      "collection": false,
      "list": false,
      "notNull": true,
      "number": false,
      "string": false
      }

       

      should be:

      {"_grantType":"conditional"}
      

      and another example:

      {
        "object": null,
        "pointer": {
          "empty": false,
          "value": "\/properties"
        },
        "null": true,
        "map": false,
        "boolean": false,
        "collection": false,
        "list": false,
        "notNull": false,
        "number": false,
        "string": false
      }
      

      should be...

      null
      

      Attachments

        Activity

          People

            jason.vincent jason vincent
            jason.vincent jason vincent
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: