resultset.fieldCount
on Android
and
resultset.fieldCount()
on iPhone
Can we have some parity please? At this point, you'll probably have to support fieldCount as both a function and a property on both platforms, to avoid breaking existing code.
This code will run on iOS, but fail on Android
var win = Ti.UI.createWindow();
win.open();
var db = Titanium.Database.open('mydb');
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(rows.fieldCount());
rows.close();
db.close();
This code will run on Android, but fail on iOS
var win = Ti.UI.createWindow();
win.open();
var db = Titanium.Database.open('mydb');
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(rows.fieldCount);
rows.close();
db.close();
This makes the code harder to write since developers but call a different code depending on the platform they are running. Also, there is a very subtle difference between the two, this makes this kind of error very easy to overlook. There should be a common way (either function or property) to access this information on all platforms.
Thank you for raising this ticket. I am afraid we need all the information listed in the [Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist) in order to accept a ticket. In this instance, we need a complete code sample showing the issue. Once this ticket is complete, we can move it to the main project. Thank you
Thanks, Christian, for adding the sample code. Matthew, does this ticket now have what you need?
Shawn, We do request that sample code have at least one window to indicate the completeness of the code (that it can be run as a single app.js)
The description of this ticket is pretty straight forward, even without sample code. In order to supply a true testcase that runs on its own, I'd have to supply a database also, which I can't submit in text. Do you really need anything else to take a look at fieldCount ?
would just like to add, resultset.getFieldCount() works for both, though is documented as android only?
fieldCount will only be supported as a read only property beginning Release 3.3.0 of the SDK Pull pending https://github.com/appcelerator/titanium_mobile/pull/5657
Vishal, does that mean that the iOS fieldCount() function is being removed, and that the fieldCount property will exist in both Android and iOS?
@[~bitshftr] Yes fieldCount() method has been removed. fieldCount is a read only property now on all supported platforms (ios, android,blackberry). rs.fieldCount - Supported rs.getFieldCount() - Supported rs.fieldCount() - Unsupported
Environment - Appc-Studio:3.3.0.201405011408 sdk:3.3.0.v20140507163312 acs:1.0.14 alloy:1.4.0-dev npm:1.3.2 titanium:3.3.0-dev titanium-code-processor:1.1.1 xcode:5.1.1 Device:Iphone5s(v7.1.1),Nexus7(v4.4.2) Result - fieldCount() method has been removed. fieldCount is a read only property on ios and android. Tested the code with "Ti.API.info(rows.fieldCount)" mentioned above and its working fine. Hence closing this issue.