{ "id": "76478", "key": "TIMOB-5566", "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": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-06-17T01:13:24.000+0000", "created": "2011-06-16T04:56:23.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "mnegadaylov", "key": "mnegadaylov", "displayName": "Maxim Negadaylov", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-09T20:50:04.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": "11500", "name": "MobileWeb", "description": "Mobile Web (HTML) Platform" } ], "description": "Method 'close' of Titanium.Database.DB does not work. After using method Ti.Database.DB.close() the data of database is still available.\r\nHow to represent: \r\n1.Insert some data in the database\r\n2. Check content of the database by 'See data'\r\n3. Click on 'CloseDB' button. It will executes method Ti.Database.DB.close() of current database.\r\n4. Click 'See data' and you will see the data of database again.\r\nExpected behavior: Database should be closed and 'See Data' should return nothing.\r\n{code:JavaScript}\r\nvar win = Ti.UI.currentWindow;\r\nwin.backgroundColor = '#fff';\r\nwin.layout = 'vertical';\r\n\r\nvar l = Ti.UI.createScrollView({\r\n\ttop:10,\r\n\tleft:10,\r\n\tfont:{fontSize:14},\r\n\tcolor:'black',\r\n\theight:180,\r\n\twidth:300,\r\n\tborderWidth: 1\r\n});\r\n\r\nwin.add(l);\r\n\r\nvar label1 = Titanium.UI.createLabel({\r\n\theight:14,\r\n\ttop:5,\r\n\tleft:10,\r\n\twidth:300,\r\n\ttext: 'mobile browser use two finger swipe to scroll data',\r\n\tfont: {fontSize:12}\r\n});\r\n\r\nwin.add(label1);\r\n\r\nvar field = Titanium.UI.createTextField({\r\n\theight:30,\r\n\ttop:10,\r\n\tleft:10,\r\n\twidth:300,\r\n\tborderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED\r\n});\r\n\r\nwin.add(field);\r\n\r\nvar b1 = Ti.UI.createButton({\r\n\ttitle:'Insert',\r\n\theight:30,\r\n\twidth:300,\r\n\ttop:10,\r\n\tleft:10,\r\n\tfont: {fontSize:18}\r\n});\r\nwin.add(b1);\r\n\r\nb1.addEventListener('click', function(){\r\n\tdoInsert(field.value);\r\n});\r\n\r\nvar b2 = Ti.UI.createButton({\r\n\ttitle:'See data',\r\n\theight:30,\r\n\twidth:300,\r\n\ttop:10,\r\n\tleft:10,\r\n\tfont:{fontSize:18}\r\n});\r\nwin.add(b2);\r\n\r\nb2.addEventListener('click', function(){\r\n\tseeResults();\r\n});\r\n\r\nvar b3 = Ti.UI.createButton({\r\n\ttitle:'Clean',\r\n\theight:30,\r\n\twidth:300,\r\n\tleft:10,\r\n\ttop:10,\r\n\tfont:{fontSize:18}\r\n});\r\nwin.add(b3);\r\n\r\nb3.addEventListener('click', function(){\r\n\tdeleteEverything();\r\n});\r\n\r\nvar b4 = Ti.UI.createButton({\r\n\ttitle:'CloseDB',\r\n\theight:30,\r\n\twidth:300,\r\n\tleft:10,\r\n\ttop:10,\r\n\tfont:{fontSize:18}\r\n});\r\nwin.add(b4);\r\n\r\nb4.addEventListener('click', function(){\r\n\tdb.close();\r\n});\r\n\r\n\r\nif( (Ti.Platform.osname == 'iphone')&&(!Ti.Platform.isBrowser) ){\r\n\tvar textArea = Ti.UI.createTextArea({\r\n\t\tvalue: '',\r\n\t\twidth: 300,\r\n\t\theight: 180\r\n\t});\r\n\tl.add(textArea);\r\n}\r\n\r\nfunction writeToLog(/*string*/ newLogItem){\r\n\tif( (Ti.Platform.osname == 'iphone')&&(!Ti.Platform.isBrowser) ){\r\n\t\ttextArea.value = textArea.value +'\\n'+ newLogItem;\r\n\t}else{\r\n\t\tl.add(Ti.UI.createLabel({\r\n\t\t\t\ttext: newLogItem + \"
\",\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n}\r\n\r\nvar db = Titanium.Database.open('mydb');\r\ndb.execute('CREATE TABLE IF NOT EXISTS DATABASETEST_ADV (ID INTEGER, NAME TEXT)');\r\ndb.execute('DELETE FROM DATABASETEST_ADV');\r\nvar counter = 0;\r\n\r\nfunction doInsert(name){\r\n\texecuteSQL('INSERT INTO DATABASETEST_ADV (ID, NAME ) VALUES(?,?)', counter++, name, reportResults);\r\n}\r\n\r\nfunction executeSQL (sql) {\r\n\tvar values = [];\r\n\tvar callback = null;\r\n\tfor (var i = 1; i < arguments.length; i++){\r\n\t\tvar val = arguments[i];\r\n\t\t\r\n\t\tif (typeof val == 'function'){\r\n\t\t\tcallback = val;\r\n\t\t} else {\r\n\t\t\tvalues.push(val);\r\n\t\t}\r\n\t}\r\n\tstr = \"Execute SQL: \" + sql + \", arguments passed: [\" + values.join(\", \") + \"]\";\r\n\r\n\twriteToLog(str);\r\n\t// selects require callback for mobile web - because SQL is async here\r\n\tif (Ti.Platform.isBrowser) {\r\n\t\tvalues.length > 0 ? db.execute(sql, values, callback) : db.execute(sql, callback);\r\n\t} else {\r\n\t\tcallback(values.length ? db.execute(sql, values) : db.execute(sql));\r\n\t}\r\n}\r\n\r\nfunction reportResults (rows) {\r\n var str = '';\r\n\tstr += 'INSERTED: rowsAffected = ' + db.rowsAffected + \", \" + 'lastInsertRowId = ' + db.lastInsertRowId;\r\n\twriteToLog(str);\r\n}\r\n\r\nfunction seeResults(){\r\n\texecuteSQL('SELECT * FROM DATABASETEST_ADV', function(rows){\r\n\t\tvar str = '';\r\n\t\tstr += 'ROW COUNT = ' + rows.getRowCount();\r\n\r\n\t\twhile (rows.isValidRow()) {\r\n\t\t\tstr += '\\nID: ' + rows.field(0) + ' NAME: ' + rows.fieldByName('name');\r\n\t\t\trows.next();\r\n\t\t}\r\n\t\trows.close();\r\n\t\twriteToLog(str);\r\n\t});\r\n}\r\n\r\nfunction deleteEverything(){\r\n\texecuteSQL('DELETE FROM DATABASETEST_ADV', function(){\r\n\t\tvar str = \"Rows deleted: \"+db.rowsAffected;\r\n\t\twriteToLog(str);\r\n\t});\r\n}\r\n\r\nvar closeButton = Ti.UI.createButton({\r\n\ttitle:'Close Window',\r\n\theight:30,\r\n\twidth:300,\r\n\ttop:10,\r\n\tleft:10,\r\n\tfont:{fontSize:20}\r\n});\r\nwin.add(closeButton);\r\n\r\ncloseButton.addEventListener('click', function(){\r\n\tTi.UI.currentWindow.close();\r\n});\r\n\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "MobileWeb: Method 'close' of Titanium.Database.DB does not work", "creator": { "name": "mvasko", "key": "mvasko", "displayName": "Misha Vasko", "active": true, "timeZone": "Europe/Kiev" }, "subtasks": [], "reporter": { "name": "mvasko", "key": "mvasko", "displayName": "Misha Vasko", "active": true, "timeZone": "Europe/Kiev" }, "environment": null, "comment": { "comments": [ { "id": "410481", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as fixed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-09T20:50:04.000+0000", "updated": "2017-03-09T20:50:04.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }