Commit Graph

112 Commits

Author SHA1 Message Date
Mark Paluch
a67db9f88a #107 - Polishing.
Adapt tests to changed behavior of TransactionalOperator.
2019-09-28 15:35:26 +02:00
Mark Paluch
fd66f8af26 #178 - Consider named and indexed parameters for named parameter processing.
Named parameters can be provided by name and by index. Repository query methods bind parameters by name if a named parameter can be found.

If parameters are bound by index, then the parameter name is looked up by index (index corresponds with the order of parameter name discovery when parsing the query). and bound to the parameter.
2019-09-20 15:50:36 +02:00
Mark Paluch
2668ecb702 #185 - Re-enable Postgres integration tests. 2019-09-17 16:21:03 +02:00
Mark Paluch
7362b45156 #188 - Adapt to package changes in r2dbc-mysql. 2019-09-14 21:37:19 +02:00
Mark Paluch
cefd3fc527 #185 - Re-enable Postgres integration tests. 2019-09-13 17:22:21 +02:00
Mark Paluch
1096838dec #186 - Consider byte[] binary data when mapping entities.
We now exclude byte[] properties from being mapped to array types. To map data to a 1-dimensional BYTE[] Postgres type, properties can be declared as Collection<Byte> or Byte[].
2019-09-13 14:34:00 +02:00
Mark Paluch
63310031cb #177 - Add tests for NOT IN. 2019-09-11 16:41:37 +02:00
Mark Paluch
353a7e7037 #184 - Polishing.
Disable MySQL SSL to avoid warning logging.
2019-09-11 16:10:22 +02:00
Mark Paluch
ddef57af63 #184 - Restore AutoCommit and IsolationLevel after transaction. 2019-09-11 16:05:58 +02:00
Mark Paluch
62656668ea #185 - Disable Postgres integration tests.
Disabling until r2dbc/r2dbc-postgresql#151 is resolved.
2019-09-11 16:05:41 +02:00
Mark Paluch
fa64006441 #183 - Use Statement.bind(String) and Row.get(String) methods instead of bind(Object). 2019-09-11 15:38:38 +02:00
Mark Paluch
f7b3e96238 #182 - Build against R2DBC 0.8 snapshots.
Disable JAsync tests until JAsync catches up with R2DBC SPI 0.8.
2019-09-11 15:38:21 +02:00
Mark Paluch
084273f026 #161 - Polishing.
Properly convert null arrays to the corresponding, driver-supported array type.
2019-09-05 15:12:28 +02:00
Mark Paluch
611b73149b #161 - Properly convert arrays for Postgres.
We now properly convert array values (single- and multi-dimensional) when inserting rows with arrays.
2019-09-05 15:01:10 +02:00
Sebastien Deleuze
9064b04110 #172 - Upgrade to Coroutines 1.3.0.
Original pull request: #173.
2019-09-04 11:55:42 +02:00
Mark Paluch
af52bc1a53 #169 - Polishing.
Move R2dbcMappingContextUnitTests to correct source folder.
2019-09-03 16:27:12 +02:00
Mark Paluch
30c5e2f5e0 #162 - Refine declaration of nullable values in DatabaseClient.
DatabaseClient.BindSpec.bind(…) (execute) and DatabaseClient.GenericInsertSpec.value(…) (insert) now consistently accept SettableValue for scalar and absent values.

This change allows us to provide a Kotlin extension leveraging reified generics to provide the type of a value even if it is null to construct an appropriate SettableValue for fluent API usage.
2019-09-03 16:23:48 +02:00
Mark Paluch
bac5c343b7 #169 - Allow usage of Entity-level converters.
We now support Converters on Entity-level if object materialization/dematerialization is handled by application code. We're using a custom R2DBC MappingContext to create mapping metadata for types that have custom converters registered.
2019-09-03 14:25:02 +02:00
Mark Paluch
501d4475e3 #159 - Polishing.
Update tests to work around known issues in type conversion and transaction synchronization.
2019-09-03 12:39:56 +02:00
Mark Paluch
bc9627e987 #159 - Skip result conversion for query methods returning Void. 2019-09-03 12:18:44 +02:00
Mark Paluch
ec8f540ed9 #166 - Polishing.
Consider Dialect-specific converters also in DatabaseClient.create(…) factory. Reduce constant visibility. Add tests. Reformat code.

Original pull request: #168.
2019-09-03 11:59:39 +02:00
Mark Paluch
e15e6b19d4 #163 - Add tests for R2DBC MySQL. 2019-08-15 12:22:56 +02:00
Mark Paluch
861a2b194f #148 - Consider sorting of PageRequest.
Issuing a paged SELECT with paging now considers the Sort order of PageRequest.
2019-07-16 12:00:05 +02:00
Mark Paluch
929c4dfab4 #138 - Allow multiple usages of the same named parameter.
We now allow multiple usages of the same named parameter if the underlying database supports identifiable placeholders.

SELECT * FROM person where name = :id or lastname = :id

gets translated to

SELECT * FROM person where name = $1 or lastname = $1
2019-07-15 16:39:27 +02:00
Mark Paluch
7403651ba3 #103 - Coroutines extensions throw proper EmptyResultDataAccessException.
RowsFetchSpec.awaitOne() and RowsFetchSpec.awaitFirst() now throw EmptyResultDataAccessException instead of NoSuchElementException to consistently use Spring DAO exceptions.
2019-07-15 14:17:39 +02:00
Mark Paluch
3c3277eac4 #124 - Remove deprecated DatabaseClient.execute().sql(…) and TransactionalDatabaseClient. 2019-07-15 13:39:23 +02:00
Mark Paluch
b1e97035f2 #140 - Polishing.
Reduce assertions on numeric fields to contain a Number subtype.
2019-07-12 15:39:11 +02:00
Mark Paluch
776044de2b #140 - Accept simple mapping function for Row in DatabaseClient.
We now accept a Function<Row, T> in DatabaseClient's map(…) operator to simplify mapping by not requiring RowMetadata.
2019-07-12 15:39:11 +02:00
Mark Paluch
82aad7c4f5 #141 - Add support for schema initialization.
We now provide DatabasePopulator and ScriptUtils to run SQL scripts using R2DBC Connections to initialize and clean up databases.
2019-06-22 20:57:07 +02:00
Mark Paluch
0d5f5089be #135 - Adapt to renamed TransactionSynchronizationManager.forCurrentTransaction(). 2019-06-05 14:35:16 +02:00
Mark Paluch
bedc18bc69 #105 - Move named parameter resolution to ReactiveDataAccessStrategy.
Named parameter resolution is now provided as part of ReactiveDataAccessStrategy. This allows us to hide implementation internals (bind markers). DatabaseClient allows configuration whether to use named parameter expansion.

Detailed configuration of named parameter support is now moved to DefaultReactiveDataAccessStrategy.

Original pull request: #105.
2019-06-04 14:34:35 +02:00
Jens Schauder
7372efe3e6 #98 - Polishing.
Formatting.
Changed generics to avoid unchecked casting.
Avoided abbreviated variable name.
Simplified handling of absent keys at ConnectionFactory lookup.

Original pull request: #132.
2019-06-04 11:53:06 +02:00
Mark Paluch
e3aae619f4 #98 - Add support for AbstractRoutingConnectionFactory.
We now provide an abstract base class for ConnectionFactory routing. Routing keys are typically obtained from a subscriber context. AbstractRoutingConnectionFactory is backed by either a map of string identifiers or connection factories. When using string identifiers, these can map agains e.g. Spring bean names that can be resolved using BeanFactoryConnectionFactoryLookup.

class MyRoutingConnectionFactory extends AbstractRoutingConnectionFactory {

		@Override
		protected Mono<Object> determineCurrentLookupKey() {
			return Mono.subscriberContext().filter(it -> it.hasKey(ROUTING_KEY)).map(it -> it.get(ROUTING_KEY));
		}
}

@Bean
public void routingConnectionFactory() {

		MyRoutingConnectionFactory router = new MyRoutingConnectionFactory();

		Map<String, ConnectionFactory> factories = new HashMap<>();
		ConnectionFactory myDefault = …;
		ConnectionFactory primary = …;
		ConnectionFactory secondary = …;

		factories.put("primary", primary);
		factories.put("secondary", secondary);

		router.setTargetConnectionFactories(factories);
		router.setDefaultTargetConnectionFactory(myDefault);

		return router;
}

Original pull request: #132.
2019-06-04 11:52:32 +02:00
Mark Paluch
043e8a6855 #104 - Provide extension mechanism for R2dbcDialect resolution.
We now use Spring's spring.factories mechanism to register and lookup R2dbcDialectProvider implementations.
This allows a pluggable model for third party implementations to ship R2dbcDialect support that can be auto-discovered.

Original pull request: #127.
2019-05-27 17:11:29 +02:00
Mark Paluch
376bfef387 #128 - Fix NullPointerException calling bindNull() with enabled named parameter support. 2019-05-23 10:09:31 +02:00
Mark Paluch
d4a06a781c #87 - Consistently use RowMetadata.
We now apply row metadata checks also for property population.
2019-05-22 15:50:02 +02:00
Mark Paluch
e03d1dc8ee #55 - Polishing.
Original pull request: #125.
2019-05-22 14:21:52 +02:00
Mark Paluch
32f1770529 #55 - Reuse Dialect support provided by Spring Data Relational.
We now reuse the existing Dialect infrastructure provided by Spring Data Relational to enhance it for R2DBC specifics such as bind markers.

Original pull request: #125.
2019-05-22 14:21:43 +02:00
Mark Paluch
46082147d3 #69 - Allow object creation with a subset of columns.
We now allow object creation when not all columns are present by leveraging R2DBC RowMetadata. A column subset is necessary for projections.
2019-05-22 09:41:23 +02:00
Mark Paluch
972bc09606 #122 - Polishing.
Add extension for UpdateTableSpec.table. Add tests. Formatting.

Original pull request: #123.
2019-05-21 15:53:18 +02:00
Jonas Bark
9bcaa24707 #122 - Improve Kotlin extensions for CriteriaStep and DatabaseClient.
Original pull request: #123.
2019-05-21 15:53:08 +02:00
Mark Paluch
8b77aa9431 #89 - Accept SQL directly in DatabaseClient.execute(…) stage.
We compressed client.execute().sql(…) to client.execute(…) to not require the intermediate execute() step but rather accept the SQL to execute directly.

Original pull request: #112.
2019-05-21 14:02:45 +02:00
Mark Paluch
430d984503 #109 - Fix simple type conversion for projection queries.
We now correctly consider built-in converters for simple types that are read through DatabaseClient. Simple type projections typically select a single column and expect a result stream of simple values such as selecting a count and retrieving a Mono<Long>.
2019-05-14 09:35:46 +02:00
Oliver Drotbohm
c456af0d2a #111 - Package and type renames.
Package renames:

- `….domain` -> `….mapping`
- `….function.connectionfactory` -> `connectionfactory`
- `….function.convert` -> `convert`
- `….function.query` -> `query`
- `….function` -> `….core`

Type moves:

- `….dialect.R2dbcSimpleTypeHolder` -> `….mapping.R2dbcSimpleTypeHolder`
- `….mapping.BindTarget` -> `….dialect.BindTarget`
- `….mapping.PreparedOperation` -> `….core.PreparedOperation`
- `….mapping.QueryOperation` -> `….core.QueryOperation`
- `….mapping.BindOperation` -> `….core.BindOperation`
- `….connectionfactory.ConnectionFactoryTransactionManager` -> `….connectionfactory.R2dbcTransactionManager`

That makes us end up with:

- `connectionfactory`
- `core` -> `connectionfactory`, `convert`, `dialect`, `mapping`, `query`
- `query` -> `convert`, `dialect`, `mapping`
- `convert` -> `dialect`, `mapping`
- `dialect` -> `mapping`
- `mapping` -> Spring Data Commons mapping

Reflect type renames in reference documentation.
2019-05-09 18:11:55 +02:00
Christoph Strobl
988b31b33a #107 - Polishing.
Extract method references for better readability. Add missing tests and update documentation.
Add delay for transactional MySql tests to avoid failures due to potentially delayed transaction id storage within the database.

Original Pull Request: #107
2019-05-09 08:26:07 +02:00
Mark Paluch
79e32941b5 #107 - Add support for ConnectionFactoryTransactionManager.ConnectionFactoryTransactionManager.
We now support R2DBC transaction management through ConnectionFactoryTransactionManager which is a ReactiveTransactionManager implementation to be used with TransactionalOperator and Spring's declarative transaction management.

ConnectionFactoryTransactionManager tm = new ConnectionFactoryTransactionManager(connectionFactory);
TransactionalOperator operator = TransactionalOperator.create(tm);
DatabaseClient db = DatabaseClient.create(connectionFactory);

Mono<Void> atomicOperation = db.execute().sql("INSERT INTO person (id, name, age) VALUES(:id, :name, :age)")
            .bind("id", "joe")
            .bind("name", "Joe")
            .bind("age", 34)
            .fetch().rowsUpdated()
            .then(db.execute().sql("INSERT INTO contacts (id, name) VALUES(:id, :name)")
                    .bind("id", "joe")
                    .bind("name", "Joe")
                    .fetch().rowsUpdated())
            .then()
            .as(operator::transactional);

Original Pull Request: #107
2019-05-09 07:56:23 +02:00
Oliver Drotbohm
da53a9a934 #64 - Polishing.
Incorporated feedback from review. Polished documentation and Javadoc. Minor code improvements restructuring for better readability. Removed unused methods types. Some polishing for compiler warnings.

Original pull request: #106.
2019-05-08 10:45:30 +02:00
Mark Paluch
774d2e8b09 #64 - API polishing.
Document fluent API. Add fluent API for update. Introduce StatementMapper. Migrate Insert to StatementMapper. Refactoring and cleanup. Migrate Select to StatementMapper.

Original pull request: #106.
2019-05-08 10:45:30 +02:00
Mark Paluch
fd4472aaaa #64 - Add Criteria API.
We now support Criteria creation and mapping to express where conditions with a fluent API.

databaseClient.select().from("legoset")
  .where(Criteria.of("name").like("John%").and("id").lessThanOrEquals(42055));

databaseClient.delete()
  .from(LegoSet.class)
  .where(Criteria.of("id").is(42055))
  .then()

databaseClient.delete()
  .from(LegoSet.class)
  .where(Criteria.of("id").is(42055))
  .fetch()
  .rowsUpdated()

Original pull request: #106.
2019-05-08 10:45:30 +02:00
Mark Paluch
88945d7d71 #73 - Introduce BindTarget.
We now apply bindings to a BindTarget that can be overridden without the need to implement all Statement methods.

PreparedOperation no longer has a direct dependency on R2DBC Statement.

Original pull request: #82.
2019-05-06 13:50:36 +02:00