Skip to content

Commit 99f1dd7

Browse files
GuillaumeOdedwinvautier
authored andcommitted
fix: attribute loss when updating entity
1 parent fd0c311 commit 99f1dd7

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Set Nodejs 20 as minimum version in packages.json (effectively removing Nodev16 and Nodev18 from supported versions)
2+
- Fix attribute loss during device update when both name and object_id are defined by filtering only object_id (#1660)

lib/services/ngsi/entities-NGSI-v2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
467467
}
468468
//remove measures that has been shadowed by an alias (some may be left and managed later)
469469
//Maybe we must filter object_id if there is name == object_id
470-
measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name);
470+
measures = measures.filter((item) => item.name !== currentAttr.object_id);
471471

472472
if (
473473
currentAttr.expression !== undefined &&

test/functional/testCases.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,16 @@ const testCases = [
542542
object_id: '.1.0.0.1',
543543
name: 'psBatteryVoltage',
544544
type: 'Number'
545+
},
546+
{
547+
object_id: 'fdt',
548+
name: 'fireDetectionThreshold',
549+
type: 'Number'
550+
},
551+
{
552+
object_id: 'fireDetectionThreshold3',
553+
name: 'fireDetectionThreshold3',
554+
type: 'Number'
545555
}
546556
],
547557
static_attributes: []
@@ -556,7 +566,7 @@ const testCases = [
556566
should: [
557567
{
558568
shouldName:
559-
'A - WHEN sending defined object_ids with special format names (measures) through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
569+
'A - WHEN sending defined object_ids with special format names in attributes through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
560570
type: 'single',
561571
measure: {
562572
url: 'http://localhost:' + config.http.port + '/iot/json',
@@ -567,7 +577,10 @@ const testCases = [
567577
},
568578
json: {
569579
a: false,
570-
'.1.0.0.1': 23.5
580+
'.1.0.0.1': 23.5,
581+
fdt: 10,
582+
fireDetectionThreshold2: 20,
583+
fireDetectionThreshold3: 30
571584
}
572585
},
573586
expectation: {
@@ -586,6 +599,18 @@ const testCases = [
586599
psBatteryVoltage: {
587600
type: 'Number',
588601
value: 23.5
602+
},
603+
fireDetectionThreshold: {
604+
type: 'Number',
605+
value: 10
606+
},
607+
fireDetectionThreshold2: {
608+
type: 'Text',
609+
value: 20
610+
},
611+
fireDetectionThreshold3: {
612+
type: 'Number',
613+
value: 30
589614
}
590615
}
591616
}

0 commit comments

Comments
 (0)