OP-Engineering/op-sqlite

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

Closed this issue · 3 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.

thanks! I will take a look in a bit!

5.0.6 is out and should fix the issue

Closing this, issue should be fixed