Problem
While using the Titanium.Database.install on the simulator it is supposed to copy the database file to the /database directory under the application root folder, however it makes only a symbolic link between the file that is under /database and the one that was in /Resources.
The issue appears only on Simulator.
Reproducible Steps
1. Run the sample code with the sample database (db file attached)
2. Go to the application folder under simulator, the path should look similar: /Users/dawconsdwitservices/Library/Application Support/iPhone Simulator/5.0/Applications/D30F4B39-8A41-4B7F-A271-4EAF69AFDFC9/Library/Application Support/database . Take a look that the myDB.db file which is only a link to the original database file that is under /Resources folder.
Sample Code
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
var db = Titanium.Database.install('speed.db','myDB');
win1.add(label1);
win1.open();
Associated HelpDesk Ticket
http://appc.me/c/APP-421442
This is expected behavior on the simulator. Works properly on device.
The new behaviour is quite inconvenient - as I described in the helpdesk ticket, every time I test in the simulator, the pristine database is modified. It may be "expected" in that you guys decided to change the behaviour, but as a user of the toolkit it is not the behaviour I expect - especially as it's inconsistent with installing on a device. Please reconsider.
I presume your comment was directed at Vishal - if not, please let me know.
Also running into issues with this. See helpdesk ticket http://support.appcelerator.com/tickets/APP-825542/tickets for details.
I pleased to see this reopened because this is definitely not expected or desired behaviour. It breaks development, it breaks testing and makes a mess of your database. I am keen to see this resolved.
So I've read through the the install method in TiDatabaseProxy.m but I can't find a reference to create symbolic link, it is correctly using NSFileManager copyItemAtPath
Hi, I can confirm that I'm also having this issue - it's also duplicating rows instead of updating them so the database is getting bigger and bigger. While it might actually be useful to see what's going on in your database when debugging in the simulator, it is far from desirable to have different functionality between simulator and device - you need to *know* exactly how it's going to behave once deployed. Also, it's very frustrating that things like this keep changing in updates - as if there weren't enough changes to contend with - it would be nice if the updates fixed errors and didn't introduce new ones. Many thanks
I have also come across this issue, and it is very annoying when trying to develop new functionality. Also when you come to complete your release build you will need to make sure that the database in the resources folder is cleaned, otherwise test data may well be release with your app which is very undesirable. Many thanks.
Pull pending #1160
Since the changes made to the database location, the database is now located at $HOME/Library/Application Support/iPhone Simulator/5.0/Applications/D30F4B39-8A41-4B7F-A271-4EAF69AFDFC9/Library/Private Documents/myDB.sql
Tested with 1.9.0.v20120113170134 on Simulator 5.0 and iPod 4.3.3
Open to add label