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

Bugfix: define plugin.error and reject any unknow type parameter in addStatement #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

halaei
Copy link

@halaei halaei commented Oct 5, 2020

Currently passing an object or function as parameter causes an unhandled exception, without calling error callbacks or rejecting promise. The reason is that, on such inputs, an undefined function plugin.error()/plugin.warn() is called.
Reading the code, it was expected to accept anything other than functions, but this PR reject objects as well, because it is more consistent with the current behaviour, and I think such inputs should be regarded as invalid anyway.

PS: my editor automatically removes extra spaces from some irrelevant lines. Sorry about that.

@halaei
Copy link
Author

halaei commented Oct 5, 2020

See #402

@@ -501,10 +507,6 @@ SQLitePluginTransaction.prototype.addStatement = function(sql, values, success,
} else if (t === 'boolean') {
//Convert true -> 1 / false -> 0
params.push(~~v);
}
Copy link
Owner

@andpor andpor Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halaei why did you remove this conditional block? wouldn't it suffice to implement warn function instead...it appears that warn function is the one that is missing...

Also, the missing plugin method was warn rather than error ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andpor Maybe I was thinking of backward compatibility or to keep the behavior as strict as possible to minimize possible errors. I don't see any value to silently save {x: {}} as "[object Object]". It just makes things more complicated in handling errors. I don't know what will happen when we save symbols or any other types.
Maybe both error and warn was missing, but warn wasn't used anywhere except the code that I removed.
I did this PR a while ago and don't remember all the details. I guess you have already fixed the issue in some other way.

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

Successfully merging this pull request may close these issues.

2 participants