-
Notifications
You must be signed in to change notification settings - Fork 1.1k
- allow "exec" commmand to pass dictionary-params to webworker (with testcase) #364
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
632effa
- allow "exec" commmand to pass dictionary-params to webworker
7bdff4d
- add documentation
88221d1
Update README.md
kaizhu256 6e5024e
fix exec-command example-code to be consistent with example-result
c6aa888
- fix english-grammar error "an sql" to "a sql"
ac1cac7
- revert grammar-change in c6aa8884baa921e3aedf31f30796db1ddece5c35
f2d5ad2
- resolve conversation - Statement.BindParams
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -651,6 +651,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { | |
| * | ||
| * This is a wrapper against | ||
| * {@link Database.prepare}, | ||
| * {@link Statement.bind}, | ||
| * {@link Statement.step}, | ||
| * {@link Statement.get}, | ||
| * and {@link Statement.free}. | ||
|
|
@@ -660,7 +661,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { | |
| * by a semicolon) | ||
| * | ||
| * ## Example use | ||
| * We have the following table, named *test* : | ||
| * We will create following table, named *test* and query it with a | ||
kaizhu256 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * multi-line statement using params: | ||
| * | ||
| * | id | age | name | | ||
| * |:--:|:---:|:------:| | ||
|
|
@@ -671,18 +673,44 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { | |
| * We query it like that: | ||
| * ```javascript | ||
| * var db = new SQL.Database(); | ||
| * var res = db.exec("SELECT id FROM test; SELECT age,name FROM test;"); | ||
| * var res = db.exec( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| * ( | ||
| * "DROP TABLE IF EXISTS test;\n" | ||
| * + "CREATE TABLE test (id INTEGER, age INTEGER, name TEXT);\n" | ||
| * + "INSERT INTO test VALUES ($id1, :age1, @name1);\n" | ||
| * + "INSERT INTO test VALUES ($id2, :age2, @name2);\n" | ||
| * + "INSERT INTO test VALUES ($id3, :age3, @name3);\n" | ||
| * + "SELECT id FROM test;\n" | ||
| * + "SELECT age,name FROM test;\n" | ||
| * ), | ||
| * { | ||
| * "$id1": 1, | ||
| * ":age1": 1, | ||
| * "@name1": "Ling", | ||
| * "$id2": 2, | ||
| * ":age2": 18, | ||
| * "@name2": "Paul", | ||
| * "$id3": 3, | ||
| * ":age3": 3, | ||
| * "@name3": "Marcus" | ||
| * } | ||
| * ); | ||
lovasoa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * ``` | ||
| * | ||
| * `res` is now : | ||
| * ```javascript | ||
| * [ | ||
| * {columns: ['id'], values:[[1],[2],[3]]}, | ||
| * {columns: ['age','name'], values:[[1,'Ling'],[18,'Paul'],[3,'Markus']]} | ||
| * {"columns":["id"],"values":[[1],[2],[3]]}, | ||
| * {"columns":["age","name"],"values":[[1,"Ling"],[18,"Paul"],[3,"Marcus"]]} | ||
| * ] | ||
| * ``` | ||
| * | ||
| * @param {string} sql a string containing some SQL text to execute | ||
| @param {string} sql a string containing some SQL text to execute | ||
| @param {any[]} [params=[]] When the SQL statement contains placeholders, | ||
kaizhu256 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| you can pass them in here. They will be bound to the statement | ||
| before it is executed. If you use the params argument as an array, | ||
| you **cannot** provide an sql string that contains several queries | ||
| (separated by `;`). This limitation does not apply to params as an object. | ||
| * @return {Database.QueryExecResult[]} The results of each statement | ||
| */ | ||
| Database.prototype["exec"] = function exec(sql, params) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Uh oh!
There was an error while loading. Please reload this page.