{ "id": "63577", "key": "TIMOB-2945", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2012-08-29T19:49:06.000+0000", "created": "2011-04-15T03:33:31.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "parity" ], "versions": [ { "id": "11233", "name": "Release 1.6.0", "archived": true, "released": true, "releaseDate": "2011-02-23" }, { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [ { "id": "14282", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "62960", "key": "TIMOB-2328", "fields": { "summary": "Android: Database - ResultSet.fieldCount method on iOS (as per APIDOCs) but property on Android", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "20455", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "94532", "key": "TIMOB-9901", "fields": { "summary": "TiAPI: Review and clean up platform bugs and reduce bug count by 20%.", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T20:38:15.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "The APIDOCs at [Titanium.Database.ResultSet|http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Database.ResultSet-object.html] state that [fieldCount|http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Database.ResultSet.fieldCount-method.html] is a method. While this exists on iOS, Android provides it as a property.\r\n\r\nHence, this is a request to remove the property on Android and to replace it with a method.\r\n\r\nSee the following testcase provided by Ketan:\r\n\r\n{code:lang=javascript|title=app.js}\r\n/**\r\n * Initializes the test environment, creating a simple table \"data\" that has 150\r\n * rows in it and just 2 fields\r\n */\r\nvar testRowCount = 150;\r\nvar db = Ti.Database.open('data');\r\ndb.execute('CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY, val TEXT)');\r\ndb.execute('DELETE FROM data WHERE 1=1');\r\nfor (var i = 1; i <= testRowCount; i++) {\r\n db.execute('INSERT INTO data (val) VALUES(?)','our value:' + i);\r\n}\r\n\r\n/**\r\n * FIELD COUNT WORKS AS A METHOD AS EXPECTED ON IOS BUT RETURNS ERROR ON ANDROID.\r\n * EXPECTED RESULT: 2\r\n *\r\n * REAL BEHAVIOR IN 1.8.3: ANDROID SAYS: Uncaught TypeError: Property 'fieldCount' of object # is not a function\r\n */\r\nfunction testFieldCountCrashesOnAndroid() {\r\n // now select out our data from the database\r\n var rows = db.execute(\"SELECT * FROM data\");\r\n var fieldCount = rows.fieldCount();\r\n Ti.API.info('*** SHOULD WORK ON BOTH iOS & ANDROID ***');\r\n Ti.API.info('rows.fieldCount() = ' + fieldCount);\r\n}\r\n\r\ntestFieldCountCrashesOnAndroid();\r\n\r\n/**\r\n * FIELD COUNT WORKS AS A METHOD AS EXPECTED ON IOS BUT RETURNS ERROR ON ANDROID. You will need to comment out line 27 above to test it working on android.\r\n * EXPECTED RESULT: 2\r\n * \r\n * REAL BEHAVIOR IN 1.8.0.1 RC3: iOS only sees the result set object and no longer gets the field count value, although android now returns the value 2.\r\n */\r\nfunction testFieldCountWorksOnAndroid() {\r\n // now select out our data from the database\r\n var rows = db.execute(\"SELECT * FROM data\");\r\n var fieldCount = rows.fieldCount; // Changed to a property not a method call.\r\n Ti.API.info('*** NOW WORKS ON ANDROID NOT iOS ***');\r\n Ti.API.info('rows.fieldCount = ' + fieldCount);\r\n}\r\n\r\ntestFieldCountWorksOnAndroid();\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Database - ResultSet.fieldCount property should be ResultSet.fieldCount() method", "creator": { "name": "ben", "key": "ben", "displayName": "Ben", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ben", "key": "ben", "displayName": "Ben", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* Titanium 1.6.0+ up to 1.8.0.1 RC3 (and since 1.7.x)\r\n* Android APIs 2.3.3\r\n* Mac OS X \r\n* Studio 1.0.8.201112161851\r\n\r\n\r\n", "comment": { "comments": [ { "id": "132828", "author": { "name": "kurtzmarc", "key": "kurtzmarc", "displayName": "Marc Kurtz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I also have this problem in beta 1.7.0", "updateAuthor": { "name": "kurtzmarc", "key": "kurtzmarc", "displayName": "Marc Kurtz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-26T20:52:15.000+0000", "updated": "2011-04-26T20:52:15.000+0000" }, { "id": "133676", "author": { "name": "mark.henderson@snagr.co.uk", "key": "mark.henderson@snagr.co.uk", "displayName": "Mark Henderson", "active": true, "timeZone": "Europe/London" }, "body": "I see this using 1.6.2, in iPhone you have to use fieldCount() .fieldCount returns [DatabaseResultSet]", "updateAuthor": { "name": "mark.henderson@snagr.co.uk", "key": "mark.henderson@snagr.co.uk", "displayName": "Mark Henderson", "active": true, "timeZone": "Europe/London" }, "created": "2011-05-16T02:13:31.000+0000", "updated": "2011-05-16T02:13:31.000+0000" }, { "id": "176435", "author": { "name": "stereoket", "key": "stereoket", "displayName": "Ketan Majmudar", "active": true, "timeZone": "Europe/London" }, "body": "I believe as its a method the correct way of calling it is with {{Titanium.Database.ResultSet.fieldCount()}}. However Android thins it is a property and throws up such an error. Treating it as a property returns the result on Android but then does not return a result on iOS. The test case below shows this behaviour and can be replicated. Testing on iOS first shows one it working with one method. Then test on Android, and you will see the error. Thirdly commenting out the first function call then testing on android shows you it working on Android.\r\n\r\n\r\nTest Environment: \r\n\r\nHost OS: Mac OS X\r\nOS Arch: x86\r\nJRE Version: 1.6.0_29\r\nJRE Vendor: Apple Inc.\r\nJRE Home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home\r\nInstall Directory: file:/Applications/Titanium Studio/\r\nVersion: 1.0.8.201112161851\r\n\r\nSDK 1.8.0.1 RC3 (and since 1.7.x)\r\n\r\nIt is worth noting that I had noticed this problem in passing since Studio 1.6.x it's only now that i've come to a point where its critical for me to use.\r\n\r\n\r\n{code:title=app.js|borderStyle=solid}\r\n/**\r\n * Initializes the test environment, creating a simple table \"data\" that has 150\r\n * rows in it and just 2 fields\r\n */\r\nvar testRowCount = 150;\r\nvar db = Ti.Database.open('data');\r\ndb.execute('CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY, val TEXT)');\r\ndb.execute('DELETE FROM data WHERE 1=1');\r\nfor (var i = 1; i <= testRowCount; i++) {\r\n db.execute('INSERT INTO data (val) VALUES(?)','our value:' + i);\r\n}\r\n\r\n/**\r\n * FIELD COUNT WORKS AS A METHOD AS EXPECTED ON IOS BUT RETURNS ERROR ON ANDROID.\r\n * EXPECTED RESULT: 2\r\n *\r\n * REAL BEHAVIOR IN 1.8.3: ANDROID SAYS: Uncaught TypeError: Property 'fieldCount' of object # is not a function\r\n */\r\nfunction testFieldCountCrashesOnAndroid() {\r\n // now select out our data from the database\r\n var rows = db.execute(\"SELECT * FROM data\");\r\n var fieldCount = rows.fieldCount();\r\n Ti.API.info('*** SHOULD WORK ON BOTH iOS & ANDROID ***');\r\n Ti.API.info('rows.fieldCount() = ' + fieldCount);\r\n}\r\n\r\ntestFieldCountCrashesOnAndroid();\r\n\r\n/**\r\n * FIELD COUNT WORKS AS A METHOD AS EXPECTED ON IOS BUT RETURNS ERROR ON ANDROID. You will need to comment out line 27 above to test it working on android.\r\n * EXPECTED RESULT: 2\r\n * \r\n * REAL BEHAVIOR IN 1.8.0.1 RC3: iOS only sees the result set object and no longer gets the field count value, although android now returns the value 2.\r\n */\r\nfunction testFieldCountWorksOnAndroid() {\r\n // now select out our data from the database\r\n var rows = db.execute(\"SELECT * FROM data\");\r\n var fieldCount = rows.fieldCount; // Changed to a property not a method call.\r\n Ti.API.info('*** NOW WORKS ON ANDROID NOT iOS ***');\r\n Ti.API.info('rows.fieldCount = ' + fieldCount);\r\n}\r\n\r\ntestFieldCountWorksOnAndroid();\r\n{code}\r\n\r\nThe only way I see of working with this in production is by using something like this:\r\n\r\n{{cols=(Ti.Platform.osname === 'android')?rs.fieldCount:rs.fieldCount()}}\r\n\r\nWhere rs is a resultSet Object.", "updateAuthor": { "name": "stereoket", "key": "stereoket", "displayName": "Ketan Majmudar", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-18T10:32:08.000+0000", "updated": "2011-12-18T10:36:28.000+0000" }, { "id": "185684", "author": { "name": "stereoket", "key": "stereoket", "displayName": "Ketan Majmudar", "active": true, "timeZone": "Europe/London" }, "body": "It would be very useful if this was resolved, it makes parity difficult to debug, and costs many hours in development, OR make a change to the documentation to state there is a difference between iOS & Android.", "updateAuthor": { "name": "stereoket", "key": "stereoket", "displayName": "Ketan Majmudar", "active": true, "timeZone": "Europe/London" }, "created": "2012-03-08T18:26:00.000+0000", "updated": "2012-03-08T18:26:00.000+0000" }, { "id": "187390", "author": { "name": "summersmile1984", "key": "summersmile1984", "displayName": "summersmile", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I got this bug either. It waste me weeks to locate the problem! Resovle this , please! If there is any differents between the two platforms , please let the developers know.", "updateAuthor": { "name": "summersmile1984", "key": "summersmile1984", "displayName": "summersmile", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-03-20T09:18:09.000+0000", "updated": "2012-03-20T09:18:09.000+0000" }, { "id": "191986", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "IMHO, \r\n\r\n\r\n\"fieldCount\" - a property\r\n\"getFieldCount\" - a method\r\n\r\n\r\n\r\nBtw, as a workaround, \"fieldCount\" can be checked if its a method:\r\n\r\n{code}\r\nvar fieldCount;\r\nif (typeof rows.fieldCount == 'function') {\r\n fieldCount = rows.fieldCount();\r\n}\r\nelse {\r\n fieldCount = rows.fieldCount;\r\n}\r\n{code}", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-04-20T01:41:06.000+0000", "updated": "2012-04-20T01:41:06.000+0000" }, { "id": "216895", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Ticket is a duplicate of TIMOB-2328.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-08-29T14:34:58.000+0000", "updated": "2012-08-29T14:35:38.000+0000" }, { "id": "414898", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as duplicate of the ticket that is mentioned above and has since been closed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T20:38:15.000+0000", "updated": "2017-03-22T20:38:15.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }