Expo driver#2240
Conversation
|
Thank you very much! Looks good I think, but I need @daniel-lang confirmation on this PR since he is expert in sqlite databases and mobiles in TypeORM. Also, once PR will be merged we'll need to move your expo-example repository into typeorm organization on github. Also, you'll have to maintain this driver all your life (😆 ) because we bring a new functionality and we can't one day remove it if maintainer has gone, I hope you understand the responsibility. |
|
Thanks for looking! I will be happy to tranfer the example repo and maintain the Expo driver. I have also been keeping an eye on changes to the SQLite API within Expo so I can make changes to the driver if necessary. |
| /** | ||
| * Starts transaction. | ||
| */ | ||
| async startTransaction(): Promise<void> { |
There was a problem hiding this comment.
Could you write a comment documenting why you had to override the transaction methods?
There was a problem hiding this comment.
Yes, that's a good idea. I'll update my PR today.
|
Pretty cool, but technically isn't the Expo SQLite API a wrapper of |
|
yeah TBH I definitely would like to avoid adding specific sqlite3 drivers into typeorm. @cuibonobo what are exact expo specifics that required you to write a separate driver for it? |
|
@stevefan1999 The API that is available in In fact, when you attempt to use the |
|
@daniel-lang I've updated the comments for those transaction lifecycle methods to give a little more insight into what is happening. Thanks for your suggestion! I rebased my branch against current master to make sure everything still works ok. |
|
The problem with all the different sqlite drivers that we have in TypeORM is that the way they are loaded and called is always a little different. Therefore if we want to support the different mobile platforms we will have to have a lot of sqlite drivers that are quite similar. |
|
@cuibonobo I'll merge it, however in the future we might change the way we do drivers right now. Please track for #2479. Thank you very much for your contribution! Can you please "send" your example repository to "typeorm" organization? |
|
@pleerock Of course! At the moment the example repository uses the following line in "typeorm": "github:cuibonobo/typeorm-package"Once the latest TypeORM release includes the Expo driver, this line should be changed. For the moment I will leave it as-is in the example so that it works. Will send the repo now. |
|
@pleerock Err, I spoke too soon. I attempted to transfer the repository to the "typeorm" organization but received the following error: |
|
I've added you as a collaborator on the example repo. Hopefully after accepting you can transfer it to the typeorm org. |
|
its not owner access, I can't do it. Let me just add you to typeorm organization and you can move it on your own. |
Add a driver to support the Expo platform. In particular it is using the Expo SQLite API that ships with Expo.
A few things to note about this pull request:
react-native-sqlite-storageas a dependency. The issue is that the Expo packager still attempts to include this dependency (even though it doesn't need it) because of thethis.sqlite = require("react-native-sqlite-storage");line insrc/driver/react-native/ReactNativeDriver.ts. If someone knows how to make the Expo packager ignore this line, I'm all ears! Still, needing to installreact-native-sqlite-storageisn't such a big deal. No linking or ejecting of the Expo app is required.BEGIN TRANSACTIONquery throws aTransaction already startederror. As a result, I needed to override thestartTransaction,commitTransaction, androllbackTransactionmethods on theAbstractSqliteQueryRunnerclass to account for the weird behavior. Besides this, the Expo driver is almost identical to how React Native is being handled.I have a working Expo example at https://github.com/cuibonobo/expo-example. To try it, download the Expo app from the App Store or Google Play Store, then
cdinto theexpo-exampledirectory and run:If your phone is on the same network as your development machine, scanning the generated QR code will automatically open the Expo app and run the example.
Fixes #2183.