Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] in PATCH v2/entities/<id> with new metadatas are appened instead of to replaced #1788

Closed
iariasleon opened this issue Feb 11, 2016 · 2 comments · Fixed by #2649
Closed
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

iariasleon commented Feb 11, 2016

in PATCH v2/entities/ with new metadatas are appened instead of to replaced.

Two metadata for create request and one metadata for PATCH request and finally there are three metadata in mongo, when there should only be one, the update metadata.

Create request

POST http://localhost:1026/v2/entities
Content-Type: application/json
Fiware-Service: test_attribute_metadata_name_update
Fiware-ServicePath: /test
{
   "type": "house", 
   "temperature": {
            "type": "celcius", 
            "value": "34", 
            "metadata": {
                        "warning_0": {"type": "alarm", "value": "hot"}, 
                        "warning_1": {"type": "alarm", "value": "hot"}}}, 
   "id": "room_1"}

Update request

PATCH http://qa-orion-fe-02:1026/v2/entities/room_1
Content-Type: application/json
Fiware-Service: test_attribute_metadata_name_update
Fiware-ServicePath: /test
{
         "temperature": {
                "value": "45", 
                "metadata": {
                       "my_meta": {"type": "nothing", "value": "5678"}}}}

Mongo doc

[{
      "modDate": 1455202600, "attrNames": ["temperature"], "_id": {"type": "house", "id": "room_1", "servicePath": "/test"}, 
      "attrs": {"temperature": {
                   "md": [
                           {"type": "nothing", "name": "my_meta", "value": "5678"}, 
                           {"type": "alarm", "name": "warning_0", "value": "hot"}, 
                           {"type": "alarm", "name": "warning_1", "value": "hot"}], 
                    "modDate": 1455202600, 
                    "type": "celcius", 
                    "value": "45", 
                    "creDate": 1455202600}}, 
     "creDate": 1455202600}]

expected in mongo (only a metadata)

      "modDate": 1455202600, "attrNames": ["temperature"], "_id": {"type": "house", "id": "room_1", "servicePath": "/test"}, 
      "attrs": {"temperature": {
                   "md": [
                            {"type": "nothing", "name": "my_meta", "value": "5678"}], 
                    "modDate": 1455202600, 
                    "type": "celcius", 
                    "value": "45", 
                    "creDate": 1455202600}}, 
     "creDate": 1455202600}]
@fgalan
Copy link
Member

fgalan commented Nov 10, 2016

Fixed by PR #2649. @iariasleon , ready for re-test, pls.

@iariasleon
Copy link
Contributor Author

LGTM

{ "_id" : { "id" : "room_1", "type" : "house", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "value" : null, "type" : "None", "md" : { "my_meta" : { "type" : "nothing", "value" : "5678" } }, "mdNames" : [ "my_meta" ], "creDate" : 1478790632, "modDate" : 1478790632 } }, "creDate" : 1478790632, "modDate" : 1478790632 }

@fgalan fgalan added this to the 1.6.0 milestone Nov 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants