I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
The example in SQLite documentation doesn't work. executeSql() doesn't build if you pass {} as the second parameter as stated on the docs, nor it returns if you omit it:
this.sqlite.create({
name: 'data.db',
location: 'default'
})
.then((db: SQLiteObject) => {
db.executeSql('create table danceMoves(name VARCHAR(32))', {}) //<- The second parameter is incorrect!
.then(() => console.log('Executed SQL'))
.catch(e => console.log(e));
})
.catch(e => console.log(e));
Expected behavior:
I think the docs should be updated as you need to use [] instead:
db.executeSql('create table danceMoves(name VARCHAR(32))', []) //<- This second argument works now!
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
cli packages: (C:\Users\Raschid\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : not installed
local packages:
@ionic/app-scripts : 3.1.11
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5
Node : v8.11.1
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : C:\Program Files (x86)\Android\android-sdk\
Misc:
backend : pro
One more thing: if you do not pass an empty array as the second argument, the sql will execute however it will return an exception with the result.
For example, I was doing a simple this.db.executeSQL('SELECT * FROM my_table').then(() => { ... });, which always returned the correct result but as an uncaught error.
Passing an empty array solved the issue, and now the result is returned in the promise
this.db.executeSQL('SELECT * FROM my_table', []).then(() => { ... });
```Ionic:
ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.8
@angular-devkit/core : 0.7.5
@angular-devkit/schematics : 0.7.5
@angular/cli : 6.1.5
@ionic/ng-toolkit : 1.0.8
@ionic/schematics-angular : 1.0.6
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.3, (and 7 other plugins)
System:
ios-deploy : 1.9.2
NodeJS : v9.11.1 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
```
This is still an issue. The docs are updated but the brackets [] are easily overlooked and the executeSql function is still defined as:
The params argument should not be optional or be defined as params: any[] = [].
This bug gave me a headache today... Still present as of March 2020
Still an issue with latest version "@ionic-native/sqlite": "^5.31.1",
Please, at least make the params? a params (without questionmark), so it is no longer "optional".