andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.77k stars 519 forks source link

Question: Math functions #80

Open vincenzoiacovone opened 8 years ago

vincenzoiacovone commented 8 years ago

Hi, is it possible to integrate math functions like sqrt, sum, pow etc.. ? There is an extension that include this functions: https://www.sqlite.org/contrib/download/extension-functions.c?get=25

Thanks for the nice work

remyrylan commented 8 years ago

This would be a huge improvement to include. I use SQLite as a client side cache of a remote PostgreSQL database, so there are several queries that I can't run (even with workarounds/rewrites) because of the lack of math functions.

I would love to contribute to this project and help out with this, iOS seems straightforward because the SQLite source is right there, but I'm lost when it comes to Android since I don't see the SQLite source files there. If someone could point me in the right direction, I'd happily send a pull request.

andpor commented 8 years ago

Yes I agree this would be nice to have. I am not entirely sure how to get started on this either. The objective is to keep the functionality on par for both platforms.

remyrylan commented 8 years ago

@andpor Is the difficulty that only the built-in SQLite is used on Android? Is there any way to use a custom version?

andpor commented 8 years ago

Both platforms have built in SQLite...

remyrylan commented 8 years ago

Ha, that's what I get for not looking through the source files and just assuming. Would using a custom SQLite build be beyond the scope of this project?

I would think using a custom build would be the only way to really ensure feature parity since there's no chance that iOS and Android would ever both stay on the latest SQLite releases and agree on the same extensions.

brodycj commented 8 years ago

@andpor I would like to propose a small correction: I think there is also src/android-native that uses the custom build of SQLite that I did for Android. It is entirely possible to rebuild that part from https://github.com/liteglue/Android-sqlite-connector and https://github.com/liteglue/Android-sqlite-native-driver. For iOS I think it should be relatively straightforward to include a more recent sqlite amalgamation which is what I do in Cordova-sqlite-storage. Note that I include these sqlite libraries as external dependencies so they don't pollute the project history.

In theory it should be possible for people to simply include these math functions by rebuilding the Android-sqlite-native-driver libs and building the iOS version with a custom version of sqlite. Unfortunately this process can be a major challenge for many application developers. Guidance for such custom builds would be great, also for the Cordova-sqlite-storage project that I maintain.

dryganets commented 7 years ago

@andpor, I've made a plugin model for our storage implementation for react-native in order to quickly switch between different implementations on android platform.

I could contribute that part back. this would allow hooking of any implementation of SQLite without changing the main code base.

But the change would lead to deletion of android-native project. I didn't implement the support for that implementation as we don't need it.

On the bright side - it's going to remove most of the code duplication you have for android now :)

It should be fairly easy to implement a provider for android-native implementation.

It might be a good idea to make a separate project for that glue layer as it would be easier for the community to use it as a gradle/maven dependency.

lazars14 commented 5 years ago

@andpor Is it possible to use these math functions now?