Project: titanium
Issue TIMOB-19262: iOS: Encrypted Database Module: SQLite #26: file is encrypted or is not a database
h6.Issue Description Just picked up the latest version of the encrypted DB module from the dashboard (1.1.4) and upgraded our app. However the module is unable to access the DB. We get the error : (SQLite #26: file is encrypted or is not a database) h6.Expected behavior The new version of the module should be able to open the older DB with same secret. h6.Steps to Replicate: 1. Grab sample code and throw it to app.js 2. Run the app with the DB module version 1.0.0 - Alert is shown - Fetched : 1 3. Change the version of module to 1.1.4 in tiapp.xml 4. Run the app again - Error is seen - The DB cannot be accessed h6.Test Case {code} var dbobj = require("appcelerator.encrypteddatabase"); var instance = null; function init() {	dbobj.setPassword('secret');	Ti.API.info("Opening DB...");	instance = dbobj.open('test.db');	} function setup() {	instance.execute("CREATE TABLE IF NOT EXISTS testtable(id integer PRIMARY KEY);");	instance.execute("INSERT OR IGNORE INTO testtable(id) VALUES (1);"); } function fetch() {	var rowValue = null;	var rowHandle = instance.execute("SELECT * FROM testtable;");	if (rowHandle.isValidRow()) {	rowValue = rowHandle.fieldByName('id');	}	alert("Fetched Data: " + rowValue); } init(); setup(); fetch(); {code} h6.Logs {code} -- Start simulator log ------------------------------------------------------- [INFO] Application started [INFO] AppcDevPushTest/1.0 (4.0.0.9239ff9) [INFO] Opening DB... [ERROR] A SQLite database error occurred on database '/Users/egomez/Library/Developer/CoreSimulator/Devices/7144027B-9501-4AD8-B17E-D6797EF0BCE6/data/Containers/Data/Application/0ADB425C-2E78-4247-A1AB-CE977A6450FF/Library/Private Documents/test.db.sql': Error Domain=com.plausiblelabs.EncPLDatabase Code=3 "An error occured parsing the provided SQL statement." UserInfo=0x78e644e0 {com.plausiblelabs.EncPLDatabase.error.vendor.code=26, com.plausiblelabs.EncPLDatabase.error.vendor.string=file is encrypted or is not a database, NSLocalizedDescription=An error occured parsing the provided SQL statement., com.plausiblelabs.EncPLDatabase.error.query.string=CREATE TABLE IF NOT EXISTS testtable(id integer PRIMARY KEY);} (SQLite #26: file is encrypted or is not a database) (query: 'CREATE TABLE IF NOT EXISTS testtable(id integer PRIMARY KEY);') [ERROR] Script Error { [ERROR] column = 21; [ERROR] line = 8; [ERROR] message = "invalid SQL statement"; [ERROR] nativeLocation = "-[AppceleratorEncrypteddatabaseDBProxy execute:] (AppceleratorEncrypteddatabaseDBProxy.m:128)"; [ERROR] nativeReason = "Error Domain=com.plausiblelabs.EncPLDatabase Code=3 \"An error occured parsing the provided SQL statement.\" UserInfo=0x78e644e0 {com.plausiblelabs.EncPLDatabase.error.vendor.code=26, com.plausiblelabs.EncPLDatabase.error.vendor.string=file is encrypted or is not a database, NSLocalizedDescription=An error occured parsing the provided SQL statement., com.plausiblelabs.EncPLDatabase.error.query.string=CREATE TABLE IF NOT EXISTS testtable(id integer PRIMARY KEY);}"; [ERROR] sourceURL = "file:///Users/egomez/Library/Developer/CoreSimulator/Devices/7144027B-9501-4AD8-B17E-D6797EF0BCE6/data/Containers/Bundle/Application/2B0B25BF-3F5D-45A0-9C77-A9D120F654F1/AppcDevPushTest.app/app.js"; [ERROR] stack = "[native code]\nsetup@file:///Users/egomez/Library/Developer/CoreSimulator/Devices/7144027B-9501-4AD8-B17E-D6797EF0BCE6/data/Containers/Bundle/Application/2B0B25BF-3F5D-45A0-9C77-A9D120F654F1/AppcDevPushTest.app/app.js:8:21\nglobal code@file:///Users/egomez/Library/Developer/CoreSimulator/Devices/7144027B-9501-4AD8-B17E-D6797EF0BCE6/data/Containers/Bundle/Application/2B0B25BF-3F5D-45A0-9C77-A9D120F654F1/AppcDevPushTest.app/app.js:27:6"; [ERROR] } {code}
Story points: 13