Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6081] iOS: Database.install does not copy the database file only creates a symbolic link

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2012-01-31T15:53:52.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2012-01, Release 2.0.0, Release 1.8.1
ComponentsiOS
Labelsqe-testadded
ReporterKarol Pomaski
AssigneeVishal Duggal
Created2011-11-08T11:06:00.000+0000
Updated2012-01-31T15:53:52.000+0000

Description

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

Attachments

FileDateSize
database.png2011-11-08T11:06:00.000+0000254914
speed.db2011-11-08T11:06:00.000+00001802240

Comments

  1. Vishal Duggal 2011-11-17

    This is expected behavior on the simulator. Works properly on device.
  2. Damien Elmes 2011-11-17

    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.
  3. Damien Elmes 2011-11-17

    I presume your comment was directed at Vishal - if not, please let me know.
  4. Ben Bahrenburg 2011-12-09

    Also running into issues with this. See helpdesk ticket http://support.appcelerator.com/tickets/APP-825542/tickets for details.
  5. Nick 2012-01-07

    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.
  6. Nick 2012-01-07

    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
  7. Learning Technology 2012-01-09

    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
  8. Peter Branson 2012-01-10

    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.
  9. Vishal Duggal 2012-01-13

    Pull pending #1160
  10. Vishal Duggal 2012-01-13

    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
  11. Natalie Huynh 2012-01-13

    Tested with 1.9.0.v20120113170134 on Simulator 5.0 and iPod 4.3.3
  12. Natalie Huynh 2012-01-31

    Open to add label

JSON Source