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

Cordova sqlite plugin openDB changes #101

Open
lwbdev opened this issue Apr 17, 2016 · 5 comments
Open

Cordova sqlite plugin openDB changes #101

lwbdev opened this issue Apr 17, 2016 · 5 comments
Labels

Comments

@lwbdev
Copy link

lwbdev commented Apr 17, 2016

Hi, it looks like the author of the cordova sqlite plugin (@brodybits) changed the arguments/parameters for the opendatabase call for the sqlite plugin. This means using sqlite as a mechanism no longer works with the latest version of the plugin since ydn-db uses the old openDatabase calls.

See https://github.com/litehelpers/Cordova-sqlite-storage.

@yathit
Copy link
Owner

yathit commented Apr 17, 2016

Could you use this plugin?

@yathit
Copy link
Owner

yathit commented Apr 17, 2016

This is a breaking change request. My first reaction is NO. There are other plugin as well. Breaking from WebSQL API is not going to happen. In this case, simply use an adaptor function to use the two library togather.

@yathit yathit added the wontfix label Apr 17, 2016
@lwbdev
Copy link
Author

lwbdev commented Apr 17, 2016

Hi,

Thanks for your quick response. Unfortunately, I cannot use the the enterprise version you linked to as it does not support Windows 10/UAP. I'm actually using this version here https://github.com/litehelpers/cordova-sqlite-ext which does support Windows 10/UAP and has the same issue with the openDatabase call change.

Aside from the openDatabase call, the plugin still adheres to the WebSQL API. I suppose I can create a wrapper function that overwrite the window.sqlitePlugin.openDatabase function, but I thought it would be easier if ydn-db could also use the modified openDatabase call just for the sqlite mechanism with a way to pass in the open arguments to the sqlite plugin (i.e. Database location). I also tried to overwrite window.openDatabase to use that to call window.sqlite.openDatabase (and using "websql" instead of "sqlite" as the mechanism), but was ultimately unsuccessful because the sqlite plugin does not implement version change API for WebSQL.

@lwbdev
Copy link
Author

lwbdev commented Apr 18, 2016

As you suggested I was able to write an adaptor function. For anyone else in my shoes, here's the code:

if (window.sqlitePlugin) {
    window.sqlitePlugin.__openDatabase = window.sqlitePlugin.openDatabase;
    window.sqlitePlugin.openDatabase = function(arg) {
        if (typeof(arg) == "object") {
            return window.sqlitePlugin.__openDatabase(arg);
        } else {
            return window.sqlitePlugin.__openDatabase({
                name: arg,
                iosDatabaseLocation: "Documents"
            });
        }
    }
}

Thanks again for all the hard work with ydn-db and your helpful suggestions!

@yathit
Copy link
Owner

yathit commented Apr 22, 2016

@lwbdev 👍 thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants