[TIMOB-17831] iOS - SQLite module throws warnings about deprecated API usage
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-10-14T18:06:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.4.2, Release 3.5.0, Release 4.0.0 |
Components | iOS |
Labels | module_database, qe-manualtest |
Reporter | Pedro Enrique |
Assignee | Muhammad Dadu |
Created | 2014-10-08T18:55:41.000+0000 |
Updated | 2014-11-26T07:06:40.000+0000 |
PR: https://github.com/appcelerator/titanium_mobile/pull/6207 Removed warnings by implementing 'sqlite3_open_v2'. Tested using Kitchen SInk.
This change crashes a newly installed app (without existing database) on IOS. Instead of creating a new database, Titanium.Database.open() causes an error. To reproduce, just run a Ti.Database.open('_alloy_'); in a newly installed app, you will get [ERROR] : message = "couldn't open database"; [ERROR] : nativeLocation = "-[TiDatabaseProxy open:] (TiDatabaseProxy.m:112)"; If I add the removed line sqlite3_enable_shared_cache(TRUE); in the iphone/Classes/DatabaseModule.m, everything works as expected.
found the problem: in the sqlite3_open_v2 there must be an additional SQLITE_OPEN_CREATE flag, so the database will be created if not existing (which seemed to be a default behaviour of sqlite3_open) in PLSqliteDatabase.m openAndReturnError: /* Open the database */ err = sqlite3_open_v2([_path fileSystemRepresentation], &_sqlite, SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); So the removed sqlite3_enable_shared_cache(TRUE); in iphone/Classes/DatabaseModule.m wasn't problematic at all.
PR: https://github.com/appcelerator/titanium_mobile/pull/6218 Thank you for the help [~marek].
Backport to 3_4_X done as part of https://github.com/appcelerator/titanium_mobile/pull/6271
The database is created without crash when it doesn't exist. Verified with the Xcode=>Devices=>Installed Apps . Closing the ticket. Tested with the below Environment: 1. Mac OSX Yosemite 10.10 2. Appcelerator Studio, build: 3.4.1.201410281743 3. Titanium SDK, build: 3.5.0.v20141125154115 4. Titanium CLI, build: 3.4.1 5. Alloy: 1.5.1 6. Xcode 6.1 7. iOS SDK 8.1 8. iPhone 5s with iOS 8.1