Skip to content

Commit

Permalink
Convert array parameters to string to match Web SQL (ref: #144)
Browse files Browse the repository at this point in the history
Small fix to handling of Blob to prepare for SQL blob improvements (ref: PR #170)
  • Loading branch information
Chris Brody committed Mar 6, 2015
1 parent 2efcf95 commit af04b67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 12 additions & 1 deletion SQLitePlugin.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,24 @@
qid = @executes.length
params = []
if !!values && values.constructor == Array
for v in values
t = typeof v
params.push (
if v == null || v == undefined || t == 'number' || t == 'string' then v
else if v instanceof Blob then v.valueOf()
else v.toString()
)
@executes.push
success: success
error: error
qid: qid
sql: sql
params: values || []
#params: values || []
params: params
return
Expand Down
4 changes: 1 addition & 3 deletions test-www/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@
});
});

// XXX reproduce BUG #144:
test(suiteName + "executeSql parameter as array", function() {
stop();
var db = openDatabase("array-parameter.db", "1.0", "Demo", DEFAULT_SIZE);
Expand All @@ -752,8 +751,7 @@
start();
var row = res.rows.item(0);
strictEqual(row.data1, 'abc', "data1: string");
// XXX BUG #144 - only works with Web SQL:
if (isWebSql) strictEqual(row.data2, '1,2,3', "data2: array should have been inserted as text (string)");
strictEqual(row.data2, '1,2,3', "data2: array should have been inserted as text (string)");
});
});
});
Expand Down
12 changes: 10 additions & 2 deletions www/SQLitePlugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af04b67

Please sign in to comment.