[TIMOB-12012] SQLite fieldCount() Crashes on iOS
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-12-11T20:55:24.000+0000 |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 API |
| Components | Core, iOS |
| Labels | database, qe-testadded, triage |
| Reporter | Rick Blalock |
| Assignee | Ingo Muschenetz |
| Created | 2012-12-10T12:54:37.000+0000 |
| Updated | 2014-06-19T12:42:50.000+0000 |
Description
In 3.0 RC2 iOS crashes when trying to use fieldCount(). If changed to just fieldCount (the property) it works. Previously fieldCount as a property wasn't supported in iOS but I see it's available now (http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Database.ResultSet-property-fieldCount). Probably was a parity issue that was fixed but in the process causes this crash.
The code that makes it crash (from the Joli ORM lib on github):
if (Titanium.Platform.name !== 'android') {
fieldCount = rows.fieldCount;
} else {
fieldCount = rows.fieldCount();
}
PR's https://github.com/appcelerator/titanium_mobile/pull/3575 https://github.com/appcelerator/titanium_mobile/pull/3576 Reverted fixes for ticket TIMOB-2328
TESTING CODE
var win = Ti.UI.createWindow(); win.open(); var db = Titanium.Database.open('testdb'); db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST (ID INTEGER, NAME TEXT)'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',1,'Name 1'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',2,'Name 2'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',3,'Name 3'); db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',4,'Name 4'); var rows = db.execute('SELECT * FROM DATABASETEST'); Ti.API.info("If this didnot crash then you r fine !! fieldCount: " + rows.fieldCount); Titanium.API.info('ROW COUNT = ' + rows.getRowCount());Closing as fixed. Tested and verified with: Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 3.1.0.v20130114171802 Titanium SDK, build: 3.0.1.v20130114133207 iPhone Simulator 6.0 iPhone 5 iOS 6.0 iPhone 4 iOS 4.3.5