{ "id": "63340", "key": "TIMOB-2708", "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": [ { "id": "11240", "name": "Release 1.6.0 M07", "archived": true, "released": true, "releaseDate": "2011-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:59:52.000+0000", "created": "2011-04-15T03:27:33.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "defect", "ios", "release-1.6.0", "reported-1.5.1" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:59:52.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Problem

\n

Given a ResultSet \"rows\" on iOS, calling \"rows.rowCount\" will\naffect the number of rows returned whle iterating over \"rows\" using\n\"rows.isValidRow()\" and \"rows.next()\".

\n

Expected Behavior

\n

Calling rows.rowCount should return the same integer as if you\ncount how many rows you iterate over using \"rows.isValidRow()\" and\n\"rows.next()\".

\n

Test Cases

\n

The first test below FAILS on iPhone simulator 4.2, PASSES on\nAndroid 2.2. The second test PASSES on both iPhone simulator 4.2\nand Android 2.2.

\n
\n/**\n * Initializes the test environment, creating a simple table \"data\" that has 1500\n * rows in it.\n */\nvar testRowCount = 1500;\nvar db = Ti.Database.open('data');\ndb.execute('CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY, val TEXT)');\ndb.execute('DELETE FROM data WHERE 1=1');\nfor (var i = 1; i <= testRowCount; i++) {\n    db.execute('INSERT INTO data (val) VALUES(?)','our value:' + i);\n}\n\n/**\n * TEST ROW COUNT DOES NOT ADVANCE RESULT SET.\n *\n * EXPECTED RESULT: rows.rowCount will return 1500, and realCount after\n * iterating over rows, will also return 1500.\n *\n * REAL BEHAVIOR IN 1.5.1: rows.rowCount returns 1000, and pushes the result set of\n * rows to 1001, so realCount after iteration is only 500, and not 1500 as expected.\n */\nfunction testRowCountDoesNotAdvanceResultSet() {\n    // now select out our data from the database\n    var rows = db.execute(\"SELECT * FROM data\");\n    var rowCount = rows.rowCount;\n    Ti.API.info('rows.rowCount = ' + rowCount);\n    var realCount = 0;\n    while (rows.isValidRow()) {\n        realCount += 1;\n        rows.next();\n    }\n    // check that the rowCount is equal to the number of rows we actually got out\n    Ti.API.info('realCount = ' + realCount);\n    if (realCount != rowCount) {\n        Ti.API.error('rowCount == realCount assertion FAILED!');\n    } else {\n        Ti.API.info('rowCount == realCount assertion PASSED!');\n    }\n}\n\ntestRowCountDoesNotAdvanceResultSet();\n\n/*\n * TEST RESULT SET COUNT WITHOUT ROW COUNT IS CORRECT\n *\n * To prove that the above test is valid, check that iterating over the result set\n * without first calling \"rows.rowCount\" will return the correct 1500 rows.\n *\n * EXPECTED RESULT: realCount after iterating over the rows will be 1500\n *\n * REAL BEHAVIOR IN 1.5.1: realCount after iterating over the rows is 1500\n */\nfunction testResultSetCountWithoutRowCount() {\n    // now select out our data from the database\n    var rows = db.execute(\"SELECT * FROM data\");\n    var realCount = 0;\n    while (rows.isValidRow()) {\n        realCount += 1;\n        rows.next();\n    }\n    Ti.API.info('realCount = ' + realCount);\n    if (realCount != testRowCount) {\n        Ti.API.error('realCount == ' + testRowCount + ' assertion FAILED!');\n    } else {\n        Ti.API.info('realCount == ' + testRowCount + ' assertion PASSED!');\n    }\n}\n\ntestResultSetCountWithoutRowCount();\n
\n

Associated Help Desk Ticket

\n

http://developer.appcelerator.com/helpdesk/view/61451

{html}", "attachment": [], "flagged": false, "summary": "ResultSet.rowCount Affects Row Pointer on iOS", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": null, "comment": { "comments": [ { "id": "129238", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "{html}

Sorry, assigned to Don instead of Ralf and tagged Android when\nit's really iOS. Fixed tags and assignment...

{html}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:27:33.000+0000", "updated": "2011-04-15T03:27:33.000+0000" }, { "id": "129239", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [eb5ab13fa39c7f2060542d48b83c873746cc1971])\n[#2708 state:fixed-in-qa] Remove arbitrary\n1000-result row count limit. Added drillbit test for database row\ncount integrity. \nhttps://github.com/appcelerator/titanium_mobile/commit/eb5ab13fa39c...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:27:34.000+0000", "updated": "2011-04-15T03:27:34.000+0000" }, { "id": "129240", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

Tested with the code provided on iPhone Simulator 4.2
\nConsole output:

\n
\n[INFO] rows.rowCount = 1500\n[INFO] realCount = 1500\n[INFO] rowCount == realCount assertion PASSED!\n[INFO] realCount = 1500\n[INFO] realCount == 1500 assertion PASSED!\n
\n

Ti SDK 1.6 (Jan 26 2011 18:55 rbd12917d)
\nTi Dev 1.3

{html}", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:27:34.000+0000", "updated": "2011-04-15T03:27:34.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }