Skip to content

Commit 0273d85

Browse files
committed
Expose column names in row struct
1 parent d28a180 commit 0273d85

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private:
3737
bool[] _nulls;
3838

3939
public:
40+
string[] names;
4041

4142
/++
4243
A constructor to extract the column data from a row data packet.
@@ -51,7 +52,7 @@ public:
5152
+/
5253
this(Connection con, ref ubyte[] packet, ResultSetHeaders rh, bool binary)
5354
{
54-
ctorRow(con, packet, rh, binary, _values, _nulls);
55+
ctorRow(con, packet, rh, binary, _values, _nulls, names);
5556
}
5657

5758
/++

0 commit comments

Comments
 (0)