SQLite: SELECT statement not working after installing WKWebView


#1

I was trying to fix some performance issues in my ionic hybrid app when using AWS cognito which requires installing cordova-plugin-ionic-webview. However, after installing this plugin, my SELECT statement is no longer working - it is now returning no records found. Here is the statement:

dbAccess.SelectGoodsReceiptDetail = function SelectGoodsReceiptDetail(goodsreceipt) {

    var resultData = {};
    // Select Multiple Items 
    return $q(function(resolve, reject) {db.executeSql("SELECT * FROM goodsreceiptdetailview WHERE goodsReceiptKey LIKE ?", [ goodsreceipt.header.goodsReceiptKey] , function(rs) {
        resultData.data = [{}];

        if (rs.rows.length > 0) {
            if (rs.rows.item) {
                for (i=0;i<rs.rows.length; i++) {
                    resultData.data[i] = rs.rows.item(i);
                }
                resultData.exist = true;
            }
        } else {
            // no item found
            resultData.exist = false;
        }
        resolve(resultData);
    }, function(error) {
            resultData.data = [{}];
            resultData.exist = false;
            resultData.failed = true;
            resolve(resultData);
    })
    });
    
}

The variable goodsreceipt.header.goodsReceiptKey in an integer. I have read in the release notes for the cordova sqlite plugin that whole numbers are treated as REAL values when using WKWebView while it is being treated as INT on UIWebView here. Could this be causing the problem? How can I fix this with WKWebView?


#2

Does the table have data in it?

I believe upgrading to WKWebView makes it so that you can’t access the data from the UIWebView version.


#3

I was able to fix this by converting the integer key to string before the SELECT statement. apparently, WKWebView somehow changes the behavior of the SQLITE SELECT.