Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R2DBC support @riba2101 #292

Merged
merged 19 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
- run:
name: 'Test'
command: |
./mvnw -ntp -B install -Pquickbuild -pl :querydsl-sql-spring,:querydsl-jpa-spring,:querydsl-kotlin-codegen,:querydsl-mongodb -am -T2
./mvnw -ntp -B install -Pquickbuild -pl :querydsl-sql-spring,:querydsl-jpa-spring,:querydsl-kotlin-codegen,:querydsl-mongodb,:querydsl-r2dbc -am -T2
./mvnw -ntp -B verify -Pexamples -rf :querydsl-examples
- save-test-results
buildQuarkusExample:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ derby.log
/devops/test-connection/.lein-repl-history
**/.flattened-pom.xml

.java-version
.gitignore
.checkstyle

Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<module>querydsl-sql-spatial</module>
<module>querydsl-sql-codegen</module>
<module>querydsl-sql-spring</module>
<module>querydsl-r2dbc</module>

<module>querydsl-jpa</module>
<module>querydsl-jpa-codegen</module>
Expand Down Expand Up @@ -155,6 +156,8 @@
<firebird.version>5.0.3.java11</firebird.version>
<mongodb.version>3.12.14</mongodb.version>

<r2dbc.version>1.0.0.RELEASE</r2dbc.version>

<!-- JPA deps -->
<hibernate.version>6.4.4.Final</hibernate.version>
<hibernate.validator.version>8.0.1.Final</hibernate.validator.version>
Expand Down Expand Up @@ -294,6 +297,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bom</artifactId>
<version>2023.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
4 changes: 4 additions & 0 deletions querydsl-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<artifactId>classgraph</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>

<!-- alias dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.querydsl.core;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
* {@code ReactiveFetchable} defines default projection methods for {@link Query} implementations.
* All Querydsl query implementations should implement this interface.
*
* @param <T> result type
*/
public interface ReactiveFetchable<T> {

/**
* Get the projection as a typed Flux.
*
* @return result
*/
Flux<T> fetch();

/**
* Get the first result of the projection.
*
* @return first result
*/
Mono<T> fetchFirst();

/**
* Get the projection as a unique result.
*
* @return first result
*/
Mono<T> fetchOne();

/**
* Get the count of matched elements
*
* @return row count
*/
Mono<Long> fetchCount();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.querydsl.core;

import com.querydsl.core.types.Expression;
import org.reactivestreams.Publisher;

/**
* {@code FetchableQuery} extends {@link ReactiveFetchable} and {@link SimpleQuery} with projection
* changing methods and result aggregation functionality using {@link ResultTransformer} instances.
*
* @param <T> element type
* @param <Q> concrete subtype
*/
public interface ReactiveFetchableQuery<T, Q extends ReactiveFetchableQuery<T, Q>>
extends SimpleQuery<Q>, ReactiveFetchable<T> {

/**
* Change the projection of this query
*
* @param <U>
* @param expr new projection
* @return the current object
*/
<U> ReactiveFetchableQuery<U, ?> select(Expression<U> expr);

/**
* Change the projection of this query
*
* @param exprs new projection
* @return the current object
*/
ReactiveFetchableQuery<Tuple, ?> select(Expression<?>... exprs);

/**
* Apply the given transformer to this {@code ReactiveFetchableQuery} instance and return the
* results
*
* @param <S>
* @param transformer result transformer
* @return transformed result
*/
<S> Publisher<S> transform(ReactiveResultTransformer<S> transformer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.querydsl.core;

import org.reactivestreams.Publisher;

/**
* Executes query on a {@link ReactiveFetchableQuery} and transforms results into T. This can be
* used for example to group projected columns or to filter out duplicate results.
*
* @param <T> Transformations target type
* @author sasa
* @see com.querydsl.core.group.GroupBy
*/
public interface ReactiveResultTransformer<T> {

/**
* Execute the given query and transform the results
*
* @param query query to be used for execution
* @return transformed results
*/
Publisher<T> transform(ReactiveFetchableQuery<?, ?> query);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.querydsl.core.dml;

import reactor.core.publisher.Mono;

/**
* Parent interface for DML clauses
*
* @param <C> concrete subtype
*/
public interface ReactiveDMLClause<C extends ReactiveDMLClause<C>> {

/**
* Execute the clause and return the amount of affected rows
*
* @return amount of affected rows or empty if not available
*/
Mono<Long> execute();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.querydsl.core.dml;

/**
* {@code ReactiveDeleteClause} defines a generic interface for Delete clauses
*
* @param <C> concrete subtype
*/
public interface ReactiveDeleteClause<C extends ReactiveDeleteClause<C>>
extends ReactiveDMLClause<C>, ReactiveFilteredClause<C> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.querydsl.core.dml;

import com.querydsl.core.types.Predicate;

/**
* {@code ReactiveFilteredClause} is an interface for clauses with a filter condition
*
* @param <C> concrete subtype
*/
public interface ReactiveFilteredClause<C extends ReactiveFilteredClause<C>> {

/**
* Adds the given filter conditions
*
* <p>Skips null arguments
*
* @param o filter conditions to be added
* @return the current object
*/
C where(Predicate... o);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.querydsl.core.dml;

import com.querydsl.core.types.Path;
import com.querydsl.core.types.SubQueryExpression;

/**
* {@code ReactiveInsertClause} defines a generic interface for Insert clauses
*
* @param <C> concrete subtype
*/
public interface ReactiveInsertClause<C extends ReactiveInsertClause<C>>
extends ReactiveStoreClause<C> {

/**
* Define the columns to be populated
*
* @param columns columns to be populated
* @return the current object
*/
C columns(Path<?>... columns);

/**
* Define the populate via subquery
*
* @param subQuery sub query to be used for population
* @return the current object
*/
C select(SubQueryExpression<?> subQuery);

/**
* Define the value bindings
*
* @param v values to be inserted
* @return the current object
*/
C values(Object... v);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.querydsl.core.dml;

import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
import org.jetbrains.annotations.Nullable;

/**
* Parent interface for {@link ReactiveInsertClause} and {@link ReactiveUpdateClause}
*
* @param <C> concrete subtype
*/
public interface ReactiveStoreClause<C extends ReactiveStoreClause<C>>
extends ReactiveDMLClause<C> {

/**
* Add a value binding
*
* @param <T>
* @param path path to be updated
* @param value value to set
* @return the current object
*/
<T> C set(Path<T> path, @Nullable T value);

/**
* Add an expression binding
*
* @param <T>
* @param path path to be updated
* @param expression binding
* @return the current object
*/
<T> C set(Path<T> path, Expression<? extends T> expression);

/**
* Bind the given path to null
*
* @param path path to be updated
* @return the current object
*/
<T> C setNull(Path<T> path);

/**
* Returns true, if no bindings have been set, otherwise false.
*
* @return true, if empty, false, if not
*/
boolean isEmpty();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.querydsl.core.dml;

import com.querydsl.core.types.Path;
import java.util.List;

/**
* {@code ReactiveUpdateClause} defines a generic extensible interface for Update clauses
*
* @param <C> concrete subtype
*/
public interface ReactiveUpdateClause<C extends ReactiveUpdateClause<C>>
extends ReactiveStoreClause<C>, ReactiveFilteredClause<C> {

/**
* Set the paths to be updated
*
* @param paths paths to be updated
* @param values values to be set
* @return the current object
*/
C set(List<? extends Path<?>> paths, List<?> values);
}
9 changes: 7 additions & 2 deletions querydsl-core/src/main/java/com/querydsl/core/group/GAvg.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
import java.math.BigDecimal;
import java.math.MathContext;

/**
* GAvg
*
* @param <T> t
*/
@SuppressWarnings("unchecked")
class GAvg<T extends Number> extends AbstractGroupExpression<T, T> {
public class GAvg<T extends Number> extends AbstractGroupExpression<T, T> {

private static final long serialVersionUID = 3518868612387641383L;

private final MathContext mathContext;

GAvg(Expression<T> expr) {
public GAvg(Expression<T> expr) {
this(expr, MathContext.DECIMAL128);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
import java.util.ArrayList;
import java.util.List;

class GList<T> extends AbstractGroupExpression<T, List<T>> {
/**
* GList
*
* @param <T> t
*/
public class GList<T> extends AbstractGroupExpression<T, List<T>> {

private static final long serialVersionUID = -5613861506383727078L;

GList(Expression<T> expr) {
public GList(Expression<T> expr) {
super(List.class, expr);
}

Expand Down
Loading
Loading