forked from sidorares/node-mysql2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"author": "Andrey Sidorov <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"bn.js": "^0.11.7", | ||
"fastqueue": "~0.1.0" | ||
}, | ||
"devDependencies": { | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var common = require('../../common'); | ||
var connection = common.createConnection({ bigNumberString: true }); | ||
var assert = require('assert'); | ||
var bn = require('bn.js'); | ||
|
||
var table = 'insert_test'; | ||
connection.query([ | ||
'CREATE TEMPORARY TABLE `bigs` (', | ||
'`id` bigint NOT NULL AUTO_INCREMENT,', | ||
'`title` varchar(255),', | ||
'PRIMARY KEY (`id`)', | ||
') ENGINE=InnoDB DEFAULT CHARSET=utf8' | ||
].join('\n')); | ||
|
||
var result, result2; | ||
connection.query("INSERT INTO bigs SET title='test', id=123"); | ||
connection.query("INSERT INTO bigs SET title='test1'", function(err, result) { | ||
if (err) throw err; | ||
assert.strictEqual(result.insertId, 124); | ||
// > 24 bits | ||
connection.query("INSERT INTO bigs SET title='test', id=123456789"); | ||
connection.query("INSERT INTO bigs SET title='test2'", function(err, result) { | ||
assert.strictEqual(result.insertId, 123456790); | ||
// big int | ||
connection.query("INSERT INTO bigs SET title='test', id=9007199254740992"); | ||
connection.query("INSERT INTO bigs SET title='test3'", function(err, result) { | ||
assert.strictEqual((new bn("9007199254740993")).cmp(result.insertId), 0); | ||
connection.query("INSERT INTO bigs SET title='test', id=90071992547409924"); | ||
connection.config.bigNumberStrings = true; | ||
connection.query("INSERT INTO bigs SET title='test4'", function(err, result) { | ||
assert.strictEqual(result.insertId, "90071992547409925"); | ||
connection.end(); | ||
}); | ||
}); | ||
}); | ||
}); |