{ "id": "114392", "key": "ALOY-730", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2013-07-09T17:01:51.000+0000", "created": "2013-05-15T15:35:24.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android,", "fetch", "idAttribute", "model", "sqlrest" ], "versions": [], "issuelinks": [], "assignee": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-06-22T13:23:20.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "*Problem*\r\nA model is created. The id of the model is set to a specific id. A fetch is made. When repeating this for another model with a different id results in a succes response object with 2 objects. There should be only one object because the fetch is for 1 specific object determined by the id. \r\n\r\nI've tried to create a collection and use the reset() function in all possible ways. Same situation/error. The created model doesn't have a reset method.\r\n\r\nWe prefer lazyloading of the object. Therefore we pass the objectId in the args.objectId. When creating this controller the code is executed and extra data is received with a get from the server. \r\n\r\n*Source*\r\n{code:javascript}\r\nvar args = arguments[0] || {};\r\nTi.API.info('args.objectId');\r\nTi.API.info(args.objectId);\r\n\r\n$.plaatsing.open();\r\n\r\nvar plaatsing = Alloy.createModel('plaatsing');\r\n\r\nplaatsing.id = args.objectId;\r\n\r\nplaatsing.fetch({\r\n\t\r\n\tsuccess : function(model) {\r\n\t\t\t\t\r\n\t\talert('succes: ' + JSON.stringify(model));\r\n\t\t\t\r\n\t\t\tvar plaatsing = model.toJSON();\r\n\t\t\t\r\n\t\t\tvar p = plaatsing[0];\t\t\t\t\t\t\r\n\t\r\n\t\t\t$.view1Block1Header.setText(p.plaatsing);\r\n\t},\r\n\terror : function(model) {\r\n\t\talert(' error ' + model);\r\n\t}\r\n});\r\n{code}\r\n\r\nfunction(model) here the model object is growinng in size by each new object instead of just containing the object where the id is set.", "attachment": [], "flagged": false, "summary": "Fetching different models with a specific idAttribute inserts instead of replaces the \"old\" object in the fetch success response object. ", "creator": { "name": "edekker", "key": "edekker", "displayName": "Edwin Dekker", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "latest titanium studio with sdk 3.1.0 GA\r\nphysical note 2 android device with android 4.1.2\r\nGoogle API's Android 2.2 armeabi\r\n\r\nusing as model.config.adapter.type:\r\n \r\n* SQL Rest Adapter for Titanium Alloy\r\n * @author Mads Møller\r\n * @version 0.1.17\r\n * Copyright Napp ApS\r\n * www.napp.dk", "comment": { "comments": [ { "id": "260955", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I need more details on what is going on here. To be clear, the issue is that the fetch() on the model is retrieving the whole collection dataset, not just the model, right? What sync adapter are you using? Details on the model itself would be useful.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-08T14:28:16.000+0000", "updated": "2013-07-08T14:28:16.000+0000" }, { "id": "261076", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Edwin,\r\n\r\nPlease can you provide the extra info that Tony asked for?\r\n\r\nThanks!", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-09T17:01:51.000+0000", "updated": "2013-07-09T17:01:51.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }