Skip to content

Relationships that are not a plain string (the 'object') are not stored in the historical database #1829

@kzangeli

Description

@kzangeli

Looking at the source code this morning I found out that if a Relationship is not a simple string, it will not be stored in Postgres!

pgAttributeAppend.cpp:

  else if (strcmp(type, "Relationship") == 0)
  {
    if (valueNodeP->type == KjString)
    {
      snprintf(buf, bufSize, "%s('%s', '%s', '%s', '%s', %s, %s, %s, '%s', 'Relationship', '%s', null, null, null, null, null, null, null, null, null, null, '%s')",
               comma, instanceId, attributeName, opMode, entityId, observedAt, hasSubProperties, unitCode, datasetId, valueNodeP->value.s, orionldState.requestTimeString);
    }
#if 0
    else
    {
      //                                                                                                                                                                                                                         
      // FIXME: Right now, we can't enter here. See 'skip' variable in pgAttributeBuild()                                                                                                                                        
      //                                                                                                                                                                                                                         

      // WARNING: If an attribute is HUGE, it may not have room enough in a buffer allocated by kaAlloc (there's a max-size)                                                                                                     
      int          renderedValueSize   = kjFastRenderSize(valueNodeP);
      char*        renderedValue       = kaAlloc(&orionldState.kalloc, renderedValueSize);

      kjFastRender(valueNodeP, renderedValue);

      snprintf(buf, bufSize, "%s('%s', '%s', '%s', '%s', %s, %s, %s, '%s', 'RelationshipArray', null, null, null, null, '%s', null, null, null, null, null, null, '%s')",
               comma, instanceId, attributeName, opMode, entityId, observedAt, hasSubProperties, unitCode, datasetId, renderedValue, orionldState.requestTimeString);
    }
#endif

See that @if 0?
Well, this needs to be fixed.
Apparently nobody is using TRoE and Relationships as arrays.
Easy fix, but, needs to be done.

Metadata

Metadata

Assignees

Labels

BacklogbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions