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 #291

Closed
wants to merge 10 commits into from
Closed
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
  •  
  •  
  •  
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
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
<module>querydsl-sql-spatial</module>
<module>querydsl-sql-codegen</module>
<module>querydsl-sql-spring</module>
<module>querydsl-r2dbc</module>
<module>querydsl-r2dbc-codegen</module>
<module>querydsl-maven-plugin</module>
<module>querydsl-jpa</module>
<module>querydsl-jpa-codegen</module>
Expand Down Expand Up @@ -150,6 +152,7 @@
<sqlite.version>3.45.1.0</sqlite.version>
<teradata.version>13.10.00.35</teradata.version>
<firebird.version>5.0.3.java11</firebird.version>
<reactor-core.version>3.3.5.RELEASE</reactor-core.version>
<mongodb.version>3.12.14</mongodb.version>

<!-- JPA deps -->
Expand Down
9 changes: 4 additions & 5 deletions querydsl-ant-test/src/test/Test.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package test;
import java.math.BigDecimal;

import com.mysema.query.annotations.QueryEntity;

import java.math.BigDecimal;

@QueryEntity
public class Test {

private String property;
private String property;

private int intProperty;
private int intProperty;

private BigDecimal bigDecimal;
private BigDecimal bigDecimal;
}
17 changes: 8 additions & 9 deletions querydsl-apt/src/test/apt/com/querydsl/BooleanExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

public class BooleanExtensions {

@QueryDelegate(Boolean.class)
public static Predicate isFalse(BooleanPath path) {
return path.isNotNull().or(path.eq(false));
}

@QueryDelegate(Boolean.class)
public static Predicate isTrue(BooleanPath path) {
return path.eq(true);
}
@QueryDelegate(Boolean.class)
public static Predicate isFalse(BooleanPath path) {
return path.isNotNull().or(path.eq(false));
}

@QueryDelegate(Boolean.class)
public static Predicate isTrue(BooleanPath path) {
return path.eq(true);
}
}
17 changes: 8 additions & 9 deletions querydsl-apt/src/test/apt/com/querydsl/BooleanExtensions2.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

public class BooleanExtensions2 {

@QueryDelegate(boolean.class)
public static Predicate isFalse(BooleanPath path) {
return path.isNotNull().or(path.eq(false));
}

@QueryDelegate(boolean.class)
public static Predicate isTrue(BooleanPath path) {
return path.eq(true);
}
@QueryDelegate(boolean.class)
public static Predicate isFalse(BooleanPath path) {
return path.isNotNull().or(path.eq(false));
}

@QueryDelegate(boolean.class)
public static Predicate isTrue(BooleanPath path) {
return path.eq(true);
}
}
7 changes: 2 additions & 5 deletions querydsl-apt/src/test/apt/com/querydsl/ExampleEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
@QueryEntity
public class ExampleEntity {

private boolean booleanProp;

private Boolean booleanProp2;


private boolean booleanProp;

private Boolean booleanProp2;
}
2 changes: 1 addition & 1 deletion querydsl-apt/src/test/apt/com/querydsl/ExampleEntity2.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

@QueryEntity
public class ExampleEntity2 extends AbstractEntity<ExampleEntity2> {
// id inherited
// id inherited
}
10 changes: 5 additions & 5 deletions querydsl-apt/src/test/apt/com/querydsl/InnerExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

public class InnerExtensions {

public static class ExampleEntity2Extensions {
public static class ExampleEntity2Extensions {

@QueryDelegate(ExampleEntity2.class)
public static BooleanExpression isZero(QExampleEntity2 left) {
return left.id.eq(0);
}
@QueryDelegate(ExampleEntity2.class)
public static BooleanExpression isZero(QExampleEntity2 left) {
return left.id.eq(0);
}
}
}
9 changes: 5 additions & 4 deletions querydsl-apt/src/test/apt/com/querydsl/IntegerExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

public class IntegerExtensions {

@QueryDelegate(Integer.class)
public static NumberExpression<Integer> difference(NumberPath<Integer> left, NumberExpression<Integer> right) {
return right.subtract(left);
}
@QueryDelegate(Integer.class)
public static NumberExpression<Integer> difference(
NumberPath<Integer> left, NumberExpression<Integer> right) {
return right.subtract(left);
}
}
73 changes: 34 additions & 39 deletions querydsl-apt/src/test/apt/com/querydsl/eclipse/SimpleEntity.java
Original file line number Diff line number Diff line change
@@ -1,65 +1,60 @@
package com.querydsl.eclipse;

import java.math.BigDecimal;

import com.querydsl.core.annotations.QueryEntity;
import java.math.BigDecimal;

@QueryEntity
public class SimpleEntity {

CustomComparable comparableProp;

CustomNumber customNumber;
CustomComparable comparableProp;

int intProp;
CustomNumber customNumber;

Integer integerProp;
int intProp;

BigDecimal bigDecimalProp;
Integer integerProp;

String stringProp;
BigDecimal bigDecimalProp;

SimpleEntity entityProp;
String stringProp;

SimpleEntity entityProp;
}

class CustomComparable implements Comparable<CustomComparable> {

@Override
public int compareTo(CustomComparable o) {
return 0;
}

@Override
public int compareTo(CustomComparable o) {
return 0;
}
}

class CustomNumber extends Number implements Comparable<CustomNumber> {

private static final long serialVersionUID = 8683978836725543780L;

@Override
public double doubleValue() {
return 0;
}
private static final long serialVersionUID = 8683978836725543780L;

@Override
public float floatValue() {
return 0;
}
@Override
public double doubleValue() {
return 0;
}

@Override
public int intValue() {
return 0;
}
@Override
public float floatValue() {
return 0;
}

@Override
public long longValue() {
return 0;
}
@Override
public int intValue() {
return 0;
}

@Override
public int compareTo(CustomNumber o) {
return 0;
}
@Override
public long longValue() {
return 0;
}


}
@Override
public int compareTo(CustomNumber o) {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public class AnnotationTest {
public void ClassAnnotation() throws IOException {
writer.annotation(getClass().getAnnotation(Annotation.class));
String option1 =
"@com.querydsl.codegen.utils.Annotation(clazz=com.querydsl.codegen.utils.AnnotationTest.class, prop2=false)";
"@com.querydsl.codegen.utils.Annotation(clazz=com.querydsl.codegen.utils.AnnotationTest.class,"
+ " prop2=false)";
String option2 =
"@com.querydsl.codegen.utils.Annotation(prop2=false, clazz=com.querydsl.codegen.utils.AnnotationTest.class)";
"@com.querydsl.codegen.utils.Annotation(prop2=false,"
+ " clazz=com.querydsl.codegen.utils.AnnotationTest.class)";
String serialized = w.toString().trim();
assertThat(serialized.equals(option1) || serialized.equals(option2)).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public void ComplexClassLoading() {
StringBuilder source = new StringBuilder();
source.append("java.util.List<Object[]> rv = new java.util.ArrayList<Object[]>();\n");
source.append(
"for (com.querydsl.codegen.utils.support.Cat cat : (java.util.List<com.querydsl.codegen.utils.support.Cat>)cat_){\n");
"for (com.querydsl.codegen.utils.support.Cat cat :"
+ " (java.util.List<com.querydsl.codegen.utils.support.Cat>)cat_){\n");
source.append(
"for (com.querydsl.codegen.utils.support.Cat otherCat : (java.util.List<com.querydsl.codegen.utils.support.Cat>)otherCat_){\n");
"for (com.querydsl.codegen.utils.support.Cat otherCat :"
+ " (java.util.List<com.querydsl.codegen.utils.support.Cat>)otherCat_){\n");
source.append("rv.add(new Object[]{cat,otherCat});\n");
source.append("}\n");
source.append("}\n");
Expand Down Expand Up @@ -106,7 +108,8 @@ public void ComplexClassLoadingFailure() {
ClassType resultType = new ClassType(TypeCategory.LIST, List.class, Types.STRING);
StringBuilder source = new StringBuilder();
source.append(
"java.util.List<String> rv = (java.util.List<String>) new java.util.ArrayList<Franklin>();\n");
"java.util.List<String> rv = (java.util.List<String>) new"
+ " java.util.ArrayList<Franklin>();\n");
source.append("for (String a : a_){\n");
source.append(" for (String b : b_){\n");
source.append(" if (a.equals(b)){\n");
Expand Down Expand Up @@ -177,7 +180,8 @@ public void ComplexEmbeddedClass() {
source.append(" }\n");
source.append("}\n");
source.append(
"return rv;} private static class TestEmbedded { public TestEmbedded() {} public boolean DO_RETURN() { return true; } ");
"return rv;} private static class TestEmbedded { public TestEmbedded() {} public boolean"
+ " DO_RETURN() { return true; } ");

@SuppressWarnings("rawtypes") // cannot specify further than List.class
Evaluator<List> evaluator =
Expand Down Expand Up @@ -207,9 +211,11 @@ public void ComplexDifferentConstants() {
String source =
new StringBuilder()
.append(
"java.util.List<com.querydsl.codegen.utils.support.Cat> rv = new java.util.ArrayList<com.querydsl.codegen.utils.support.Cat>();\n")
"java.util.List<com.querydsl.codegen.utils.support.Cat> rv = new"
+ " java.util.ArrayList<com.querydsl.codegen.utils.support.Cat>();\n")
.append(
"for (com.querydsl.codegen.utils.support.Cat cat : (java.util.List<com.querydsl.codegen.utils.support.Cat>)cat_){\n")
"for (com.querydsl.codegen.utils.support.Cat cat :"
+ " (java.util.List<com.querydsl.codegen.utils.support.Cat>)cat_){\n")
.append("if (cat.equals(a1)) {\n")
.append("rv.add(cat);\n")
.append("}\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public void CustomHeader() throws IOException {
// "ID");
// }
writer.beginClass(
"QDepartment(path: String) extends RelationalPathBase[QDepartment](classOf[QDepartment], path)");
"QDepartment(path: String) extends RelationalPathBase[QDepartment](classOf[QDepartment],"
+ " path)");
writer.publicFinal(Types.OBJECT, "id", "createNumber(\"ID\", classOf[Integer])");
writer.publicFinal(Types.OBJECT, "company", "createNumber(\"COMPANY\", classOf[Integer])");
writer.publicFinal(Types.OBJECT, "idKey", "createPrimaryKey(id)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public void resolve2() {
Type type = factory.getEntityType(AbstractCollectionAttribute.class);
assertThat(type.getGenericName(false))
.isEqualTo(
"com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>");
"com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends"
+ " java.util.Collection<?>>");
assertThat(type.getGenericName(true))
.isEqualTo(
"com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>");
"com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends"
+ " java.util.Collection<?>>");
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions querydsl-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<artifactId>classgraph</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor-core.version}</version>
</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();
}
Loading
Loading