Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJS-131] Duplication error now indicating option checkDuplicate.
 Improvement of `checkDuplicate` option documentation
  • Loading branch information
rusher committed Apr 3, 2020
1 parent 366ffd6 commit 9b4b56a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions documentation/connection-options.md
Expand Up @@ -353,8 +353,8 @@ mariadb.createConnection({
| **initSql** | When a connection is established, permit to execute commands before using connection|*string|array* |
| **bulk** | disabled bulk command in batch|*boolean* |
| **permitConnectionWhenExpired** | Permit a user with expired password to connect. Only possible operation in this case will be to change password ('SET PASSWORD=PASSWORD('XXX')')|*boolean* |false|
| **forceVersionCheck** | Force server version check by explicitly using SELECT VERSION(), not relying on server initial packet. |*boolean* |false|
| **checkDuplicate** | indicate to throw an exception if result-set will not contain some data due to having duplicate identifier|*boolean* | true |
| **forceVersionCheck** | Force server version check by explicitly using SELECT VERSION(), not relying on server initial packet.<br/><i><small>Since version 2.2.0</small></i> |*boolean* |false|
| **checkDuplicate** | Indicate to throw an exception if result-set will not contain some data due to having duplicate identifier. <br/>JSON cannot have multiple identical key, so query like `SELECT 1 as i, 2 as i` cannot result in { i:1, i:2 }, 'i:1' would be skipped. <br/>When `checkDuplicate` is enable (default) driver will throw an error if some data are skipped. Duplication error can be avoided by multiple ways, like using unique aliases or using options [`rowsAsArray`](https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/master/documentation/promise-api.md#rowsasarray) / [`nestTables`](https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/master/documentation/promise-api.md#nestTables) for example <br/><i><small>Since version 2.3.0</small></i>|*boolean* | true |



Expand Down
8 changes: 6 additions & 2 deletions lib/cmd/resultset.js
Expand Up @@ -283,7 +283,10 @@ class ResultSet extends Command {
[]
);
this.throwUnexpectedError(
'Error in results, duplicate field name `' + dupes[0] + '`',
'Error in results, duplicate field name `' +
dupes[0] +
'`.\n' +
'(see option `checkDuplicate`)',
false,
null,
'42000',
Expand All @@ -307,7 +310,8 @@ class ResultSet extends Command {
this.tableHeader[i][0] +
'`.`' +
this.tableHeader[i][1] +
'`',
'`\n' +
'(see option `checkDuplicate`)',
false,
null,
'42000',
Expand Down

0 comments on commit 9b4b56a

Please sign in to comment.