Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14206] BlackBerry: ResultSet.isValidRow() and ResultSet.rowCount failed when there is no records in table (Ti SDK 3.1.1)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-08-13T17:17:41.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 14, 2013 Sprint 14 API, Release 3.1.2, Release 3.2.0
ComponentsBlackBerry
LabelsBlackBerry, qe-3.1.2, qe-testadded
ReporterBharat Panthee
AssigneePedro Enrique
Created2013-06-13T15:42:25.000+0000
Updated2014-06-19T12:43:24.000+0000

Description

*Problem* The isValidRow method and rowCount property of ResultSet failed when the table is empty for BlackBerry. *Test case*
if (Ti.version < 1.8 ) {
	alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
}

// This is a single context application with mutliple windows in a stack
(function() {
	//determine platform and form factor and render approproate components
	var osname = Ti.Platform.osname,
		version = Ti.Platform.version,
		height = Ti.Platform.displayCaps.platformHeight,
		width = Ti.Platform.displayCaps.platformWidth;
	
	//considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide
	//yourself what you consider a tablet form factor for android
	var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
	
	    var db = Ti.Database.open("testBB2");
        var sSQL = "Create table if not exists testBB2(key text, value text)";
        db.execute(sSQL);
         db.execute("delete from testBB2");
        //sSQL = "insert into testBB2(key,value) values('1', 'testBB77777')";
        //db.execute(sSQL);
        var rs = db.execute("select * from testBB2");

        if(rs.isValidRow())
        {
            alert(rs.fieldByName('value'));
            rs.next();
        }
 
        alert('completed!');
        rs.close();
        db.close();
	
	/*
	var Window;
	if (isTablet) {
		Window = require('ui/tablet/ApplicationWindow');
	}
	else {
		Window = require('ui/handheld/ApplicationWindow');
	}

	var ApplicationTabGroup = require('ui/common/ApplicationTabGroup');
	new ApplicationTabGroup(Window).open();
	*/
})();
*BlackBerry emulator log*
app.js:38
        if(rs.isValidRow())
              ^
TypeError: Cannot call method 'isValidRow' of undefined
    at app.js:38:15
    at app.js:60:3

Comments

  1. Pedro Enrique 2013-08-12

    Sample code:
       var db = Ti.Database.open("testBB2");
       var sSQL = "Create table if not exists testBB2(key text, value text)";
       db.execute(sSQL);
       db.execute("delete from testBB2");
       
       var rs = db.execute("select * from testBB2");
        
       if(rs.isValidRow())
       {
           alert(rs.fieldByName('value'));
           rs.next();
       }
       
       alert('completed!');
       rs.close();
       db.close();
       
  2. Lokesh Choudhary 2013-08-12

    Running the sample test code given by pedro crashes the app at "rs.close()". Reopening
  3. Pedro Enrique 2013-08-13

    PR for master: https://github.com/appcelerator/titanium_mobile_blackberry/pull/159 PR for 3.1.x : https://github.com/appcelerator/titanium_mobile_blackberry/pull/160
  4. Lokesh Choudhary 2013-08-13

    verified the fix & the app works as expected & does not crash at "re.close()". Environment: Appcel Studio : 3.1.2.201308091728 Ti SDK : 3.1.2.v20130809141556 Mac OSX : 10.8.4 Alloy : 1.2.0-alpha6 CLI - 3.1.2-alpha win 7 Win 8 Z10 BB simulator : 10.0.10.822 Z10 device running 10.0.10.88 Q10 Simulator : 10.1.0.1720 Q10 Dev alpha C device running 10.1.0.138

JSON Source