op-sqlite icon indicating copy to clipboard operation
op-sqlite copied to clipboard

db.delete tries to delete wrong path when using an absolute location path

Open francescotescari opened this issue 2 months ago • 2 comments

Describe the bug When calling db.delete on a db with an absolute location path, the underlying database is not deleted because the path passed to the delete function is wrong.

Error: Exception in HostFunction: [op-sqlite]: Database file not found/Users/franz/Library/Developer/CoreSimulator/Devices/696292DB-6A10-499A-BE60-7466EF5DAF90/data/Containers/Data/Application/8AEFF1D1-1C41-4500-BCB4-C2A136093373/Library//Users/franz/Library/Developer/CoreSimulator/Devices/696292DB-6A10-499A-BE60-7466EF5DAF90/data/Containers/Data/Application/8AEFF1D1-1C41-4500-BCB4-C2A136093373/Library/UDB-User13518182+RemoteGraph.sql
    at delete (native)

Versions:

  • OS and version: iOS simulator 17.0
  • op-sqlite version: 3.0.7
  • RN version: 0.71.14
  • New Architecture: No

Reproducible example

  • Open a the database specifying a location, e.g const db = open({ name: 'test.sql', location: Platform.OS === 'ios' ? IOS_LIBRARY_PATH : ANDROID_DATABASE_PATH });
  • Invoke db.delete(), it will throw

By looking at the code, the offending lines seem to be these ones: if we specify an absolute path in the location, the delete method is going to concatenate it to the base path, creating an invalid path.

francescotescari avatar May 02 '24 14:05 francescotescari

thanks! I will take a look in a bit!

ospfranco avatar May 03 '24 06:05 ospfranco

5.0.6 is out and should fix the issue

ospfranco avatar May 03 '24 06:05 ospfranco

Closing this, issue should be fixed

ospfranco avatar May 11 '24 06:05 ospfranco