Skip to content

Commit ced44b0

Browse files
GuillaumeOdGuillaumeOdile
authored andcommitted
fix: attribute loss when updating entity
1 parent 518d322 commit ced44b0

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Upgrade express de from 4.19.2 to 4.20.0
1+
- Fix attribute loss during device update when both name and object_id are defined by filtering only object_id (issue #1660)

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

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

468468
if (
469469
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)