I try building a database with two collections, one customer collection and one for orders. I get the following error:
Script Error { [ERROR] : backtrace = "#0 Migrate() at file://localhost/Users/h23/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EB1C5461-3459-491C-A0BD-8F6DF9DF14BE/HandwerkerApp.app/alloy/sync/sql.js:206\n#1 () at file://localhost/Users/h23/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EB1C5461-3459-491C-A0BD-8F6DF9DF14BE/HandwerkerApp.app/alloy/sync/sql.js:312\n#2 () at file://localhost/Users/h23/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EB1C5461-3459-491C-A0BD-8F6DF9DF14BE/HandwerkerApp.app/alloy.js:40\n#3 () at file://localhost/Users/h23/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EB1C5461-3459-491C-A0BD-8F6DF9DF14BE/HandwerkerApp.app/alloy/models/Order.js:24"; [ERROR] : line = 64; [ERROR] : message = "invalid SQL statement"; [ERROR] : nativeLocation = "-[TiDatabaseProxy execute:] (TiDatabaseProxy.m:186)"; [ERROR] : nativeReason = "Error Domain=com.plausiblelabs.pldatabase Code=3 \"An error occured parsing the provided SQL statement.\" UserInfo=0xad314b0 {com.plausiblelabs.pldatabase.error.vendor.code=1, NSLocalizedDescription=An error occured parsing the provided SQL statement., com.plausiblelabs.pldatabase.error.query.string=CREATE TABLE IF NOT EXISTS order ( orderNumber TEXT,orderName TEXT,alloy_id TEXT UNIQUE), com.plausiblelabs.pldatabase.error.vendor.string=near \"order\": syntax error}"; [ERROR] : sourceId = 307482880; [ERROR] : sourceURL = "file://localhost/Users/h23/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EB1C5461-3459-491C-A0BD-8F6DF9DF14BE/HandwerkerApp.app/alloy/sync/sql.js"; [ERROR] : } [ERROR] : Script Error Module "alloy/models/Order" failed to leave a valid exports objectThe code I am using is:
exports.definition = { config: { columns: { "orderNumber": "string", "orderName": "string" }, adapter: { type: "sql", collection_name: "order" } }, extendModel: function(Model) { _.extend(Model.prototype, { // extended functions and properties go here }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { // extended functions and properties go here }); return Collection; } }And for the second collection:
exports.definition = { config: { columns: { "firstName": "string", "lastName": "string", "company":"string", "mobilePhone" : "string", "workPhone": "string", "adressStreet": "string", "adressPLZ":"int", "adressCity":"string", "companyPictureID":"string" }, adapter: { type: "sql", collection_name: "customer" } }, extendModel: function(Model) { _.extend(Model.prototype, { // extended functions and properties go here validate: function (attrs) { if (!_.contains(Object.keys(attrs),"lastName")) return "Error: attributes do not contain lastName"; for (var key in attrs) { var value = attrs[key]; if (key === "lastName") { if (value.length <= 0) { return "Error: No lastName!"; } } } } }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { // extended functions and properties go here comparator : function(customer) { return customer.get('lastName'); } }); return Collection; } }
First I created the customers database, then I added the orders database. Deleting the sql- database and deleting the App from the iPhone Simulator did not help.