Skip to content

Commit

Permalink
Expose column names in row struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jpf91 committed Oct 21, 2018
1 parent d28a180 commit 0273d85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions source/mysql/protocol/comms.d
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ body

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

uint fieldCount = cast(uint)rh.fieldCount;
_values.length = _nulls.length = fieldCount;
_values.length = _nulls.length = names.length = fieldCount;

if(binary)
{
Expand All @@ -669,6 +669,7 @@ body
do
{
FieldDescription fd = rh[i];
names[i] = fd.name;
sqlValue = packet.consumeIfComplete(fd.type, binary, fd.unsigned, fd.charSet);
// TODO: Support chunk delegate
if(sqlValue.isIncomplete)
Expand Down
3 changes: 2 additions & 1 deletion source/mysql/result.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private:
bool[] _nulls;

public:
string[] names;

/++
A constructor to extract the column data from a row data packet.
Expand All @@ -51,7 +52,7 @@ public:
+/
this(Connection con, ref ubyte[] packet, ResultSetHeaders rh, bool binary)
{
ctorRow(con, packet, rh, binary, _values, _nulls);
ctorRow(con, packet, rh, binary, _values, _nulls, names);
}

/++
Expand Down

0 comments on commit 0273d85

Please sign in to comment.