{ "id": "108485", "key": "ALOY-508", "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": [ { "id": "15271", "description": "Alloy 1.1.0, concurrent with SDK 3.1.0", "name": "Alloy 1.1.0", "archived": false, "released": true, "releaseDate": "2013-04-16" }, { "id": "14872", "description": "2013 Sprint 03", "name": "2013 Sprint 03", "archived": true, "released": true, "releaseDate": "2013-02-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-02-07T13:53:05.000+0000", "created": "2013-01-24T06:49:32.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "qe-port", "qe-sdk3.0.2" ], "versions": [], "issuelinks": [ { "id": "25671", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "108556", "key": "ALOY-487", "fields": { "summary": "SQL adapter does not accept ID when using PRIMARY KEY", "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" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-03-12T18:16:48.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": [ { "id": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "When you create a new object like:\r\nm = Alloy.createModel(modelName);\r\nm.attributes.customID = 1234;\r\nm.save();\r\n\r\nit doesn't save the id provided. I think that this provided should be saved, because if you provide this value is because you want this object to have this id (for example for synchronizing from another source).\r\n\r\nAssuming this is the desided behaviour, the line that is wrong is (sql_new.js:98)\r\nmodel.idAttribute === ALLOY_ID_DEFAULT ? model.id = util.guid() : model.id = null;\r\n\r\nAnd should be replaced by:\r\nmodel.idAttribute === ALLOY_ID_DEFAULT ? model.id = util.guid() : model.id = model.attributes[model.idAttribute];\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "sql_new adapter doesn't save the id provided when creating a new object", "creator": { "name": "jordivicedo", "key": "jordivicedo", "displayName": "Jordi Vicedo", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "jordivicedo", "key": "jordivicedo", "displayName": "Jordi Vicedo", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "237580", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Why wouldn't you just set m.idAttribute to \"customId\"?", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-07T01:22:00.000+0000", "updated": "2013-02-07T01:22:00.000+0000" }, { "id": "237600", "author": { "name": "jordivicedo", "key": "jordivicedo", "displayName": "Jordi Vicedo", "active": true, "timeZone": "Europe/Berlin" }, "body": "In the model, is set to customid:\n{noformat}\n[...]\n\"adapter\": {\n [...]\n idAttribute: \"customID\"\n}\n[...]\n{noformat}\n\nAfter working with Alloy for various days, I've found that we don't need this: we can make any field a primary key, and then retrieve the object using a query ( collection.fetch{query: ... }); )", "updateAuthor": { "name": "jordivicedo", "key": "jordivicedo", "displayName": "Jordi Vicedo", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-02-07T06:34:42.000+0000", "updated": "2013-02-07T06:34:42.000+0000" }, { "id": "237607", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "OK, I'm understanding what you mean in the original ticket description now. I'll take a look and see what I can do.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-07T12:37:34.000+0000", "updated": "2013-02-07T12:37:34.000+0000" }, { "id": "237608", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "On a side note, use {{m.set('customId',1234)}}, not {{m.attributes.customID = 1234;}}. Setting m.attributes directly will circumvent any Backbone.js eventing that should take place.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-07T13:27:22.000+0000", "updated": "2013-02-07T13:27:22.000+0000" }, { "id": "237609", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Resolved, tested, and will be available in Alloy 1.0.0. \r\n\r\nThe easiest way to test this fix is to use the [models/sql_keywords test app|https://github.com/appcelerator/alloy/tree/master/test/apps/models/sql_keywords], but *BEFORE* running it, make sure to remove the *AUTOINCREMENT* keyword from both the model and migration files. In addition, add a *fighterId* field to each inserted row in the migration. The changes are summed up in this gist:\r\n\r\nhttps://gist.github.com/tonylukasavage/4731041\r\n\r\nMake these changes in the test app, before running it, then run it and inspect the sqlite db file on the simulator/device to confirm that the ids from the migrations are used, not autoincrement ids.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-07T13:53:05.000+0000", "updated": "2013-02-07T13:53:05.000+0000" }, { "id": "237649", "author": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed on 1.0.0-cr and 1_0_X latest branch on iOS (iPAd 6.0, iPhone 5) and Android (Nexus 4 4.2, Nexus 7 4.1.2 and Nexus One 2.2.2)", "updateAuthor": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-07T19:35:23.000+0000", "updated": "2013-02-07T19:51:02.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }