Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19262] iOS: Encrypted Database Module: SQLite #26: file is encrypted or is not a database

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-08-19T09:13:46.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.0.0
ComponentsiOS
Labelsdatabase, sqlite
ReporterEduardo Gomez
AssigneeEric Merriman
Created2015-07-28T17:39:03.000+0000
Updated2017-03-31T22:16:53.000+0000

Description

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)

Expected behavior

The new version of the module should be able to open the older DB with same secret.

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

Test Case

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();

Logs

-- 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] } 

Comments

  1. Chee Kiat Ng 2015-08-17

    [~ewieber], That's odd. Mine works fine on 8.4. Also tried using titanium cli and appc cli. Ti SDK 4.1.0.GA and 4.1.1 titanium CLI 4.1.4 Appc CLI 4.2.0-51 [~egomez], yours worked too right? Nevertheless, I replaced the module zip file with a new built. Check it out again?
  2. Hans Knöchel 2015-08-17

    Latest zip works for me, same setup as [~cng]. Waiting for [~ewieber] to test before merging.
  3. Eric Wieber 2015-08-18

    Tried again, using: MacOS 10.11 Studio 4.2.0.201508062204 Ti SDK 4.1.1.v20150816214206 Appc NPM 4.1.0-2 Appc CLI 4.1.3-2 Ti CLI 4.0.1 Alloy 1.6.2 Node v0.10.37 Java 1.7.0_45 preproduction Xcode 6.4 (6E35b) I now get the Fetched Data: 1 alert with the 1.2.0 module, on iOS 8.4 sims and iOS 8.1 devices.
  4. Chee Kiat Ng 2015-08-19

    yay. Thanks [~ewieber], merge it now [~hansknoechel].
  5. Ingo Muschenetz 2015-10-29

    [~cng] can you please work with [~pkclark] to publish this?
  6. Patrick Clark 2015-10-30

    [~cng] just need the file and version info to drop into the manifest and get out on S3. Shoot me the file in an APPTS ticket AYC.
  7. Lee Morris 2017-03-31

    Closing ticket as fixed, if there are any problems, please file a new ticket.

JSON Source