Skip to content

Commit f226b68

Browse files
authored
Merge pull request #250 from schveiguy/fixcolnames
Fix issue #222. Set column names even for null columns
2 parents bbdd562 + dabca43 commit f226b68

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

integration-tests/source/mysql/maintests.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,3 +1335,17 @@ unittest
13351335
assert(rows[1].getName(0) == "another");
13361336
assert(rows[1].getName(1) == "someValue");
13371337
}
1338+
1339+
// issue 222, set column names when data is null.
1340+
@("colNamesForBinary")
1341+
debug(MYSQLN_TESTS)
1342+
unittest
1343+
{
1344+
import mysql.test.common;
1345+
import mysql.commands;
1346+
mixin(scopedCn);
1347+
// binary mode happens with prepared statements
1348+
auto row = cn.queryRow("SELECT `colname` FROM (SELECT 1 AS `id`, NULL AS `colname`) as `tbl` WHERE `id` = ?", 1);
1349+
assert(row.get[0] == null);
1350+
assert(row.get.getName(0) == "colname");
1351+
}

source/mysql/protocol/comms.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ do
663663
if(binary && _nulls[i])
664664
{
665665
_values[i] = null;
666+
_names[i] = rh[i].name;
666667
continue;
667668
}
668669

0 commit comments

Comments
 (0)