Skip to content

Commit

Permalink
text array fix
Browse files Browse the repository at this point in the history
  • Loading branch information
denizzzka committed Apr 19, 2015
1 parent afb5220 commit 90dd91e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/example.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main()
"$2::timestamp with time zone as time_field, "
"$3::text, "
"$4::text as null_field, "
"array['first', 'second', 'NULL']::text[] as array_field, "
"array['first', 'second', NULL]::text[] as array_field, "
"$5::integer[] as multi_array";

p.args.length = 5;
Expand Down
8 changes: 5 additions & 3 deletions src/dpq2/answer.d
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ struct Value

/// Returns cell value as native string type
@property T as(T)() const
if( isSomeString!(T) )
if(is(T == string))
{
return to!T( cast(immutable(char)*) value.ptr );
import std.utf: toUTF8;

return toUTF8(cast(const(char[])) value);
}

/// Returns cell value as native integer or decimal values
Expand Down Expand Up @@ -425,7 +427,7 @@ const struct Array
{
assert( _arguments[i] == typeid(int) );
args[i] = va_arg!(int)(_argptr);
enforce( dimsSize[i] > args[i] ); // TODO: here is need exception, not enforce
enforce(dimsSize[i] > args[i], "Out of range"); // TODO: here is need exception, not enforce
}

// Calculates serial number of the element
Expand Down

0 comments on commit 90dd91e

Please sign in to comment.