Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter passing issue in Prepare2 for WinRT #374

Open
rigdern opened this issue Dec 19, 2017 · 0 comments
Open

Parameter passing issue in Prepare2 for WinRT #374

rigdern opened this issue Dec 19, 2017 · 0 comments

Comments

@rigdern
Copy link

rigdern commented Dec 19, 2017

  • The marshaling for the sql parameter should be switched from UnmanagedType.LPStr to UnmanagedType.LPWStr (source).
  • Here and here the Prepare2 calls should pass -1 rather than query.Length to match the implementations on the other platforms (that parameter expects a number of bytes and I'm not sure using query.Length returns the correct result).

I believe this fix was already done for all platforms including WinRT in commit 1c2b3c0. However, it looks like there was a conflict with commit 77662f8 and the WinRT fix was partially lost.

Adam Comella
Microsoft Corp.

@rigdern rigdern changed the title Prepare2 for WinRT miscounts non-ascii characters Parameter passing issue in Prepare2 for WinRT Dec 19, 2017
rigdern pushed a commit to rigdern/react-native-sqlite-storage that referenced this issue Jun 24, 2018
The UWP implementation is very similar to the iOS implementation. There are some differences. Most of them are because I didn't have time to port certain features and I haven't needed them. Here's the list of differences:
  - Reading and writing blobs isn't supported.
  - I didn't port the sqlcipher stuff.
  - I didn't port the custom regex SQL function so REGEXP may not be supported.
  - `attach` isn't supported.
  - Some `open` options aren't supported:
    - dblocation. I wasn't sure how to map it to UWP. Also, the Android implementations don't seem to support this.
    - key (related to sqlcipher)
  - Differences with `delete`:
    - The dblocation option isn't supported
    - Closes the DB if it's open. This felt like the right thing to do.

All of the code in the SQLite.Net-PCL directory is from https://github.com/oysteinkrog/SQLite.Net-PCL. It provides a thin wrapper around the C SQLite APIs which enables them to be called from C#. A couple of tweaks were made to the code to fix these bugs:
  - oysteinkrog/SQLite.Net-PCL#374
  - oysteinkrog/SQLite.Net-PCL#375

This implementation requires at least the Windows 10 Anniversary Update. This is because it relies on the version of SQLite that is built into Windows 10 and this was introduced in the Anniversary Update. You can learn more at https://blogs.windows.com/buildingapps/2017/02/06/using-sqlite-databases-uwp-apps/.

With a little work, this module could be updated to support earlier versions of Windows 10. Here's how:
  - When constructing `SQLiteApiWinRT`, pass `false` for the `useWinSqlite` parameter.
  - Install the "SQLite for Universal Windows Platform" extension which will bring a version of SQLite into your app: https://marketplace.visualstudio.com/items?itemName=SQLiteDevelopmentTeam.SQLiteforUniversalWindowsPlatform

TODO:
  - backgroundExecuteSqlBatch
  - executeSql
  - backgroundExecuteSql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant