{ "id": "170774", "key": "ALOY-1599", "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": "20064", "name": "CLI Release 7.0.3", "archived": false, "released": true } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-01-16T23:34:18.000+0000", "created": "2018-01-11T11:21:29.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "updated": "2018-04-09T23:22:33.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": "13605", "name": "Models" } ], "description": "There is a problem with code generated for Simple Data Binding with the first upper case letter in model name.\r\n\r\nI have two models defined:\r\napp/models/book.js\r\napp/models/Task.js\r\n\r\nI expect that following XMLs will produce the same code:\r\n{code:xml}\r\n\r\n\t\r\n\t\r\n\r\n{code}\r\n{code:xml}\r\n\r\n\t\r\n\t\r\n\r\n{code}\r\n\r\n\r\nBut in the first case it is correct:\r\n{code:javascript}\r\n\tAlloy.Models.instance('book');\r\n\r\n\t$.__views.Book = Ti.UI.createLabel({ id: \"Book\" });\r\n\t$.__views.Book && $.addTopLevelView($.__views.Book);\r\n\tvar __alloyId2 = function () {\r\n\t\tAlloy['Models']['book'].__transform = _.isFunction(Alloy['Models']['book'].transform) ? Alloy['Models']['book'].transform() : Alloy['Models']['book'].toJSON();$.Book.text = Alloy['Models']['book']['__transform']['name'];\r\n\t};Alloy['Models']['book'].on('fetch change destroy', __alloyId2);exports.destroy = function () {\r\n\t\tAlloy['Models']['book'] && Alloy['Models']['book'].off('fetch change destroy', __alloyId2);\r\n\t};\r\n{code}\r\n\r\nand in the second case it is invalid:\r\n{code:javascript}\r\n\t$.__views.Task = Ti.UI.createLabel({ text: $model.__transform.Task.name, id: \"Task\" });\r\n\t$.__views.Task && $.addTopLevelView($.__views.Task);\r\n{code}\r\n\r\nand I get error $model.__transform is undefined", "attachment": [ { "id": "63949", "filename": "AlloyModelBindingIssue.zip", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-11T11:21:01.000+0000", "size": 22575, "mimeType": "application/zip" } ], "flagged": false, "summary": "ALLOY: Model Data binding problem with the first upper case in the model src", "creator": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "subtasks": [], "reporter": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "environment": null, "closedSprints": [ { "id": 986, "state": "closed", "name": "2018 Sprint 01 Tooling", "startDate": "2017-12-31T16:58:25.103Z", "endDate": "2018-01-14T16:58:00.000Z", "completeDate": "2018-01-17T22:42:40.307Z", "originBoardId": 219 } ], "comment": { "comments": [ { "id": "433061", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello [~darknos],\r\nThanks for sharing with us. Can you please test the sample code on latest SDK and share the console logs here.\r\n\r\nBest", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-01-12T08:27:40.000+0000", "updated": "2018-01-12T08:27:40.000+0000" }, { "id": "433062", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "{noformat}\r\nAlloy 1.11.0 by Appcelerator. The MVC app framework for Titanium.\r\n\r\n[DEBUG] ----- CONFIGURATION -----\r\n[DEBUG] raw config = \"platform=ios\"\r\n[DEBUG] platform = ios\r\n[DEBUG] deploytype = development\r\n[DEBUG] project path = /Users/admin/tmp/AlloyModelBindingIssue\r\n[DEBUG] app path = /Users/admin/tmp/AlloyModelBindingIssue/app\r\n[DEBUG]\r\n[DEBUG] ----- CONFIG.JSON -----\r\n[DEBUG] dependencies = {}\r\n[INFO] [config.json] config.json unchanged, using cached config.json...\r\n[DEBUG] {\r\n[DEBUG] \"dependencies\": {},\r\n[DEBUG] \"sourcemap\": true,\r\n[DEBUG] \"autoStyle\": false,\r\n[DEBUG] \"adapters\": [\r\n[DEBUG] \"localStorage\",\r\n[DEBUG] \"properties\",\r\n[DEBUG] \"sql\"\r\n[DEBUG] ]\r\n[DEBUG] }\r\n[DEBUG]\r\n[DEBUG] ----- CLEANING RESOURCES -----\r\n[DEBUG] Removing orphaned controllers ...\r\n[DEBUG] Removing orphaned models ...\r\n[DEBUG] Removing orphaned styles ...\r\n[DEBUG] Removing orphaned sync adapters...\r\n[DEBUG] Removing orphaned assets and libs...\r\n[TRACE] * iphone/\r\n[DEBUG]\r\n[DEBUG] ----- BASE RUNTIME FILES -----\r\n[TRACE] SRC_DIR=/Users/admin/.nvm/versions/node/v8.9.1/lib/node_modules/alloy/Alloy/lib\r\n[TRACE] Copying SRC_DIR/alloy/widget.js --> Resources/iphone/alloy/widget.js\r\n[TRACE] Copying SRC_DIR/alloy/underscore.js --> Resources/iphone/alloy/underscore.js\r\n[TRACE] Copying SRC_DIR/alloy/sync/sql.js --> Resources/iphone/alloy/sync/sql.js\r\n[TRACE] Copying SRC_DIR/alloy/sync/properties.js --> Resources/iphone/alloy/sync/properties.js\r\n[TRACE] Copying SRC_DIR/alloy/sync/localStorage.js --> Resources/iphone/alloy/sync/localStorage.js\r\n[TRACE] Copying SRC_DIR/alloy/controllers/BaseController.js --> Resources/iphone/alloy/controllers/BaseController.js\r\n[TRACE]\r\n[TRACE] Generating ../Resources/iphone/alloy.js\r\n[TRACE] SRC_DIR=/Users/admin/.nvm/versions/node/v8.9.1/lib/node_modules/alloy/Alloy/common\r\n[TRACE] Copying SRC_DIR/constants.js --> Resources/iphone/alloy/constants.js\r\n[TRACE]\r\n[DEBUG] Resetting /Users/admin/tmp/AlloyModelBindingIssue/platform/ios\r\n[DEBUG]\r\n[DEBUG] Resetting /Users/admin/tmp/AlloyModelBindingIssue/i18n\r\n[DEBUG]\r\n[INFO] ----- MVC GENERATION -----\r\n[INFO] [global style] loading from cache...\r\n[INFO] [models/Task.js] model processing...\r\n[INFO] [models/book.js] model processing...\r\n[INFO] [Book.xml] view processing...\r\n[INFO] style: \"Book.tss\"\r\n[INFO] view: \"Book.xml\"\r\n[INFO] controller: \"Book.js\"\r\n[INFO] created: \"Resources/iphone/alloy/controllers/Book.js\"\r\n[INFO] created: \"Resources/iphone/alloy/styles/Book.js\"\r\n[INFO] [Task.xml] view processing...\r\n[INFO] style: \"Task.tss\"\r\n[INFO] view: \"Task.xml\"\r\n[INFO] controller: \"Task.js\"\r\n[INFO] created: \"Resources/iphone/alloy/controllers/Task.js\"\r\n[INFO] created: \"Resources/iphone/alloy/styles/Task.js\"\r\n[INFO] [index.xml] view processing...\r\n[INFO] style: \"index.tss\"\r\n[INFO] view: \"index.xml\"\r\n[INFO] controller: \"index.js\"\r\n[INFO] created: \"Resources/iphone/alloy/controllers/index.js\"\r\n[INFO] created: \"Resources/iphone/alloy/styles/index.js\"\r\n[INFO]\r\n[INFO] [app.js] Titanium entry point processing...\r\n[INFO] created: \"Resources/iphone/app.js\"\r\n[INFO]\r\n[INFO] ----- OPTIMIZING -----\r\n[INFO] - iphone/alloy.js\r\n[INFO] - iphone/alloy/models/Book.js\r\n[INFO] - iphone/alloy/models/Task.js\r\n[INFO] - iphone/alloy/sync/localStorage.js\r\n[INFO] - iphone/alloy/sync/properties.js\r\n[INFO] - iphone/alloy/sync/sql.js\r\n[TRACE]\r\n[TRACE] Benchmarking\r\n[TRACE] ------------\r\n[TRACE] [0.41479s] TOTAL\r\n[INFO]\r\n[INFO] Alloy compiled in 0.41479s\r\n{noformat}\r\n", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-12T08:32:05.000+0000", "updated": "2018-01-12T08:32:05.000+0000" }, { "id": "433088", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~darknos] Naming them lowercase is a naming convention that Alloy requires and recommends. I do not see a reason we should support it, since you also wouldn't expect a Ti.UI.Window be accessible via ti.ui.window. Or am I missing something here?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-12T16:57:00.000+0000", "updated": "2018-01-12T16:57:00.000+0000" }, { "id": "433095", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "I told about names of my models in my project. I generated them from mongodb and loopback and everywhere they called from upper case. Seeding, Crop, Pest, Disease, etc.\r\n\r\nI expect that I can use my local model called \"Seeding\" in but I can't.\r\n\r\nBut look at the code above - there are completely different code for and or \r\n\r\nWhy? ", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-12T18:43:40.000+0000", "updated": "2018-01-12T18:43:40.000+0000" }, { "id": "433096", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "Hm...\r\n\r\n{quote}\r\nZachary Litten [1 day ago] \r\nAll my model names have begun with a capital? I was in the understanding that, that was the proper convention.\r\n{quote}\r\n\r\n{quote}\r\nRene Pot [1 day ago] \r\nsame here... most my models start with uppercase\r\n{quote}\r\n\r\nBut all of us used to use some workarounds. Couple of my friends never use Simple Data Binding because they are sure that it never works correct. \r\n\r\nI'm shocked that you are not shocked that Alloy generates different code depends from case of the first letter of the file name!", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-12T19:03:06.000+0000", "updated": "2018-01-12T19:03:06.000+0000" }, { "id": "433104", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "OK. I fixed it and prepared PR. https://github.com/appcelerator/alloy/pull/875\r\n\r\nand this is a simple minimal test case: https://github.com/darknos/AlloyBrokenSimpleDataBinding\r\n\r\nbtw, there are no test case with model named with the first upper letter.\r\n\r\nand it's quite funny because it generates model files with upper letter at start and called it \"properCase\" :)\r\n{code:javascript}\r\nexports.properCase = function(n) {\r\n\treturn n.charAt(0).toUpperCase() + n.substring(1);\r\n};\r\n{code}\r\n", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-12T22:27:17.000+0000", "updated": "2018-01-12T22:27:17.000+0000" }, { "id": "433106", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "btw, I did some investigation to find a source of issue.\r\n\r\n4 years ago code that force to lower case was just a part of [ALOY-932] Improve error messages \r\nhttps://github.com/appcelerator/alloy/commit/1c8e820fc1c3ed174ca46432dcd703a4316b6b9f#diff-ddbdb7300fa15590afdfee9246ac61fcR235\r\n\r\nthen after two years Fokke decided to use CU.models (that was created only for error reporting) for data binding\r\nhttps://github.com/appcelerator/alloy/commit/378370206762456c8e5debc00a6a93dc278bae14#diff-a59a2178e486f81366775c39e5393695R567\r\n\r\nbut he missed that it was lower cased. :(\r\n\r\nSo, it is not a \"a naming convention that Alloy requires and recommends\" but just a bug.", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-01-12T22:50:43.000+0000", "updated": "2018-01-12T22:50:43.000+0000" }, { "id": "433120", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~darknos] Very good research, thank you for that! I'll move it to the Alloy-namespace, so the Alloy team can review your PR. Thanks again!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-13T15:59:09.000+0000", "updated": "2018-01-13T15:59:09.000+0000" }, { "id": "435800", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "When I install alloy as `npm i -g alloy`, I got alloy v 1.11.0 BUT I see that PR above was not included in release. But if I download zip from releases page https://github.com/appcelerator/alloy/archive/1.11.0.zip I see that PR is included.\r\n\r\nI guess you sent to npm new version without raise up version so now npm has wrong version of alloy :(\r\n", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-03-21T11:52:55.000+0000", "updated": "2018-03-21T11:52:55.000+0000" }, { "id": "436679", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix in alloy 1.12.0.\r\n\r\nClosing.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-09T23:22:23.000+0000", "updated": "2018-04-09T23:22:23.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }