Skip to content
This repository
  • 5 commits
  • 7 files changed
  • 0 comments
  • 1 contributor
Sep 02, 2010
Felix Geisendörfer Add contributors to readme 5e1183f
Felix Geisendörfer Update todos ee63231
Sep 17, 2010
Felix Geisendörfer Test case showing column ordering bug
Original test case by Bert Belder:
http://gist.github.com/583048
5e68d18
Felix Geisendörfer Fix column ordering bug
Original patch by Bert Belder, see:
http://gist.github.com/583103

This patch also adds a unit test. I had to to move the packet.emit line
a little, as to make the unit test easier to produce.
7340394
Felix Geisendörfer Bump version c05ecc8
10  Readme.md
Source Rendered
@@ -5,6 +5,13 @@
5 5
 A node.js module implementing the
6 6
 [MySQL protocol](http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol).
7 7
 
  8
+## Contributors
  9
+
  10
+* Bert Belder ([piscisaureus](http://github.com/felixge/node-mysql/commits/master?author=piscisaureus))
  11
+* Alan Gutierrez ([bigeasy](http://github.com/felixge/node-mysql/commits/master?author=bigeasy))
  12
+* Brian ([mscdex](http://github.com/felixge/node-mysql/commits/master?author=mscdex))
  13
+* Cal Henderson ([iamcal](http://github.com/felixge/node-mysql/commits/master?author=iamcal))
  14
+
8 15
 ## Sponsors
9 16
 
10 17
 * [Joyent](http://www.joyent.com/)
@@ -185,10 +192,9 @@ parameter is provided which contains the information from the mysql OK packet.
185 192
 
186 193
 At this point the module is ready to be tried out, but a lot of things are yet to be done:
187 194
 
  195
+* Auto-cast mysql types into JS types
188 196
 * Prepared Statements
189  
-* Test using no Password
190 197
 * Charsets handling
191  
-* Import Error code constants
192 198
 * ...
193 199
 
194 200
 ## License
4  lib/mysql/parser.js
@@ -515,10 +515,10 @@ Parser.prototype.write = function(buffer) {
515 515
         break;
516 516
       case Parser.COLUMN_VALUE_STRING:
517 517
         var remaining = packet.columnLength - packet.index, read;
518  
-        if (i + remaining >= buffer.length) {
  518
+        if (i + remaining > buffer.length) {
519 519
           read = buffer.length - i;
520  
-          packet.emit('data', buffer.slice(i, buffer.length), remaining - read);
521 520
           packet.index += read;
  521
+          packet.emit('data', buffer.slice(i, buffer.length), remaining - read);
522 522
           // the -1 offsets are because these values are also manipulated by the loop itself
523 523
           packet.received += read - 1;
524 524
           i = buffer.length;
2  package.json
... ...
@@ -1,5 +1,5 @@
1 1
 { "name" : "mysql"
2  
-, "version": "0.4.0"
  2
+, "version": "0.5.0"
3 3
 , "dependencies": {"gently": ">=0.8.0"}
4 4
 , "main" : "./lib/mysql"
5 5
 }
1  test/common.js
@@ -12,6 +12,7 @@ global.TEST_CONFIG = {
12 12
 };
13 13
 
14 14
 global.TEST_TABLE = 'posts';
  15
+global.TEST_FIXTURES = path.join(__dirname, 'fixture');
15 16
 
16 17
 global.Gently = require('gently');
17 18
 global.assert = require('assert');
54  test/fixture/columnia.sql
... ...
@@ -0,0 +1,54 @@
  1
+CREATE TABLE `columnia` (
  2
+  `f0` bigint(20) unsigned NOT NULL DEFAULT '0',
  3
+  `field0001` bigint(20) unsigned NOT NULL DEFAULT '0',
  4
+  `field002` bigint(20) unsigned NOT NULL DEFAULT '0',
  5
+  `field0000000003` bigint(20) unsigned DEFAULT NULL,
  6
+  `field00004` bigint(20) unsigned NOT NULL DEFAULT '0',
  7
+  `field000000000005` bigint(20) unsigned DEFAULT NULL,
  8
+  `field0000000000006` bigint(20) unsigned NOT NULL,
  9
+  `field000007` text NOT NULL,
  10
+  `field0000000008` text NOT NULL,
  11
+  `field009` int(10) NOT NULL DEFAULT '0',
  12
+  `field00010` text NOT NULL,
  13
+  `field000000000011` text NOT NULL,
  14
+  `field00000012` text NOT NULL,
  15
+  `field0000013` text NOT NULL,
  16
+  `field00000000000014` text NOT NULL,
  17
+  `field0000000015` text NOT NULL,
  18
+  `field000016` text NOT NULL,
  19
+  `field000000000017` text NOT NULL,
  20
+  `field0000000000000018` text NOT NULL,
  21
+  `field0000000000019` text NOT NULL,
  22
+  `field0000000000020` text NOT NULL,
  23
+  `field00000000000021` text NOT NULL,
  24
+  `field00000000022` text NOT NULL,
  25
+  `field000000000000000023` text NOT NULL,
  26
+  `field000000000000024` text NOT NULL,
  27
+  `field000000000000025` text NOT NULL,
  28
+  `field0000000000000026` text NOT NULL,
  29
+  `field0000000000027` text NOT NULL,
  30
+  `field00000028` bigint(20) unsigned NOT NULL,
  31
+  `field000000029` tinyint(1) NOT NULL,
  32
+  `field000030` tinyint(1) NOT NULL DEFAULT '0',
  33
+  `field31` text NOT NULL,
  34
+  `field00000032` bigint(20) unsigned NOT NULL,
  35
+  `fi33` int(11) NOT NULL DEFAULT '0',
  36
+  `field00000034` bigint(20) unsigned DEFAULT NULL,
  37
+  `field000035` text NOT NULL,
  38
+  `field0036` int(11) NOT NULL DEFAULT '0',
  39
+  `field0000000000000000000037` text NOT NULL,
  40
+  `field0000000000000000000038` text NOT NULL,
  41
+  `field0000000000000000000000000039` text NOT NULL,
  42
+  `field0000000000000000040` text NOT NULL,
  43
+  `field00000000000000000041` text NOT NULL,
  44
+  `field00000000000000000000042` text NOT NULL,
  45
+  `field00000000000000000043` text NOT NULL,
  46
+  `field00000000000000000044` text NOT NULL,
  47
+  `field00000000000000000000000045` text NOT NULL,
  48
+  `field00000000000000046` text NOT NULL,
  49
+  `field000000000000000047` text NOT NULL,
  50
+  `field000000000000000000048` text NOT NULL,
  51
+  `field49` text NOT NULL,
  52
+  `field50` int(11) NOT NULL,
  53
+  PRIMARY KEY (`f0`)
  54
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
1  test/simple/test-parser.js
@@ -343,6 +343,7 @@ test(function write() {
343 343
       assert.equal(event, 'data');
344 344
       assert.equal(val.toString(), 'Fine!');
345 345
       assert.equal(remaining, 0);
  346
+      assert.equal(packet.index, 0);
346 347
     });
347 348
 
348 349
     parser.write(new Buffer(' are you?\u0005Fine!'));
40  test/system/test-client-query-column-order.js
... ...
@@ -0,0 +1,40 @@
  1
+require('../common');
  2
+var REPEATS = 1000,
  3
+    Client = require('mysql').Client,
  4
+    client = Client(TEST_CONFIG),
  5
+    fs = require('fs'),
  6
+    gently = new Gently();
  7
+
  8
+client.connect();
  9
+
  10
+client.query('CREATE DATABASE '+TEST_DB, function(err) {
  11
+  if (err && err.number != Client.ERROR_DB_CREATE_EXISTS) {
  12
+    throw err;
  13
+  }
  14
+});
  15
+client.query('USE '+TEST_DB);
  16
+
  17
+client.query('DROP TABLE IF EXISTS columnia');
  18
+var fixture = fs.readFileSync(TEST_FIXTURES+'/columnia.sql', 'utf8');
  19
+client.query(fixture);
  20
+
  21
+var finished = 0;
  22
+for (var i = 0; i < REPEATS; i++) {
  23
+  (function(i) {
  24
+    var query = client.query("SHOW COLUMNS FROM columnia");
  25
+
  26
+    query.on('row', function(row) {
  27
+      if (!row.Type) {
  28
+        throw new Error('Column order mixed up after '+i+' queries.');
  29
+      }
  30
+    });
  31
+
  32
+    query.on('end', function() {
  33
+      finished++;
  34
+      if (finished === REPEATS) {
  35
+        process.exit(0);
  36
+      }
  37
+    });
  38
+  })(i);
  39
+}
  40
+

No commit comments for this range

Something went wrong with that request. Please try again.