Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijah Stone committed Jul 1, 2021
1 parent 6ff46c0 commit c71862b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/dpq2/conv/native_tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,23 @@ public void _integration_test( string connParam ) @system
C!(Nullable!(int[]))(Nullable!(int[]).init, "int[]", "NULL");
C!(Nullable!(int[]))(Nullable!(int[])([1,2,3]), "int[]", "'{1,2,3}'");
}

// test round-trip compound types
{
conn.exec("CREATE TYPE test_type AS (x int, y int)");
scope(exit) conn.exec("DROP TYPE test_type");

params.sqlCommand = "SELECT 'test_type'::regtype::oid";
OidType oid = cast(OidType)conn.execParams(params)[0][0].as!Oid;

Value input = Value(toRecordValue([17.toValue, Nullable!int.init.toValue]).data, oid);

params.sqlCommand = "SELECT $1::text";
params.args = [input];
Value v = conn.execParams(params)[0][0];
assert(v.as!string == `(17,)`, v.as!string);
params.sqlCommand = "SELECT $1";
v = conn.execParams(params)[0][0];
assert(v.oidType == oid && v.data == input.data);
}
}
1 change: 1 addition & 0 deletions src/dpq2/oids.d
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool isNativeInteger(OidType t) pure
case Int8:
case Int2:
case Int4:
case Oid:
return true;
default:
break;
Expand Down

0 comments on commit c71862b

Please sign in to comment.