Skip to content

Commit 9174eca

Browse files
committed
Expose column names in row struct
1 parent d28a180 commit 9174eca

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

source/mysql/protocol/comms.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ body
636636

637637
// Moved here from `struct Row.this`
638638
package(mysql) void ctorRow(Connection conn, ref ubyte[] packet, ResultSetHeaders rh, bool binary,
639-
out Variant[] _values, out bool[] _nulls)
639+
out Variant[] _values, out bool[] _nulls, out string[] names)
640640
in
641641
{
642642
assert(rh.fieldCount <= uint.max);
@@ -646,7 +646,7 @@ body
646646
scope(failure) conn.kill();
647647

648648
uint fieldCount = cast(uint)rh.fieldCount;
649-
_values.length = _nulls.length = fieldCount;
649+
_values.length = _nulls.length = names.length = fieldCount;
650650

651651
if(binary)
652652
{
@@ -669,6 +669,7 @@ body
669669
do
670670
{
671671
FieldDescription fd = rh[i];
672+
names[i] = fd.name;
672673
sqlValue = packet.consumeIfComplete(fd.type, binary, fd.unsigned, fd.charSet);
673674
// TODO: Support chunk delegate
674675
if(sqlValue.isIncomplete)

source/mysql/result.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ private:
3737
bool[] _nulls;
3838

3939
public:
40+
/++
41+
The names of the columns in this row.
42+
+/
43+
string[] names;
4044

4145
/++
4246
A constructor to extract the column data from a row data packet.
@@ -51,7 +55,7 @@ public:
5155
+/
5256
this(Connection con, ref ubyte[] packet, ResultSetHeaders rh, bool binary)
5357
{
54-
ctorRow(con, packet, rh, binary, _values, _nulls);
58+
ctorRow(con, packet, rh, binary, _values, _nulls, names);
5559
}
5660

5761
/++

0 commit comments

Comments
 (0)