typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

Disable transactionSupport option for CordovaDriver

Open michaelwolz opened this issue 3 years ago • 0 comments

Description of change

The cordova-sqlite-storage plugin does not support regular transactions at the moment.

See: https://github.com/storesafe/cordova-sqlite-storage#other-limitations

User-defined savepoints are not supported and not expected to be compatible with the transaction locking mechanism used by this plugin. In addition, the use of BEGIN/COMMIT/ROLLBACK statements is not supported.

This conflicts with the way typeORM is handling save / remove operations via the EntityPersistExecutor by default leading to errors when not explicitly disabling the transaction on each method call via the respective option (e.g. connection.manager.save(ExampleEntity, { transaction: false }). Prior version 0.2.34 this was not a problem since the transaction was basically just ignored but with fc4133c the start|commit|rollbackTransaction call will throw an error to indicate that transactions aren't supported which is totally correct in my opinion but is pretty hard to work with the current behavior of the EntityPersistExecutor. This PR will set the transactionSupport property of the CordovaDriver to none and also respect this setting in the EntityPersistExecutor.

Relates to:

  • https://github.com/typeorm/ionic-example/issues/44
  • https://github.com/typeorm/typeorm/issues/4075#issuecomment-933715081
  • https://github.com/storesafe/cordova-sqlite-storage/issues/865

Pull-Request Checklist

  • [x] Code is up-to-date with the master branch
  • [x] npm run format to apply prettier formatting
  • [x] npm run test passes with this change
  • [ ] This pull request links relevant issues as Fixes #0000 N/A
  • [x] There are new or updated unit tests validating the change
  • [x] Documentation has been updated to reflect this change
  • [x] The new commits follow conventions explained in CONTRIBUTING.md

michaelwolz avatar Sep 21 '22 13:09 michaelwolz