Skip to content

Commit ea12998

Browse files
toverdijkmp911de
authored andcommitted
Added new PostgresqlStatement
Also, remove references to SimpleQueryPostgresqlStatement and ExtendedQueryPostgresqlStatement and deleted the files and their tests [#468]
1 parent 6fb916d commit ea12998

11 files changed

+369
-1058
lines changed

src/main/java/io/r2dbc/postgresql/ExtendedQueryPostgresqlStatement.java

Lines changed: 0 additions & 328 deletions
This file was deleted.

src/main/java/io/r2dbc/postgresql/PostgresqlBatch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.r2dbc.postgresql;
1818

1919
import io.r2dbc.postgresql.util.Assert;
20+
import io.r2dbc.postgresql.util.sql.BasicPostgresqlSqlLexer;
2021
import io.r2dbc.spi.Batch;
2122
import reactor.core.publisher.Flux;
2223

@@ -40,7 +41,7 @@ final class PostgresqlBatch implements io.r2dbc.postgresql.api.PostgresqlBatch {
4041
public PostgresqlBatch add(String sql) {
4142
Assert.requireNonNull(sql, "sql must not be null");
4243

43-
if (!SimpleQueryPostgresqlStatement.supports(sql)) {
44+
if (!(BasicPostgresqlSqlLexer.tokenize(sql).getParameterCount() > 0)) {
4445
throw new IllegalArgumentException(String.format("Statement '%s' is not supported. This is often due to the presence of parameters.", sql));
4546
}
4647

@@ -50,7 +51,7 @@ public PostgresqlBatch add(String sql) {
5051

5152
@Override
5253
public Flux<io.r2dbc.postgresql.api.PostgresqlResult> execute() {
53-
return new SimpleQueryPostgresqlStatement(this.context, String.join("; ", this.statements))
54+
return new PostgresqlStatement(this.context, String.join("; ", this.statements))
5455
.execute();
5556
}
5657

src/main/java/io/r2dbc/postgresql/PostgresqlConnection.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ final class PostgresqlConnection implements io.r2dbc.postgresql.api.PostgresqlCo
8686
this.connectionContext = client.getContext();
8787
this.codecs = Assert.requireNonNull(codecs, "codecs must not be null");
8888
this.isolationLevel = Assert.requireNonNull(isolationLevel, "isolationLevel must not be null");
89-
this.validationQuery = new SimpleQueryPostgresqlStatement(this.resources, "SELECT 1").fetchSize(0).execute().flatMap(PostgresqlResult::getRowsUpdated);
89+
this.validationQuery = new io.r2dbc.postgresql.PostgresqlStatement(this.resources, "SELECT 1").fetchSize(0).execute().flatMap(PostgresqlResult::getRowsUpdated);
9090
}
9191

9292
Client getClient() {
@@ -236,14 +236,7 @@ public Mono<Void> createSavepoint(String name) {
236236
@Override
237237
public PostgresqlStatement createStatement(String sql) {
238238
Assert.requireNonNull(sql, "sql must not be null");
239-
240-
if (SimpleQueryPostgresqlStatement.supports(sql)) {
241-
return new SimpleQueryPostgresqlStatement(this.resources, sql);
242-
} else if (ExtendedQueryPostgresqlStatement.supports(sql)) {
243-
return new ExtendedQueryPostgresqlStatement(this.resources, sql);
244-
} else {
245-
throw new IllegalArgumentException(String.format("Statement '%s' cannot be created. This is often due to the presence of both multiple statements and parameters at the same time.", sql));
246-
}
239+
return new io.r2dbc.postgresql.PostgresqlStatement(this.resources, sql);
247240
}
248241

249242
/**

0 commit comments

Comments
 (0)