Skip to content

Commit 2a37fb8

Browse files
committed
Minimal impl for sql-options
1 parent a6c42cb commit 2a37fb8

File tree

9 files changed

+34
-45
lines changed

9 files changed

+34
-45
lines changed

src/main/asciidoc/groovy/index.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application.
1515

1616
To use this client, you need to add the following jar to your `CLASSPATH`:
1717

18-
* vertx-mysql-postgresql-client 3.5.0.Beta1 (the client)
18+
* vertx-mysql-postgresql-client 3.5.0-SNAPSHOT (the client)
1919
* scala-library 2.11.4
2020
* the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async
2121
* joda time
@@ -33,15 +33,15 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de
3333
<dependency>
3434
<groupId>io.vertx</groupId>
3535
<artifactId>vertx-mysql-postgresql-client</artifactId>
36-
<version>3.5.0.Beta1</version>
36+
<version>3.5.0-SNAPSHOT</version>
3737
</dependency>
3838
----
3939

4040
* Gradle (in your `build.gradle` file):
4141

4242
[source,groovy,subs="+attributes"]
4343
----
44-
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0.Beta1'
44+
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0-SNAPSHOT'
4545
----
4646

4747
=== In an application using a vert.x distributions

src/main/asciidoc/java/index.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application.
1515

1616
To use this client, you need to add the following jar to your `CLASSPATH`:
1717

18-
* vertx-mysql-postgresql-client 3.5.0.Beta1 (the client)
18+
* vertx-mysql-postgresql-client 3.5.0-SNAPSHOT (the client)
1919
* scala-library 2.11.4
2020
* the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async
2121
* joda time
@@ -33,15 +33,15 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de
3333
<dependency>
3434
<groupId>io.vertx</groupId>
3535
<artifactId>vertx-mysql-postgresql-client</artifactId>
36-
<version>3.5.0.Beta1</version>
36+
<version>3.5.0-SNAPSHOT</version>
3737
</dependency>
3838
----
3939

4040
* Gradle (in your `build.gradle` file):
4141

4242
[source,groovy,subs="+attributes"]
4343
----
44-
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0.Beta1'
44+
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0-SNAPSHOT'
4545
----
4646

4747
=== In an application using a vert.x distributions

src/main/asciidoc/js/index.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application.
1515

1616
To use this client, you need to add the following jar to your `CLASSPATH`:
1717

18-
* vertx-mysql-postgresql-client 3.5.0.Beta1 (the client)
18+
* vertx-mysql-postgresql-client 3.5.0-SNAPSHOT (the client)
1919
* scala-library 2.11.4
2020
* the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async
2121
* joda time
@@ -33,15 +33,15 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de
3333
<dependency>
3434
<groupId>io.vertx</groupId>
3535
<artifactId>vertx-mysql-postgresql-client</artifactId>
36-
<version>3.5.0.Beta1</version>
36+
<version>3.5.0-SNAPSHOT</version>
3737
</dependency>
3838
----
3939

4040
* Gradle (in your `build.gradle` file):
4141

4242
[source,groovy,subs="+attributes"]
4343
----
44-
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0.Beta1'
44+
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0-SNAPSHOT'
4545
----
4646

4747
=== In an application using a vert.x distributions

src/main/asciidoc/kotlin/index.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application.
1515

1616
To use this client, you need to add the following jar to your `CLASSPATH`:
1717

18-
* vertx-mysql-postgresql-client 3.5.0.Beta1 (the client)
18+
* vertx-mysql-postgresql-client 3.5.0-SNAPSHOT (the client)
1919
* scala-library 2.11.4
2020
* the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async
2121
* joda time
@@ -33,15 +33,15 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de
3333
<dependency>
3434
<groupId>io.vertx</groupId>
3535
<artifactId>vertx-mysql-postgresql-client</artifactId>
36-
<version>3.5.0.Beta1</version>
36+
<version>3.5.0-SNAPSHOT</version>
3737
</dependency>
3838
----
3939

4040
* Gradle (in your `build.gradle` file):
4141

4242
[source,groovy,subs="+attributes"]
4343
----
44-
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0.Beta1'
44+
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0-SNAPSHOT'
4545
----
4646

4747
=== In an application using a vert.x distributions

src/main/asciidoc/ruby/index.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application.
1515

1616
To use this client, you need to add the following jar to your `CLASSPATH`:
1717

18-
* vertx-mysql-postgresql-client 3.5.0.Beta1 (the client)
18+
* vertx-mysql-postgresql-client 3.5.0-SNAPSHOT (the client)
1919
* scala-library 2.11.4
2020
* the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async
2121
* joda time
@@ -33,15 +33,15 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de
3333
<dependency>
3434
<groupId>io.vertx</groupId>
3535
<artifactId>vertx-mysql-postgresql-client</artifactId>
36-
<version>3.5.0.Beta1</version>
36+
<version>3.5.0-SNAPSHOT</version>
3737
</dependency>
3838
----
3939

4040
* Gradle (in your `build.gradle` file):
4141

4242
[source,groovy,subs="+attributes"]
4343
----
44-
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0.Beta1'
44+
compile 'io.vertx:vertx-mysql-postgresql-client:3.5.0-SNAPSHOT'
4545
----
4646

4747
=== In an application using a vert.x distributions

src/main/java/io/vertx/ext/asyncsql/impl/AsyncSQLConnectionImpl.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @author <a href="http://escoffier.me">Clement Escoffier</a>
3838
*/
39-
public class AsyncSQLConnectionImpl implements SQLConnection {
39+
public abstract class AsyncSQLConnectionImpl implements SQLConnection {
4040

4141
private final ExecutionContext executionContext;
4242
private volatile boolean inTransaction = false;
@@ -51,6 +51,11 @@ public AsyncSQLConnectionImpl(Connection connection, AsyncConnectionPool pool, E
5151
this.executionContext = executionContext;
5252
}
5353

54+
/**
55+
* Returns a vendor specific start transaction statement
56+
*/
57+
protected abstract String getStartTransactionStatement();
58+
5459
@Override
5560
public SQLConnection call(String sql, Handler<AsyncResult<ResultSet>> resultHandler) {
5661
throw new UnsupportedOperationException("Not implemented");
@@ -63,7 +68,7 @@ public SQLConnection callWithParams(String sql, JsonArray params, JsonArray outp
6368

6469
@Override
6570
public SQLConnection setOptions(SQLOptions options) {
66-
return null;
71+
throw new UnsupportedOperationException("Not implemented");
6772
}
6873

6974
@Override
@@ -287,7 +292,7 @@ private SQLConnection endAndStartTransaction(String command, Handler<AsyncResult
287292
private synchronized void beginTransactionIfNeeded(Handler<AsyncResult<Void>> action) {
288293
if (!inAutoCommit && !inTransaction) {
289294
inTransaction = true;
290-
ScalaUtils.scalaToVertxVoid(connection.sendQuery("BEGIN"), executionContext)
295+
ScalaUtils.scalaToVertxVoid(connection.sendQuery(getStartTransactionStatement()), executionContext)
291296
.setHandler(action);
292297
} else {
293298
action.handle(Future.succeededFuture());

src/main/java/io/vertx/ext/asyncsql/impl/MySQLConnectionImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public MySQLConnectionImpl(Connection conn, AsyncConnectionPool pool, ExecutionC
1616
super(conn, pool, ec);
1717
}
1818

19+
@Override
20+
protected String getStartTransactionStatement() {
21+
return "BEGIN";
22+
}
23+
1924
@Override
2025
protected UpdateResult queryResultToUpdateResult(QueryResult qr) {
2126
int affected = (int)qr.rowsAffected();

src/main/java/io/vertx/ext/asyncsql/impl/PostgreSQLConnectionImpl.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.github.mauricio.async.db.Connection;
44
import com.github.mauricio.async.db.QueryResult;
5-
import com.github.mauricio.async.db.mysql.MySQLQueryResult;
65
import io.vertx.core.json.JsonArray;
76
import io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool;
87
import io.vertx.ext.sql.UpdateResult;
@@ -17,6 +16,12 @@ public PostgreSQLConnectionImpl(Connection conn, AsyncConnectionPool pool, Execu
1716
}
1817

1918
@Override
19+
protected String getStartTransactionStatement() {
20+
// TODO: consider the tx isolation level
21+
return "BEGIN";
22+
}
23+
24+
@Override
2025
protected UpdateResult queryResultToUpdateResult(QueryResult qr) {
2126
int affected = (int) qr.rowsAffected();
2227
return new UpdateResult(affected, new JsonArray());

src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java

-26
Original file line numberDiff line numberDiff line change
@@ -722,32 +722,6 @@ public void testSimpleStream(TestContext context) {
722722
});
723723
}
724724

725-
private void setupTxTestTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
726-
conn.execute("BEGIN",
727-
ar -> conn.execute("DROP TABLE IF EXISTS test_txtable",
728-
ar2 -> conn.execute("CREATE TABLE test_txtable (id BIGINT, val BIGINT)",
729-
ar3 -> conn.update("INSERT INTO test_txtable (id, name) VALUES (1, 8), (2, 8)",
730-
ar4 -> conn.execute("COMMIT", handler)))));
731-
}
732-
733-
@Test
734-
public void testIsolation(TestContext context) {
735-
Async async = context.async();
736-
client.getConnection(ar -> {
737-
if (ar.failed()) {
738-
context.fail(ar.cause());
739-
return;
740-
}
741-
742-
// Create table
743-
conn = ar.result();
744-
setupTxTestTable(conn, ar2 -> {
745-
// TODO: test me!
746-
async.complete();
747-
});
748-
});
749-
}
750-
751725
private static class UserDefinedException extends RuntimeException {
752726
}
753727

0 commit comments

Comments
 (0)