Skip to content

Commit fd5adb1

Browse files
committed
Merge pull request #45 from vert-x3/add-numeric-fields-test
Add numeric fields test
2 parents 246815f + 1621a28 commit fd5adb1

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<properties>
1919
<stack.version>3.3.0-SNAPSHOT</stack.version>
2020
<scala.version>2.11.4</scala.version>
21-
<asyncdriver.version>0.2.18</asyncdriver.version>
21+
<asyncdriver.version>0.2.19</asyncdriver.version>
2222

2323
<host>localhost</host>
2424
</properties>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.github.mauricio.async.db.Configuration;
2020
import com.github.mauricio.async.db.Connection;
21+
import com.github.mauricio.async.db.SSLConfiguration;
2122
import io.netty.buffer.PooledByteBufAllocator;
2223
import io.vertx.core.AsyncResult;
2324
import io.vertx.core.Future;
@@ -29,6 +30,7 @@
2930
import io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool;
3031
import io.vertx.ext.sql.SQLConnection;
3132
import scala.Option;
33+
import scala.collection.Map$;
3234
import scala.concurrent.ExecutionContext;
3335
import scala.concurrent.duration.Duration;
3436

@@ -116,7 +118,13 @@ protected Configuration getConfiguration(
116118
Option.empty() : Option.apply(Duration.apply(queryTimeout, TimeUnit.MILLISECONDS));
117119

118120
log.info("Creating configuration for " + host + ":" + port);
119-
return new Configuration(username, host, port, Option.apply(password), Option.apply(database),
121+
return new Configuration(
122+
username,
123+
host,
124+
port,
125+
Option.apply(password),
126+
Option.apply(database),
127+
SSLConfiguration.apply(Map$.MODULE$.empty()),
120128
charset,
121129
16777216,
122130
PooledByteBufAllocator.DEFAULT,

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,35 @@ public void queryTypeTimestampWithoutTimezoneTest(TestContext context) throws Ex
9797
});
9898
}
9999

100+
@Test
101+
public void testUpdatingNumericField(TestContext context) {
102+
Async async = context.async();
103+
client.getConnection(ar -> {
104+
ensureSuccess(context, ar);
105+
conn = ar.result();
106+
conn.execute("DROP TABLE IF EXISTS test_table", ar1 -> {
107+
ensureSuccess(context, ar1);
108+
conn.execute("CREATE TABLE test_table (id BIGSERIAL, numcol NUMERIC)", ar2 -> {
109+
ensureSuccess(context, ar2);
110+
conn.query("INSERT INTO test_table DEFAULT VALUES RETURNING id", ar3 -> {
111+
ensureSuccess(context, ar3);
112+
System.out.println("result: " + ar3.result().toJson().encode());
113+
final long id = ar3.result().getResults().get(0).getLong(0);
114+
conn.updateWithParams("UPDATE test_table SET numcol = ? WHERE id = ?", new JsonArray().add(1234).add(id), ar4 -> {
115+
ensureSuccess(context, ar4);
116+
conn.updateWithParams("UPDATE test_table SET numcol = ? WHERE id = ?", new JsonArray().addNull().add(id), ar5 -> {
117+
ensureSuccess(context, ar5);
118+
conn.updateWithParams("UPDATE test_table SET numcol = ? WHERE id = ?", new JsonArray().add(123.123).add(id), ar6 -> {
119+
ensureSuccess(context, ar6);
120+
121+
async.complete();
122+
});
123+
});
124+
});
125+
});
126+
});
127+
});
128+
});
129+
}
130+
100131
}

0 commit comments

Comments
 (0)