Skip to content

Commit

Permalink
bugfix for #52 + test added
Browse files Browse the repository at this point in the history
  • Loading branch information
denizzzka committed Nov 10, 2016
1 parent 4e53482 commit 53e8693
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dpq2/args.d
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ package struct InternalQueryParams
{
lengths[i] = qp.args[i].data.length.to!int;

if(qp.args[i].data.length != 0)
immutable ubyte[] zeroLengthArg = [123]; // fake value, isn't unused as argument

if(qp.args[i].data.length == 0)
values[i] = &zeroLengthArg[0];
else
values[i] = &qp.args[i].data[0];
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/dpq2/query.d
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ void _integration_test( string connParam ) @trusted
assert( a[0][4].as!Bson == binArray );
}

{
// Bug #52: empty text argument
QueryParams p;
Value v = toValue("");

p.sqlCommand = "SELECT $1";
p.args = [v];

auto a = conn.execParams(p);

assert( !a[0][0].isNull );
assert( a[0][0].as!string == "" );
}

// checking prepared statements
{
// uses PQprepare:
Expand Down

0 comments on commit 53e8693

Please sign in to comment.