Hello,
I'm using Alloy 1.0 with titanium studio build: 3.0.2.201302081641 and titanium SDK 3.0.2.v20130207164659
I'm using a pre-populated database . Here is the code of my Alloy model :
exports.definition = { config: { // No need to define columns object, loading the db_file // below will do that for us. "adapter" : { "type" : "sql", // db_file tells model to use myapp.sqlite file to install // database and to use "myapp" as the database name for // all further operations "db_file" : "/dbrauch.sqlite", "db_name" : "dbrauch", // The table name inside the sqlite database to use for // models and collections based on this definition. "collection_name" : "streuername" // idAttribute tells Alloy/Backbone to use this column in // my table as its unique identifier field. Without // specifying this, Alloy's default behavior is to create // and "alloy_id" field which will uniquely identify your // rows in the table. } }, extendModel: function(Model) { _.extend(Model.prototype, { // Extend Backbone.Model //Initialisation custom properties "label" initialize:function(){ this.set({"label":this.get("Streuername") }); }, getLabel: function() { return this.get('Streuername'); }, }); return Model; } }Then I create my Alloy Collection :
Alloy.Collections.sprayers = Alloy.createCollection("Sprayer");
And then I am displaying it using a table view ...
Ok everything is working fine with iOS (I see my 30 lines of data .. )
But when executing my code on Android emulator I have this error :
[ERROR][TiExceptionHandler( 445)] (main) [1819,3290] ----- Titanium Javascript Runtime Error ----- [ERROR][TiExceptionHandler( 445)] (main) [0,3290] - In alloy/sync/sql.js:235,15 [ERROR][TiExceptionHandler( 445)] (main) [1,3291] - Message: Uncaught TypeError: Cannot call method 'isValidRow' of null [ERROR][TiExceptionHandler( 445)] (main) [0,3291] - Source: while (rs.isValidRow()) { [ERROR][V8Exception( 445)] Exception occurred at alloy/sync/sql.js:235: Uncaught TypeError: Cannot call method 'isValidRow' of null
When opening the file alloy/sync/sql.js and debuging it , it appears that the generated code :
Ti.API.debug("Installing sql database \"" + dbFile + "\" with name \"" + dbName + "\""); var db = Ti.Database.install(dbFile, dbName), rs = db.execute("pragma table_info(\"" + table + "\");"), columns = {}; while (rs.isValidRow()) { var cName = rs.fieldByName("name"), cType = rs.fieldByName("type"); columns[cName] = cType; cName === ALLOY_ID_DEFAULT && !config.adapter.idAttribute && (config.adapter.idAttribute = ALLOY_ID_DEFAULT); rs.next(); }is crashing because the query db.execute("pragma table_info(\"" + table + "\");") is returning null .
While debugging I noticed that the table variable is well initialized. The SQL query is correct. (I manually executed it ) .
Any clue of what is going on ?
What can I do to get it working on Android ?
Thanks in advance for any helps.