r2dbc / r2dbc-client Goto Github PK
View Code? Open in Web Editor NEWReactive Relational Database Connectivity
License: Apache License 2.0
Reactive Relational Database Connectivity
License: Apache License 2.0
Update MssqlExample
to use ConnectionFactory
discovery.
Update H2Example
to use ConnectionFactory
discovery.
The Javadoc of R2dbc
mentions postgresql explicitly. This is probably outaded:
When reading and mapping data into objects, it's common to have types which differ between the model and its persistent representation. We should have a method to read values and let the driver determine the data type.
Note: Ideally, we have Row.get(String identifier)
and Row.get(int index)
methods to tighten up the API contract and resolve ambiguities over the identifier.
As example:
List<Integer> age = new ArrayList(); age.add(10); age.add(20); age.add(30); r2dbc .withHandle(handle -> handle.select("select * from persons where age in ($1)") .bind("$1", ) .mapResult(result -> result.map(toWrapper())));
R2DBC started as an experiment to evaluate whether reactive programming and SQL databases can work together. R2DBC Client emerged as an artifact to make R2DBC usable without the need to use the SPI directly. A library that is providing higher-level abstraction, which is taking care of resource handling and a more humane API.
With the growth of drivers and the adoption of R2DBC in the Java eco-system, R2DBC Client deserves a place where it can evolve and reside in a maintained state. R2DBC is not opinionated about clients and client design in particular. Maintaining R2DBC Client by the R2DBC team and within the R2DBC organization influences how client library development is perceived.
R2DBC has a neutral position regarding client library design.
Therefore we want to transition R2DBC client into a new home that allows for the development and evolution of the client inspired by JDBI.
Couple of questions
Spec Update
While playing around with r2dbc, I wanted to read the returned results from an INSERT. Given the table TEST
with columns ID
and DESCRIPTION
, when insert a row like this (postgres):
handle.execute("INSERT INTO TEST VALUES (1$, $2) RETURNING ID", 1, "bla")
I found out that that execute()
always maps the result into an integer that shows the number of affected rows. I was wishing to be able to read the result of the query. I am aware that not all databases supports RETURNING
in INSERT
being able to access the result using .mapResult
or .map
An alternative way to get the ID is to pre-set from the provided value. Another solution for sequence id is to read them using a select query before executing the INSERT
statement
Reading a row in which a field contains a null value fails with
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Optional.<init>(Optional.java:96)
at java.util.Optional.of(Optional.java:108)
at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:193)
at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:190)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at com.nebhale.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:82)
at com.nebhale.r2dbc.postgresql.PostgresqlRow.get(PostgresqlRow.java:84)
at org.springframework.data.jdbc.core.function.EntityRowMapper.readFrom(EntityRowMapper.java:102)
... 94 more
I read "r2dbc-client - client using pure Reactor (i.e. no Spring dependencies)." That fits quite well my problem. We have reactive stack but the data come from blocking database (Oracle). The problem is I see Spring-data for reactive approaches still not in release mode and it causes me issue while moving to production. The problem is that all example I have found from r2dbc-client uses somehow spring-data. Our microservices are bases in Spring world but I can't use any dependeny not delivery yet.
Your example from https://github.com/r2dbc/r2dbc-client seems still depending on Spring Data (PostgresqlConnectionConfiguration). I have nothing against Spring Data but I will be blocked from moving to production if the pom has milestone versions (not definitely release I mean).
Cancellation of stream created with R2dbc.withHandle
does not close the Handle
. This often happens when transforming Flux
to Mono
with Flux.next()
.
Related code snippet on master
branch
Currently the r2dbc-spi project only requires org.reactive-streams at the API level, and a DB vendor may implement the SPI using any RS implementation they choose.
However, r2dbc-client defines a hard dependency on reactor-core. This is unfortunate because r2dbc-client itself is a pretty lightweight wrapper around the SPI. All of the leg-work seems to be done by the SPI implementation. If I was using an SPI implementation where the DB vendor implementation chose Akka Streams or RxJava as their RS implementation, it would be nice to not have to pull in Reactor Core (a 1.5MB dependency) to do the client-level wrapper logic.
It would probably be overkill to put r2dbc-client APIs behind RS-impl agnostic interfaces, so I was wondering if the R2DBC folks would be open to the idea of alternative r2dbc client libraries that used different RS impls, such as r2dbc-client-rxjava
or r2dbc-client-akka
under the r2dbc org?
The current version in README.md , 1.0.0.M3 , no longer exists in the milestone repository anymore (https://repo.spring.io/milestone/io/r2dbc/r2dbc-client/).
Is there a possibility of AS400/DB2 support being introduced?
Thank you
In project reactor if you don't subscribe to a stream, nothing happens. This is fine if we are reading data, but is very un-intuitive if we are writing data to a database, where we typically don't care about any sort of feedback (unless an exception has been thrown).
Consider the following code example:
R2dbc r2dbc = // ...
r2dbc.inTransaction(handle -> handle.execute("INSERT INTO test VALUES ($1)", 100));
With the above code, it looks like we are inserting some data into a table, but nothing goes into the DB until we subscribe to the writer operation in some way, such as:
R2dbc r2dbc = // ...
r2dbc.inTransaction(handle -> handle.execute("INSERT INTO test VALUES ($1)", 100))
.subscribe();
In JDBC we have two different operations for reads and writes (Statement.executeQuery()
and Statement.executeUpdate()
respectively), so perhaps we could do something similar in R2DBC? The difference being that read operations still need to be subscribed to, but write operations do not require a subscription.
Update PostgresqlExample
to use ConnectionFactory
discovery.
ConnectionFactory
should expose a product name, ideally as part of driver-metadata. Optionally, the metadata could also expose server-metadata.
The product name is a useful detail when configuring SQLErrorCodeSQLExceptionTranslator
.
r2dbc-mysql
groupId has changed from com.github.mirromuth
to dev.miku
and it is being deployed to https://oss.sonatype.org/content/repositories/snapshots/.
thank you!
We should introduce a base exception that allows structured representation of the SQL errors.
Due to differences between r2dbc's and Jasync's versions of Netty, remove it from the client.
Microsoft?
The Example
s in the client should exercise the Blob/Clob functionality. It should be pretty straight forward to transport from r2dbc-spi
's `Example.
The Statement
API should accept null
bindings using an integer index.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.