Skip to content

Commit ab0f114

Browse files
committed
WIP - unable to get the correct result out
1 parent 200a515 commit ab0f114

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgConnectionImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ public Query<RowSet<Row>> copyToRows(String sql) {
137137

138138
@Override
139139
public Future<SqlResult<Buffer>> copyToBytes(String sql) {
140-
Function<Buffer, SqlResultImpl<Buffer>> factory = SqlResultImpl::new;
140+
Function<Buffer, SqlResultImpl<Buffer>> factory = (buffer) -> new SqlResultImpl<>(buffer);
141141
PromiseInternal<SqlResult<Buffer>> promise = context.promise();
142142

143+
// currently, this loads entire content into Buffer
144+
// it should stream bytes out instead
145+
// TODO: signal completion as soon as the database replied CopyOutResponse 'H' ?
143146
QueryResultBuilder<Buffer, SqlResultImpl<Buffer>, SqlResult<Buffer>> resultHandler =
144147
new QueryResultBuilder<>(factory, promise);
145148

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CopyOutCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.vertx.sqlclient.impl.SqlResultImpl;
88
import io.vertx.sqlclient.impl.command.CommandBase;
99

10-
import java.util.function.Function;
1110
import java.util.stream.Collector;
1211

1312
public class CopyOutCommand extends CommandBase<SqlResult<Buffer>> {
@@ -25,7 +24,7 @@ public CopyOutCommand(
2524
Buffer::buffer,
2625
(v, chunk) -> v.appendBuffer(Buffer.buffer(chunk)),
2726
(v1, v2) -> null,
28-
Function.identity()
27+
(finalResult) -> finalResult
2928
);
3029
}
3130

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CopyOutCommandCodec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.vertx.core.buffer.Buffer;
44
import io.vertx.core.buffer.impl.BufferImpl;
55
import io.vertx.sqlclient.SqlResult;
6+
import io.vertx.sqlclient.impl.SqlResultImpl;
67

78
class CopyOutCommandCodec extends PgCommandCodec<SqlResult<Buffer>, CopyOutCommand> {
89
CopyOutDataDecoder decoder;
@@ -14,7 +15,7 @@ class CopyOutCommandCodec extends PgCommandCodec<SqlResult<Buffer>, CopyOutComma
1415

1516
@Override
1617
public void handleCommandComplete(int updated) {
17-
this.result = null;
18+
this.result = new SqlResultImpl<Buffer>(Buffer.buffer("abc"));
1819
Buffer result;
1920
Throwable failure;
2021
int size;

vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionCopyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.vertx.ext.unit.Async;
44
import io.vertx.ext.unit.TestContext;
5-
import org.junit.Ignore;
65
import org.junit.Test;
76

87
public class PgConnectionCopyTest extends PgConnectionTestBase {
@@ -74,6 +73,7 @@ public void testSimpleQuery(TestContext ctx) {
7473
conn
7574
.query("select 1")
7675
.execute()
76+
// when does the result is transformed from bool to rows?
7777
.onComplete(ctx.asyncAssertSuccess(result1 -> {
7878
ctx.assertEquals(1, result1.size());
7979
async.complete();

0 commit comments

Comments
 (0)