Skip to content

Commit d1ab545

Browse files
authored
Merge pull request #42 from clue-labs/blob
Report correct field length for fields longer than 16k chars
2 parents c0d06c3 + 7082689 commit d1ab545

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Protocal/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public function parse($data)
256256
$u = unpack('v', $this->read(2));
257257
$field['charset'] = $u[1];
258258

259-
$u = unpack('v', $this->read(4));
259+
$u = unpack('V', $this->read(4));
260260
$field['length'] = $u[1];
261261

262262
$field['type'] = ord($this->read(1));

tests/ResultQueryTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ public function testSelectStaticTextWithQuestionMark()
6161
$loop->run();
6262
}
6363

64+
public function testSelectLongStaticTextWithProperType()
65+
{
66+
$loop = \React\EventLoop\Factory::create();
67+
68+
$connection = new \React\MySQL\Connection($loop, $this->getConnectionOptions());
69+
$connection->connect(function () {});
70+
71+
$length = 40000;
72+
73+
$connection->query('SELECT ?', function ($command, $conn) use ($length) {
74+
$this->assertEquals(false, $command->hasError());
75+
$this->assertCount(1, $command->resultFields);
76+
$this->assertEquals($length * 3, $command->resultFields[0]['length']);
77+
$this->assertInstanceOf('React\MySQL\Connection', $conn);
78+
}, str_repeat('.', $length));
79+
80+
$connection->close();
81+
$loop->run();
82+
}
83+
6484
public function testSimpleSelect()
6585
{
6686
$loop = \React\EventLoop\Factory::create();

0 commit comments

Comments
 (0)