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

ionic-native@2.2.4 - SQLite transaction success part is undefined. #732

Closed
NeoLSN opened this issue Oct 19, 2016 · 4 comments
Closed

ionic-native@2.2.4 - SQLite transaction success part is undefined. #732

NeoLSN opened this issue Oct 19, 2016 · 4 comments
Labels
Milestone

Comments

@NeoLSN
Copy link

NeoLSN commented Oct 19, 2016

SQLite transaction will not resolve or reject after tx.executeSql.
It just stock in there.

let queries = ['...', '...'];
this._db.transaction((tx) => {
    queries.forEach((query) => {
        tx.executeSql(query, []);
    });
})
    .then(() => {
        console.log('Transaction done');
    }, (error) => {
        console.log('Transaction error: ', error);
    });

No Transaction done' or 'Transaction error: ' will be logged.

2.2.3 works fine just needs to change resolve/reject function order.

@ihadeed
Copy link
Collaborator

ihadeed commented Oct 19, 2016

Your usage is incorrect.

this._db.transaction().then(tx => tx.executeSql(...)).then(result => ...);

On Oct 19, 2016 12:14 PM, "NeoLSN" notifications@github.com wrote:

SQLite transaction will not resolve or reject after tx.executeSql.
It just stock in there.

let queries = ['...', '...'];
this._db.transaction((tx) => {
queries.forEach((query) => {
tx.executeSql(query, []);
});
})
.then(() => {
console.log('Transaction done');
}, (error) => {
console.log('Transaction error: ', error);
});

No Transaction done' or 'Transaction error: ' will be logged.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#732, or mute the thread
https://github.com/notifications/unsubscribe-auth/ANJ8dNLOUKbSI1u6qtZsgOv_9t-wAPepks5q1kHdgaJpZM4KbK1c
.

@NeoLSN
Copy link
Author

NeoLSN commented Oct 20, 2016

@ihadeed
I tried your way, but it is still not working.
There is no resolve/reject part will be called.
So I couldn't get any tx.

@NeoLSN NeoLSN changed the title ionic-native@2.2.4 - SQLite transaction will not resolve or reject after tx.executeSql ionic-native@2.2.4 - SQLite transaction will not call any resolve or reject Oct 20, 2016
@NeoLSN
Copy link
Author

NeoLSN commented Oct 20, 2016

ionic-native@2.2.4, the tx

tx =>  
SQLitePluginTransaction
db: SQLitePlugin
error: function (e){s(t,n,e)}
executes: Array[0]
finalized: true
fn: function (e){t.forEach(function(t){e.executeSql(t,[],function(t,e){console.log("tx => ",t)},function(t){console.log("error => ",t)})})}
readOnly: false
success: undefined
txlock: true
__proto__: SQLitePluginTransaction

ionic-native@2.2.3, the tx

tx =>
SQLitePluginTransaction
db: SQLitePlugin
error: function (e){s(t,n,e)}
executes: Array[0]
finalized: true
fn: function (e){t.forEach(function(t){e.executeSql(t,[],function(t,e){console.log("tx => ",t)},function(t){console.log("error => ",t)})})}
readOnly: false
success: function (e){s(t,n,e)}
txlock: true
__proto__: SQLitePluginTransaction

The different thing is the success part on ionic-native@2.2.4 is 'undefined'.
Could you make some time to check it?

@NeoLSN NeoLSN changed the title ionic-native@2.2.4 - SQLite transaction will not call any resolve or reject ionic-native@2.2.4 - SQLite transaction success part is undefined. Oct 20, 2016
@ihadeed
Copy link
Collaborator

ihadeed commented Oct 22, 2016

Sorry, never mind my previous reply, got things mixed up. Your usage is correct.

Just had a look at what's going on. The issue is happening here https://github.com/driftyco/ionic-native/blob/master/src/plugins/plugin.ts#L70-L81

// Line 69
args = [fn];

// Line 70 
// successIndex ( 2 ) is greater than args.length (1)
// Line 71
args = [fn, undefined, resolve];

// Line 77
// errorIndex (1) is less than args.length (3)
// Line 80
args = [fn, reject, undefined, resolve];

// Which leads to 
db.transaction(fn, reject, undefined, resolve);

I'll fix this soon.

@ihadeed ihadeed added the bug label Oct 22, 2016
@ihadeed ihadeed modified the milestones: v2.2.4, v2.2.5 Oct 22, 2016
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