WebSqlSync icon indicating copy to clipboard operation
WebSqlSync copied to clipboard

<null> values from server will be updated to string "null" into the websql db

Open SuperMario77 opened this issue 12 years ago • 3 comments

Hello,

I just noticed that all my values from the server are now a string "null" after I send updates from server to the client.

On INSERT it works fine, because you use placeholder '?' in the INSERT statement.

But in the UPDATE statement you write the following in line 473 (_buildUpdateSQL):

for (var i = 0; i < nb; i++) {
    sql += '"' + members[i] + '" = "' + values[i] + '"';
    if (i < nb - 1) {
        sql += ', ';
    }
}

Here the values are enclosed by quotes and now it is a string "null". :-(

Could you please use also placeholders in UPDATE?

Best regards, Mario

SuperMario77 avatar Sep 17 '13 16:09 SuperMario77

Could you propose a pull request? Unfortunately, I am very busy...

orbitaloop avatar Sep 25 '13 23:09 orbitaloop

Hi Samuel, It's just to inform you that my 2 way sync is working perfectly with MySQL. I use 2 indexes (one for the client DB and one for the server DB). I modifyed webSqlSync.js to handle inserted records directly into MySQL that have a null client id value. When I insert a record in webSQL (with the client), I use -1 in the "server" ID to inform the server adapter that's a record newly created with the app. -1 mean to do an INSERT INTO MySQL. You'll find my code on my GitHub webSqlApp. I think, it will answer a lot of questions from the community. Ciao! Alain from Montréal.

abeauseigle avatar Oct 24 '13 02:10 abeauseigle

Great work Alain ! I will add a link to your project in the doc. Very helpful indeed.

Thanks

@SuperMario77 Could you propose a pull request for this modifications? Or just send me here the code you have modified. Thanks

orbitaloop avatar Oct 29 '13 15:10 orbitaloop