diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ac8f968
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.pyc
+
+# Logs and databases #
+######################
+*.log
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
diff --git a/benchmark/insert.js b/benchmark/insert.js
index 196576e..6a97e63 100644
--- a/benchmark/insert.js
+++ b/benchmark/insert.js
@@ -11,7 +11,7 @@ var startUsage = process.memoryUsage();
function dumpMem(n)
{
var memusage = process.memoryUsage();
- console.log(n + ' rss: ' + (memusage.rss - startUsage.rss) + ' vsize:' + (memusage.vsize - startUsage.vsize) +
+ console.log(n + ' rss: ' + (memusage.rss - startUsage.rss) + ' vsize:' + (memusage.vsize - startUsage.vsize) +
' heapTotal:' + (memusage.heapTotal - startUsage.heapTotal) + ' heapUsed:' + (memusage.heapUsed - startUsage.heapUsed)
);
}
@@ -50,13 +50,13 @@ client.query(config.create_table)
{
var duration = (+new Date - startTick) / 1000,
queriesPerSecond = 100 / duration;
- startTick = +new Date;
+ startTick = +new Date;
console.log('%d queries / second', queriesPerSecond.toFixed(2));
}
});
client.debug(queries + 'finished');
-
+
}
queryOne();
});
diff --git a/examples/myhttp.js b/examples/myhttp.js
index f60b216..7d50a69 100755
--- a/examples/myhttp.js
+++ b/examples/myhttp.js
@@ -6,7 +6,7 @@ var mysql = require('../lib/mysql-native');
function test_datasource()
{
- var db = mysql.createTCPClient('127.0.0.1');
+ var db = mysql.createTCPClient('127.0.0.1');
db.auto_prepare = true;
var auth = db.auth('', 'root');
db.set('row_as_hash', false);
@@ -21,7 +21,7 @@ function dump_row(row, res, formatter)
res.write('
');
for (var i=0; i < row.length; ++i)
{
- res.write('| ' + formatter(row[i]) + ' | ');
+ res.write('' + formatter(row[i]) + ' | ');
}
res.write('
\n');
}
@@ -31,9 +31,9 @@ function dump_query(cmd, res, formatter)
res.write("\n");
cmd
- .on('field', function(f) { res.write('| ' + f.name + ' | '); })
- .on('fields_eof', function() { res.write('
\n'); })
- .on('row', function(r) { dump_row(r, res, formatter) })
+ .on('field', function(f) { res.write('' + f.name + ' | '); })
+ .on('fields_eof', function() { res.write('\n'); })
+ .on('row', function(r) { dump_row(r, res, formatter) })
.on('end', function() { res.end('
'); })
}
@@ -51,7 +51,7 @@ http.createServer(function (req, res) {
{
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('');
- dump_query(conn.query('show databases'), res,
+ dump_query(conn.query('show databases'), res,
function(s) { return '' + s + ''; }
);
} else if (query.db)
@@ -64,9 +64,9 @@ http.createServer(function (req, res) {
{
res.write("\n");
conn.query('show tables')
- .on('field', function(f) { res.write("| " + f.name + " | "); })
- .on('fields_eof', function() { res.write("
\n"); })
- .on('row', function(r) { res.write('| ' + r[0] + ' |
\n'); })
+ .on('field', function(f) { res.write("| " + f.name + " | "); })
+ .on('fields_eof', function() { res.write("
\n"); })
+ .on('row', function(r) { res.write('| ' + r[0] + ' |
\n'); })
.on('end', function() { res.end("
"); })
.on('error', function(e) { res.end(e.message); });
} else {
@@ -74,9 +74,9 @@ http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write("\n");
conn.query(q)
- .on('field', function(f) { res.write("| " + f.name + " | "); })
- .on('fields_eof', function() { res.write("
\n"); })
- .on('row', function(r) { dump_row(r, res); })
+ .on('field', function(f) { res.write("" + f.name + " | "); })
+ .on('fields_eof', function() { res.write("\n"); })
+ .on('row', function(r) { dump_row(r, res); })
.on('end', function() { res.end("
"); })
.on('error', function(e) { res.end(e.message); });
}
@@ -85,5 +85,5 @@ http.createServer(function (req, res) {
res.end('please select DB
');
}
console.log(req);
-
+
}).listen(8080, "127.0.0.1");
\ No newline at end of file
diff --git a/examples/websql.js b/examples/websql.js
index 305c145..e10ebf0 100644
--- a/examples/websql.js
+++ b/examples/websql.js
@@ -1,17 +1,17 @@
// websql example adapted from http://html5demos.com/database-rollback
-// original code (c)
+// original code (c)
var webdb = require('../lib/mysql-native/wrappers/websql');
var db = webdb.openDatabase('test');
db.transaction(function (tx) {
- tx.executeSql("CREATE TABLE `foo` (`id` int(20) DEFAULT NULL, `text` blob ) ENGINE=InnoDB");
+ tx.executeSql("CREATE TABLE `foo` (`id` int(20) DEFAULT NULL, `text` blob ) ENGINE=InnoDB");
tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")');
});
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM foo', [], function (tx, results) {
- console.log('found rows (should be 1): ' + sys.inspect(results));
+ console.log('found rows (should be 1): ' + sys.inspect(results));
}, function (tx, err) {
console.log('select* failed: ' + err.message);
});
@@ -20,7 +20,7 @@ db.transaction(function (tx) {
db.transaction(function (tx) {
tx.executeSql('DROP TABLE foo');
// known to fail - so should rollback the DROP statement
- tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")', [],
+ tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")', [],
function(tx, rs)
{
console.log("insrted " + sys.inspect(rs));
@@ -31,7 +31,7 @@ db.transaction(function (tx) {
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM foo', [], function (tx, results) {
- console.log('found rows (should be 1): ' + sys.inspect(results));
+ console.log('found rows (should be 1): ' + sys.inspect(results));
}, function (tx, err) {
console.log('select* failed: ' + err.message);
});
diff --git a/lib/mysql-native/charset.js b/lib/mysql-native/charset.js
index 40ec488..3b089b6 100644
--- a/lib/mysql-native/charset.js
+++ b/lib/mysql-native/charset.js
@@ -37,7 +37,7 @@ exports.Charset.prototype.convertFromBytes = function(bytes) {
var convertUTF8ToBytes = function(str) {
if(typeof(str)=='undefined') return undefined;
if(typeof(str)=='undefined') return undefined;
-
+
var surrogate_1st = 0;
var unicode_codes = [];
for (var i = 0; i < str.length; ++i) {
@@ -58,7 +58,7 @@ var convertUTF8ToBytes = function(str) {
unicode_codes.push(utf16_code);
}
}
-
+
var utf8_bytes = "";
var i, unicode_code;
for(i=0; i 0) {
bitmap.push(val);
}
diff --git a/lib/mysql-native/commands/prepare.js b/lib/mysql-native/commands/prepare.js
index 5b4a7fc..10deaab 100644
--- a/lib/mysql-native/commands/prepare.js
+++ b/lib/mysql-native/commands/prepare.js
@@ -26,7 +26,7 @@ module.exports = function(sql)
this.ps.num_params = r.num(2);
this.ps.sql = sql
r.bytes(1); // filler, should be 0
-
+
if (!this.connection.pscache)
this.connection.pscache = {};
this.connection.pscache[sql] = this.ps;
@@ -60,7 +60,7 @@ module.exports = function(sql)
var f = r.field();
this.ps.fields.push(f);
this.emit('field', f);
- }
+ }
}
);
diff --git a/lib/mysql-native/constants.js b/lib/mysql-native/constants.js
index 36cab74..507331f 100644
--- a/lib/mysql-native/constants.js
+++ b/lib/mysql-native/constants.js
@@ -1,4 +1,4 @@
-var flags = exports.flags =
+var flags = exports.flags =
{
CLIENT_LONG_PASSWORD: 1 ,/* new more secure passwords */
CLIENT_FOUND_ROWS: 2 ,/* Found instead of affected rows */
@@ -20,7 +20,7 @@ var flags = exports.flags =
CLIENT_MULTI_RESULTS: 131072 /* Enable/disable multi-results */
}
-exports.field_flags =
+exports.field_flags =
{
NOT_NULL: 1, /* Field can't be NULL */
PRI_KEY: 2, /* Field is part of a primary key */
@@ -29,26 +29,26 @@ exports.field_flags =
BLOB: 16, /* Field is a blob */
UNSIGNED: 32, /* Field is unsigned */
ZEROFILL: 64, /* Field is zerofill */
- BINARY: 128,
+ BINARY: 128,
}
-exports.flags.CLIENT_BASIC_FLAGS = flags.CLIENT_LONG_PASSWORD |
- flags.CLIENT_FOUND_ROWS |
- flags.CLIENT_LONG_FLAG |
- flags.CLIENT_CONNECT_WITH_DB |
- flags.CLIENT_ODBC |
- flags.CLIENT_LOCAL_FILES |
- flags.CLIENT_IGNORE_SPACE |
- flags.CLIENT_PROTOCOL_41 |
+exports.flags.CLIENT_BASIC_FLAGS = flags.CLIENT_LONG_PASSWORD |
+ flags.CLIENT_FOUND_ROWS |
+ flags.CLIENT_LONG_FLAG |
+ flags.CLIENT_CONNECT_WITH_DB |
+ flags.CLIENT_ODBC |
+ flags.CLIENT_LOCAL_FILES |
+ flags.CLIENT_IGNORE_SPACE |
+ flags.CLIENT_PROTOCOL_41 |
flags.CLIENT_INTERACTIVE |
- flags.CLIENT_IGNORE_SIGPIPE |
- flags.CLIENT_TRANSACTIONS |
- flags.CLIENT_RESERVED |
- flags.CLIENT_SECURE_CONNECTION |
- flags.CLIENT_MULTI_STATEMENTS |
- flags.CLIENT_MULTI_RESULTS;
+ flags.CLIENT_IGNORE_SIGPIPE |
+ flags.CLIENT_TRANSACTIONS |
+ flags.CLIENT_RESERVED |
+ flags.CLIENT_SECURE_CONNECTION |
+ flags.CLIENT_MULTI_STATEMENTS |
+ flags.CLIENT_MULTI_RESULTS;
-exports.types =
+exports.types =
{
MYSQL_TYPE_DECIMAL: 0,
MYSQL_TYPE_TINY: 1,
diff --git a/lib/mysql-native/containers/queue.js b/lib/mysql-native/containers/queue.js
index e21d518..e8d90db 100644
--- a/lib/mysql-native/containers/queue.js
+++ b/lib/mysql-native/containers/queue.js
@@ -15,8 +15,8 @@ deque.prototype.push = function(data)
if (!this.begin) // insert into empty list
{
this.begin = this.end = { 'data': data };
- this.begin.next = this.begin;
- this.begin.prev = this.begin;
+ this.begin.next = this.begin;
+ this.begin.prev = this.begin;
} else {
var end = this.end;
this.end = { 'data': data };
diff --git a/lib/mysql-native/serializers/reader.js b/lib/mysql-native/serializers/reader.js
index f2d8fdc..57f43d6 100644
--- a/lib/mysql-native/serializers/reader.js
+++ b/lib/mysql-native/serializers/reader.js
@@ -13,14 +13,14 @@ reader.prototype.dump = function()
for (var i=this.pos; i < this.data.length; ++i)
{
sys.puts(this.data.charCodeAt(i));
- }
+ }
}
// libmysql sets all fields to zero when binary packet has zero length
function zeroTime()
{
// todo: check how zero date is serialized to output in mysql
- return new Date();
+ return new Date();
}
reader.prototype.unpackBinaryTime = function()
@@ -64,7 +64,7 @@ reader.prototype.unpackBinaryDateTime = function()
var millisec = (length > 8) ? this.num(4) : 0;
var dt = new Date();
dt.setYear(y);
- dt.setMonth(m - 1);
+ dt.setMonth(m - 1);
dt.setDate(d);
dt.setHours(hour);
dt.setMinutes(min);
@@ -84,7 +84,7 @@ reader.prototype.unpackBinaryDate = function()
var d = this.num(1);
var dt = new Date();
dt.setYear(y);
- dt.setMonth(m - 1);
+ dt.setMonth(m - 1);
dt.setDate(d);
return dt;
@@ -94,17 +94,17 @@ function parseIEEE754Double(data)
{
var fraction = 0.0;
fraction += data.charCodeAt(2) / ( 16 * 256 * 256 * 256 * 256 * 256 * 256);
- fraction += data.charCodeAt(3) / ( 16 * 256 * 256 * 256 * 256 * 256 );
+ fraction += data.charCodeAt(3) / ( 16 * 256 * 256 * 256 * 256 * 256 );
fraction += data.charCodeAt(4) / ( 16 * 256 * 256 * 256 * 256 );
fraction += data.charCodeAt(5) / ( 16 * 256 * 256 * 256);
fraction += data.charCodeAt(6) / ( 16 * 256 * 256 );
fraction += data.charCodeAt(7) / ( 16 * 256 );
fraction += (data.charCodeAt(8) & 0x0f) / 16.0;
-
+
var signbit = data.charCodeAt(9) & 128;
var exponent = ((data.charCodeAt(8) & 0xf0) >> 4) + ((data.charCodeAt(9) & 127) << 4);
-
+
var factor = Math.pow(2,exponent-1023);
var mantissa = 1.0 + fraction;
var sign = signbit > 0 ? -1 : 1;
@@ -115,7 +115,7 @@ function parseIEEE754Double(data)
reader.prototype.unpackBinary = function(type, unsigned)
{
// http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
-
+
// debug dump
//return "_not_implemented_ " + constants.type_names[type] + " " + sys.inspect(this.data);
@@ -133,7 +133,7 @@ reader.prototype.unpackBinary = function(type, unsigned)
break;
case constants.types.MYSQL_TYPE_SHORT:
result = this.num(2);
- break;
+ break;
case constants.types.MYSQL_TYPE_LONG:
result = this.num(4);
break;
@@ -173,7 +173,7 @@ reader.prototype.unpackBinary = function(type, unsigned)
return result;
}
-// read n-bytes number
+// read n-bytes number
// TODO: add unsigned flag and code to read signed/unsigned integers
reader.prototype.num = function(numbytes)
{
@@ -220,7 +220,7 @@ function binary(n)
nbits++;
}
for(; nbits <= 8; ++nbits)
- res = "0" + res;
+ res = "0" + res;
return res;
}
@@ -287,18 +287,18 @@ reader.prototype.readOKpacket = function()
{
res.errno = this.data.charCodeAt(this.pos) + (this.data.charCodeAt(this.pos+1)<<8);
// at least for 1040 +8 offset is incorrect TODO: check where +8 comes from
- if (res.errno != 1040)
+ if (res.errno != 1040)
this.pos += 8;
else
this.pos += 2;
//this.pos++; // skip sqlstate marker, "#"
//res.sqlstate = this.bytes(5); FIXME!!!
- } else if (res.field_count == 0xfe && this.data.length < 9) {
+ } else if (res.field_count == 0xfe && this.data.length < 9) {
// eof packet
res.warning_count = this.num(2);
res.server_status = this.num(2);
- } else {
+ } else {
res.affected_rows = this.lcnum();
res.insert_id = this.lcnum();
res.server_status = this.num(2);
@@ -319,7 +319,7 @@ reader.prototype.lcnum = function()
else if (b1 == 253)
return this.num(3);
else if (b1 == 254)
- return this.num(8);
+ return this.num(8);
}
reader.prototype.readPacketHeader = function()
diff --git a/lib/mysql-native/serializers/writer.js b/lib/mysql-native/serializers/writer.js
index 5b3c639..3da5daf 100644
--- a/lib/mysql-native/serializers/writer.js
+++ b/lib/mysql-native/serializers/writer.js
@@ -1,6 +1,6 @@
var sys = require('sys')
, constants = require('../constants');
-
+
function writer()
{
this.data = "";
@@ -40,7 +40,7 @@ writer.prototype.lcnum = function(n)
this.data += String.fromCharCode( n & 0xff );
this.data += String.fromCharCode( (n >> 8) & 0xff );
this.data += String.fromCharCode( (n >> 16) & 0xff );
- }
+ }
/*
TODO: 64 bit number
*/
@@ -78,7 +78,7 @@ writer.prototype.lcbits = function(s){
writer.prototype.add = function(s)
{
if (typeof s == "string") // add string bufer
- this.data += s;
+ this.data += s;
else if (typeof s == "number") // add four byte integer
{
this.data += String.fromCharCode( s & 0xff );
diff --git a/lib/mysql-native/socketclient.js b/lib/mysql-native/socketclient.js
index 70d8bd3..ef4c2db 100644
--- a/lib/mysql-native/socketclient.js
+++ b/lib/mysql-native/socketclient.js
@@ -4,7 +4,7 @@ var sys = require('sys')
, writer = require('./serializers/writer')
, commands = require('./commands')
, queue = require('./containers/queue')
-
+
function packetLength(data)
{
var len = data.charCodeAt(0);
@@ -14,11 +14,11 @@ function packetLength(data)
}
function SocketClient(connection) {
-
+
var client = this;
this.queued_cmds = new queue();
this.connection = connection;
-
+
this.connection.buffer = "";
this.connection.pscache = {}
this.connection.setEncoding("binary");
@@ -31,7 +31,7 @@ function SocketClient(connection) {
// expose api methods as client instance methods
var apimethods = Object.getOwnPropertyNames(commands)
- apimethods.forEach(function(name, i, apimethods)
+ apimethods.forEach(function(name, i, apimethods)
{
// assign commend name to function
// it is assigned to cmd object in the constructor
@@ -49,7 +49,7 @@ function SocketClient(connection) {
this.connected = true;
client.dispatch_packet();
}
-
+
this.buffer += data;
var len = packetLength(this.buffer);
@@ -64,7 +64,7 @@ function SocketClient(connection) {
return client;
}
-
+
SocketClient.prototype.set = function(name, val) {
this.settings[name] = val
return this
@@ -73,7 +73,7 @@ SocketClient.prototype.set = function(name, val) {
SocketClient.prototype.get = function(name) {
return this.settings[name]
}
-
+
SocketClient.prototype.escape = function(str) {
str = str.replace(/\0/g, "\\0")
str = str.replace(/\n/g, "\\n")
@@ -121,7 +121,7 @@ SocketClient.prototype.add = function(c) {
this.queued_cmds.push(c);
if (need_start_queue)
this.dispatch_packet();
-
+
return c;
}
diff --git a/lib/mysql-native/wrappers/websql.js b/lib/mysql-native/wrappers/websql.js
index a217e7a..ca2df64 100644
--- a/lib/mysql-native/wrappers/websql.js
+++ b/lib/mysql-native/wrappers/websql.js
@@ -25,12 +25,12 @@ transaction.prototype.executeSql = function (query, args, rsCallback, errorCallb
});
execCmd.addListener('end', function() { if (tx.clean && rsCallback) rsCallback(tx, results); });
execCmd.addListener('error', function(err)
- {
- tx.clean = false;
- if (errorCallback)
+ {
+ tx.clean = false;
+ if (errorCallback)
errorCallback(tx, err);
if (tx.onerror)
- tx.onerror(err);
+ tx.onerror(err);
});
tx.last_exec_cmd = execCmd;
}
@@ -51,7 +51,7 @@ exports.openDatabase = function(db, user, password)
txCreated(t);
var commit = connection.query("");
t.last_exec_cmd.addListener('end', function()
- {
+ {
commit.sql = t.clean ? "COMMIT" : "ROLLBACK"
});
}
diff --git a/test/autoprepare.test.js b/test/autoprepare.test.js
index 7b8b811..88cf3ab 100644
--- a/test/autoprepare.test.js
+++ b/test/autoprepare.test.js
@@ -1,9 +1,9 @@
-var assert = require('assert'),
+var assert = require('assert'),
mysql = require('../lib/mysql-native');
-function createConnection()
+function createConnection()
{
- var db = mysql.createTCPClient();
+ var db = mysql.createTCPClient();
//db.verbose = true;
db.set('auto_prepare', true)
.set('row_as_hash', false)
@@ -15,7 +15,7 @@ module.exports = {
'test execute and autoprepare': function(fn) {
var db = createConnection();
var end_count = 0; // issue #16 - end emitted twice
- var q = 'select 1+?';
+ var q = 'select 1+?';
db.execute(q, [345])
.on('end', function()
{
@@ -31,11 +31,11 @@ module.exports = {
assert.equal(end_count, 1, 'end event expected to fire exactly one time');
var ps = db.connection.pscache[q];
assert.equal(false, !ps, 'expecting cached statement');
- db.close();
+ db.close();
if (fn)
fn();
- }, 200);
-
+ }, 200);
+
},
' #17 issue test ': function(fn)
{
diff --git a/test/bigint-bf.test.js b/test/bigint-bf.test.js
index f352dd7..5f0b8ac 100644
--- a/test/bigint-bf.test.js
+++ b/test/bigint-bf.test.js
@@ -1,9 +1,9 @@
-var assert = require('assert'),
+var assert = require('assert'),
mysql = require('../lib/mysql-native');
-function createConnection()
+function createConnection()
{
- var db = mysql.createTCPClient();
+ var db = mysql.createTCPClient();
//db.verbose = true;
db.set('auto_prepare', true)
.set('row_as_hash', false)
@@ -42,7 +42,7 @@ module.exports = {
runTest(params, setupSql, insertSql, [testInt], testSql, [], function(r){
assert.equal(r[0],testInt);
- }, params);
+ }, params);
},
'test bit fields': function(params) {
diff --git a/test/errors.test.js b/test/errors.test.js
index ef1c4f8..25b544a 100644
--- a/test/errors.test.js
+++ b/test/errors.test.js
@@ -15,7 +15,7 @@ module.exports = {
'test error on query': function(beforeExit) {
var db = createClient();
var testEndCalled = false
-
+
// attempt to run a bunk query
db.query('SELECT * FROM').on('error', function(error) {
assert.equal(error.num, 1064)
@@ -25,19 +25,19 @@ module.exports = {
testEndCalled = true
db.close()
})
-
+
beforeExit(function() {
assert.equal(testEndCalled, false)
})
-
+
},
-
+
'test error on empty query': function(beforeExit) {
-
+
var db = createClient();
-
+
var testEndCalled = false
-
+
// attempt to run a bunk query
db.query('').on('error', function(error) {
assert.equal(error.num, 1065)
@@ -47,7 +47,7 @@ module.exports = {
testEndCalled = true
db.close()
})
-
+
beforeExit(function() {
assert.equal(testEndCalled, false)
})
@@ -66,7 +66,7 @@ module.exports = {
testEndCalled = true
db.close()
})
-
+
beforeExit(function() {
assert.equal(testEndCalled, false)
})
diff --git a/test/expresso-wrapper.js b/test/expresso-wrapper.js
index 214a395..6271c1d 100644
--- a/test/expresso-wrapper.js
+++ b/test/expresso-wrapper.js
@@ -30,12 +30,12 @@ function runModuleTests(m, cb)
cb();
}
}
- runOne();
+ runOne();
}
function runTest(name, cb)
{
- try {
+ try {
var m = require(name);
runModuleTests(m, cb);
} catch(e) {
diff --git a/test/insert.test.js b/test/insert.test.js
index a79b243..503e4e7 100644
--- a/test/insert.test.js
+++ b/test/insert.test.js
@@ -13,10 +13,10 @@ function createClient()
}
module.exports = {
-
+
'test insert quoted': function(cb) {
- var db = createClient();
+ var db = createClient();
var sql = 'INSERT INTO tbl SET id = NULL, field = ' + db.quote("this is' a test\" 'quoted' string");
db.query(sql).on('row', function(r) {
@@ -25,15 +25,15 @@ module.exports = {
if(cb)
cb();
})
-
+
},
-
+
'test insert quoted multiline': function(cb) {
-
- var db = createClient();
+
+ var db = createClient();
var sql = 'INSERT INTO tbl SET id = NULL, field = ' + db.quote("this is' a test\" 'quoted' string\nwith multiple\nlines")
db.query(sql).on('result', function(r) {
-
+
var insert_id = this.result.insert_id;
assert.ok(insert_id >= 0)
@@ -48,15 +48,15 @@ module.exports = {
cb();
})
})
-
+
},
-
+
'test insert multibyte characters': function(cb) {
-
+
var db = createClient();
var sql = 'INSERT INTO tbl SET id = NULL, field = ' + db.quote("本日は晴天なり");
db.query(sql).on('end', function() {
-
+
var insert_id = this.result.insert_id;
assert.ok(insert_id >= 0)
@@ -71,8 +71,8 @@ module.exports = {
if(cb)
cb();
})
-
+
})
-
+
}
}
diff --git a/test/prepared.test.js b/test/prepared.test.js
index a751b12..c3616cc 100644
--- a/test/prepared.test.js
+++ b/test/prepared.test.js
@@ -7,7 +7,7 @@ var
//
// parts of code from expresso
// TODO: move to wrapper
-//
+//
assert.eql = assert.deepEqual;
assert.isNull = function(val, msg) {
@@ -36,10 +36,10 @@ function createClient()
}
module.exports = {
-
+
'test autoprepare': function(cb) {
-
- var db = createClient();
+
+ var db = createClient();
var sql = 'SELECT * FROM tbl WHERE id = ?'
db.execute(sql, [1]).addListener('row', function(r) {
assert.isDefined(r.id)
@@ -47,12 +47,12 @@ module.exports = {
db.close();
cb();
})
-
+
},
-
+
'test prepare params': function(cb) {
- var db = createClient();
+ var db = createClient();
var params = ['param', 'param2', 'param3']
db.execute("select ?,?,?", params).addListener('row', function(r) {
assert.includes(r, 'param')
@@ -62,10 +62,10 @@ module.exports = {
cb();
})
},
-
+
'test prepare null params': function(cb) {
- var db = createClient();
+ var db = createClient();
var params = [null, null, null]
db.execute("select ?,?,?", params).addListener('row', function(r) {
@@ -75,12 +75,12 @@ module.exports = {
db.close();
cb();
})
-
+
},
-
+
'test prepare undefined params': function(cb) {
- var db = createClient();
+ var db = createClient();
var params = [undefined, undefined, undefined]
db.execute("select ?,?,?", params).addListener('row', function(r) {
@@ -90,12 +90,12 @@ module.exports = {
db.close();
cb();
})
-
+
},
-
+
'test prepare mixed params': function(cb) {
- var db = createClient();
+ var db = createClient();
var params = [null, 'param2', undefined]
db.execute("select ?,?,?", params).addListener('row', function(r) {
@@ -107,12 +107,12 @@ module.exports = {
db.close();
cb();
})
-
+
},
-
+
'test execute result complete': function(cb) {
- var db = createClient();
+ var db = createClient();
db.execute("select ?,?,?", [ 'test', null, 1]).addListener('result', function(res) {
assert.length(res.rows, 1)
}).addListener('end', function() {
diff --git a/test/select.test.js b/test/select.test.js
index 7e492e3..fbd4e0b 100644
--- a/test/select.test.js
+++ b/test/select.test.js
@@ -16,9 +16,9 @@ module.exports = {
}).addListener('end', function() {
db.close()
})
-
+
},
-
+
'test select all rows result event': function() {
var db = mysql.createTCPClient()
db.set('auto_prepare', true)
@@ -31,7 +31,7 @@ module.exports = {
db.close()
})
},
-
+
'test select no results': function() {
var db = mysql.createTCPClient()
db.set('auto_prepare', true)
@@ -44,7 +44,7 @@ module.exports = {
db.close()
})
},
-
+
'test result field null number': function() {
var db = mysql.createTCPClient()
db.set('auto_prepare', true)
@@ -54,7 +54,7 @@ module.exports = {
// first insert a record that we know has a null value
db.query('INSERT INTO tbl SET parent = NULL').addListener('result', function(res) {
var insert_id = res.insert_id
-
+
var sql = 'SELECT * FROM tbl WHERE id = ' + insert_id
db.query(sql).addListener('row', function(r) {
assert.isNull(r.parent)
@@ -63,7 +63,7 @@ module.exports = {
db.close()
})
},
-
+
'test result field non null number': function() {
var db = mysql.createTCPClient()
db.set('auto_prepare', true)
@@ -78,7 +78,7 @@ module.exports = {
db.query(sql).addListener('row', function(r) {
assert.eql(r.parent, 1)
})
-
+
}).addListener('end', function() {
db.close()
})
diff --git a/test/test_autoprepare.js b/test/test_autoprepare.js
index 8ebc5cf..d63e7aa 100755
--- a/test/test_autoprepare.js
+++ b/test/test_autoprepare.js
@@ -1,13 +1,13 @@
#!/usr/local/bin/node
-var sys = require("sys");
+var sys = require("sys");
var db = require("../lib/mysql-native").createTCPClient();
db.auth("test", "testuser", "testpass");
db.set('auto_prepare', true)
.set('row_as_hash', true)
-
+
var sql = process.argv[2];
db.execute(sql, process.argv.slice(3))
diff --git a/test/test_execute.js b/test/test_execute.js
index f661c75..6b73367 100755
--- a/test/test_execute.js
+++ b/test/test_execute.js
@@ -1,6 +1,6 @@
#!/usr/local/bin/node
-var sys = require("sys");
+var sys = require("sys");
var mysql = require("../lib/mysql-native");
var db = mysql.createTCPClient();
diff --git a/test/test_null_param.js b/test/test_null_param.js
index 5aa5d41..ef2b15f 100755
--- a/test/test_null_param.js
+++ b/test/test_null_param.js
@@ -28,6 +28,6 @@ db.query("create temporary table nullparams( \
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;").addListener('end', function() {
dump_rows(db.execute("insert into nullparams (a, b, c) values (?,?,?)", [null, "word", null]))
dump_rows(db.execute("select * from nullparams"))
- db.close();
+ db.close();
})
diff --git a/test/test_query.js b/test/test_query.js
index fe2feba..566e3e7 100755
--- a/test/test_query.js
+++ b/test/test_query.js
@@ -1,6 +1,6 @@
#!/usr/local/bin/node
-var sys = require("sys");
+var sys = require("sys");
var db = require("../lib/mysql-native").createTCPClient();
db.auth("test", "testuser", "testpass").addListener('authorized', function(s) { sys.puts("authorized as " + sys.inspect(s)); });
diff --git a/test/test_stmt_parameters.js b/test/test_stmt_parameters.js
index 52f8cfb..5429de2 100755
--- a/test/test_stmt_parameters.js
+++ b/test/test_stmt_parameters.js
@@ -1,6 +1,6 @@
#!/usr/local/bin/node
-var sys = require("sys");
+var sys = require("sys");
var db = require("../lib/mysql-native").createTCPClient();
db.auth("test", "testuser", "testpass");
diff --git a/test/test_stress.js b/test/test_stress.js
index 1f332cd..ebc44ef 100755
--- a/test/test_stress.js
+++ b/test/test_stress.js
@@ -1,6 +1,6 @@
#!/usr/local/bin/node
-var sys = require("sys");
+var sys = require("sys");
var createTCPClient = require("../lib/mysql-native").createTCPClient;
var numclients = process.argv[2];