diff --git a/README.md b/README.md
index 6e76300c1..be638d95a 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ QQ群:170029046
```xml
- 0.9.36
+ 0.9.37
com.easy-query
@@ -65,7 +65,7 @@ QQ群:170029046
```xml
- 0.9.36
+ 0.9.37
diff --git a/pom.xml b/pom.xml
index b34b1acd6..f19c00fa2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.easy-query
easy-query-all
pom
- 0.9.36
+ 0.9.37
easy-query
java object query distributed connector
https://github.com/xuejmnet/easy-query
@@ -33,8 +33,8 @@
sql-db-support/sql-pgsql
sql-db-support/sql-sqlite
-
-
+ sql-test
+ samples
diff --git a/samples/pom.xml b/samples/pom.xml
index a270fb69c..715381428 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -5,7 +5,7 @@
easy-query-all
com.easy-query
- 0.9.36
+ 0.9.37
4.0.0
diff --git a/samples/springbootdemo/pom.xml b/samples/springbootdemo/pom.xml
index 1de54daa8..cf5c1a2da 100644
--- a/samples/springbootdemo/pom.xml
+++ b/samples/springbootdemo/pom.xml
@@ -55,7 +55,7 @@
com.easy-query
sql-springboot-starter
- 0.9.36
+ 0.9.37
compile
diff --git a/sql-core/pom.xml b/sql-core/pom.xml
index ac8bd0af2..beb9223c1 100644
--- a/sql-core/pom.xml
+++ b/sql-core/pom.xml
@@ -5,7 +5,7 @@
easy-query-all
com.easy-query
- 0.9.36
+ 0.9.37
4.0.0
diff --git a/sql-core/src/main/java/com/easy/query/core/api/client/DefaultEasyQueryClient.java b/sql-core/src/main/java/com/easy/query/core/api/client/DefaultEasyQueryClient.java
index 88a726b34..4ab9685b4 100644
--- a/sql-core/src/main/java/com/easy/query/core/api/client/DefaultEasyQueryClient.java
+++ b/sql-core/src/main/java/com/easy/query/core/api/client/DefaultEasyQueryClient.java
@@ -57,6 +57,11 @@ public ClientQueryable queryable(Class clazz) {
return easySQLApiFactory.createQueryable(clazz, runtimeContext);
}
+ @Override
+ public ClientQueryable queryable(ClientQueryable queryable) {
+ return null;
+ }
+
@Override
public ClientQueryable queryable(String sql, Class clazz) {
return easySQLApiFactory.createQueryable(sql, clazz, runtimeContext);
diff --git a/sql-core/src/main/java/com/easy/query/core/api/client/EasyQueryClient.java b/sql-core/src/main/java/com/easy/query/core/api/client/EasyQueryClient.java
index baaebfcc8..c913f1ab4 100644
--- a/sql-core/src/main/java/com/easy/query/core/api/client/EasyQueryClient.java
+++ b/sql-core/src/main/java/com/easy/query/core/api/client/EasyQueryClient.java
@@ -51,6 +51,8 @@ default long sqlExecute(String sql) {
ClientQueryable queryable(Class clazz);
+ ClientQueryable queryable(ClientQueryable queryable);
+
ClientQueryable queryable(String sql, Class clazz);
default Transaction beginTransaction() {
diff --git a/sql-core/src/main/java/com/easy/query/core/api/def/DefaultSQLClientApiFactory.java b/sql-core/src/main/java/com/easy/query/core/api/def/DefaultSQLClientApiFactory.java
index ec1836bc0..96d442353 100644
--- a/sql-core/src/main/java/com/easy/query/core/api/def/DefaultSQLClientApiFactory.java
+++ b/sql-core/src/main/java/com/easy/query/core/api/def/DefaultSQLClientApiFactory.java
@@ -68,7 +68,6 @@ public ClientQueryable createQueryable(Class clazz, QueryRuntimeContex
EntityQueryExpressionBuilder entityQueryExpressionBuilder = expressionBuilderFactory.createEntityQueryExpressionBuilder(queryExpressionContext);
EntityMetadata entityMetadata = runtimeContext.getEntityMetadataManager().getEntityMetadata(clazz);
int tableIndex = EasyUtil.getNextTableIndex(entityQueryExpressionBuilder);
- ;
EntityTableExpressionBuilder sqlTable = expressionBuilderFactory.createEntityTableExpressionBuilder(entityMetadata, tableIndex, MultiTableTypeEnum.FROM, runtimeContext);
entityQueryExpressionBuilder.addSQLEntityTableExpression(sqlTable);
return new EasyClientQueryable<>(clazz, entityQueryExpressionBuilder);
diff --git a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable.java b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable.java
index 343e2f1c6..d1dfcb750 100644
--- a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable.java
+++ b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable.java
@@ -64,16 +64,6 @@ default BigDecimal sumBigDecimalOrNull(String property) {
return sumBigDecimalOrDefault(property, null);
}
- /**
- * 防止溢出
- *
- * @param property
- * @return
- */
- default BigDecimal sumBigDecimalNotNull(String property) {
- return sumBigDecimalOrDefault(property, BigDecimal.ZERO);
- }
-
BigDecimal sumBigDecimalOrDefault(String property, BigDecimal def);
default TMember sumOrNull(String property) {
@@ -120,13 +110,6 @@ default Float avgOrDefault(String property, Float def)
TResult avgOrDefault(String property, TResult def, Class resultClass);
- default Integer lenOrNull(String property) {
- return lenOrDefault(property, null);
- }
-
- Integer lenOrDefault(String property, Integer def);
-
-
/**
* 对当前表达式返回自定义select列
*
diff --git a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable2.java b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable2.java
index 3e8d95c02..ed03dc798 100644
--- a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable2.java
+++ b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable2.java
@@ -6,11 +6,7 @@
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression2;
import com.easy.query.core.expression.lambda.SQLExpression3;
-import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnResultSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnSelector;
-import com.easy.query.core.expression.parser.core.base.GroupBySelector;
-import com.easy.query.core.expression.parser.core.base.WherePredicate;
+import com.easy.query.core.expression.parser.core.base.*;
import java.math.BigDecimal;
import java.util.function.Function;
@@ -75,17 +71,6 @@ default BigDecimal sumBigDecimalOrNull(SQLExpression2
- * @return
- */
- default BigDecimal sumBigDecimalNotNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
- return sumBigDecimalOrDefault(columnSelectorExpression, BigDecimal.ZERO);
- }
-
BigDecimal sumBigDecimalOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, BigDecimal def);
default TMember sumOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
@@ -106,17 +91,31 @@ default TMember minOrNull(SQLExpression2, Col
TMember minOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, TMember def);
- default TMember avgOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
- return avgOrDefault(columnSelectorExpression, null);
+ default Double avgOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Double.class);
+ }
+
+ default BigDecimal avgBigDecimalOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, BigDecimal.class);
+ }
+
+ default Float avgFloatOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Float.class);
+ }
+
+ default Double avgOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, Double def) {
+ return avgOrDefault(columnSelectorExpression, def, Double.class);
}
- TMember avgOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, TMember def);
+ default BigDecimal avgBigDecimalOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, BigDecimal def) {
+ return avgOrDefault(columnSelectorExpression, def, BigDecimal.class);
+ }
- default Integer lenOrNull(SQLExpression2, ColumnResultSelector> columnSelectorExpression) {
- return lenOrDefault(columnSelectorExpression, null);
+ default Float avgFloatOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, Float def) {
+ return avgOrDefault(columnSelectorExpression, def, Float.class);
}
- Integer lenOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, Integer def);
+ TResult avgOrDefault(SQLExpression2, ColumnResultSelector> columnSelectorExpression, TResult def, Class resultClass);
//endregion
//region group
@@ -134,6 +133,20 @@ default ClientQueryable2 groupBy(SQLExpression2, Gro
ClientQueryable2 groupBy(boolean condition, SQLExpression2, GroupBySelector> selectExpression);
+ @Override
+ default ClientQueryable2 having(SQLExpression1> predicateExpression) {
+ return having(true, predicateExpression);
+ }
+
+ @Override
+ ClientQueryable2 having(boolean condition, SQLExpression1> predicateExpression);
+
+ default ClientQueryable2 having(SQLExpression2, WhereAggregatePredicate> predicateExpression) {
+ return having(true, predicateExpression);
+ }
+
+ ClientQueryable2 having(boolean condition, SQLExpression2, WhereAggregatePredicate> predicateExpression);
+
//endregion
//region order
@Override
diff --git a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable3.java b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable3.java
index 6318e67cf..1131657ab 100644
--- a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable3.java
+++ b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable3.java
@@ -6,11 +6,7 @@
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression3;
import com.easy.query.core.expression.lambda.SQLExpression4;
-import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnResultSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnSelector;
-import com.easy.query.core.expression.parser.core.base.GroupBySelector;
-import com.easy.query.core.expression.parser.core.base.WherePredicate;
+import com.easy.query.core.expression.parser.core.base.*;
import java.math.BigDecimal;
import java.util.function.Function;
@@ -76,17 +72,6 @@ default BigDecimal sumBigDecimalOrNull(SQLExpression3
- * @return
- */
- default BigDecimal sumBigDecimalNotNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return sumBigDecimalOrDefault(columnSelectorExpression, BigDecimal.ZERO);
- }
-
BigDecimal sumBigDecimalOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, BigDecimal def);
default TMember sumOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
@@ -107,17 +92,32 @@ default TMember minOrNull(SQLExpression3, Col
TMember minOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TMember def);
- default TMember avgOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return avgOrDefault(columnSelectorExpression, null);
+ default Double avgOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Double.class);
+ }
+
+ default BigDecimal avgBigDecimalOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, BigDecimal.class);
+ }
+
+ default Float avgFloatOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Float.class);
}
- TMember avgOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TMember def);
+ default Double avgOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Double def) {
+ return avgOrDefault(columnSelectorExpression, def, Double.class);
+ }
+
+ default BigDecimal avgBigDecimalOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, BigDecimal def) {
+ return avgOrDefault(columnSelectorExpression, def, BigDecimal.class);
+ }
- default Integer lenOrNull(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return lenOrDefault(columnSelectorExpression, null);
+ default Float avgFloatOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Float def) {
+ return avgOrDefault(columnSelectorExpression, def, Float.class);
}
- Integer lenOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Integer def);
+ TResult avgOrDefault(SQLExpression3, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TResult def, Class resultClass);
+
//endregion
//region group
@@ -135,6 +135,21 @@ default ClientQueryable3 groupBy(SQLExpression3,
ClientQueryable3 groupBy(boolean condition, SQLExpression3, GroupBySelector, GroupBySelector> selectExpression);
+
+ @Override
+ default ClientQueryable3 having(SQLExpression1> predicateExpression) {
+ return having(true, predicateExpression);
+ }
+
+ @Override
+ ClientQueryable3 having(boolean condition, SQLExpression1> predicateExpression);
+
+ default ClientQueryable3 having(SQLExpression3, WhereAggregatePredicate, WhereAggregatePredicate> predicateExpression) {
+ return having(true, predicateExpression);
+ }
+
+ ClientQueryable3 having(boolean condition, SQLExpression3, WhereAggregatePredicate, WhereAggregatePredicate> predicateExpression);
+
//endregion
//region order
@Override
diff --git a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable4.java b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable4.java
index 2efa46bba..1b3e441df 100644
--- a/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable4.java
+++ b/sql-core/src/main/java/com/easy/query/core/basic/api/select/ClientQueryable4.java
@@ -5,11 +5,7 @@
import com.easy.query.core.enums.sharding.ConnectionModeEnum;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression4;
-import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnResultSelector;
-import com.easy.query.core.expression.parser.core.base.ColumnSelector;
-import com.easy.query.core.expression.parser.core.base.GroupBySelector;
-import com.easy.query.core.expression.parser.core.base.WherePredicate;
+import com.easy.query.core.expression.parser.core.base.*;
import java.math.BigDecimal;
import java.util.function.Function;
@@ -60,17 +56,6 @@ default BigDecimal sumBigDecimalOrNull(SQLExpression4
- * @return
- */
- default BigDecimal sumBigDecimalNotNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return sumBigDecimalOrDefault(columnSelectorExpression, BigDecimal.ZERO);
- }
-
BigDecimal sumBigDecimalOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, BigDecimal def);
default TMember sumOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
@@ -91,17 +76,32 @@ default TMember minOrNull(SQLExpression4, Col
TMember minOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TMember def);
- default TMember avgOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return avgOrDefault(columnSelectorExpression, null);
+ default Double avgOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Double.class);
+ }
+
+ default BigDecimal avgBigDecimalOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, BigDecimal.class);
}
- TMember avgOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TMember def);
+ default Float avgFloatOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
+ return avgOrDefault(columnSelectorExpression, null, Float.class);
+ }
- default Integer lenOrNull(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression) {
- return lenOrDefault(columnSelectorExpression, null);
+ default Double avgOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Double def) {
+ return avgOrDefault(columnSelectorExpression, def, Double.class);
}
- Integer lenOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Integer def);
+ default BigDecimal avgBigDecimalOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, BigDecimal def) {
+ return avgOrDefault(columnSelectorExpression, def, BigDecimal.class);
+ }
+
+ default Float avgFloatOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, Float def) {
+ return avgOrDefault(columnSelectorExpression, def, Float.class);
+ }
+
+ TResult avgOrDefault(SQLExpression4, ColumnResultSelector, ColumnResultSelector, ColumnResultSelector> columnSelectorExpression, TResult def, Class resultClass);
+
//endregion
@@ -120,6 +120,20 @@ default ClientQueryable4 groupBy(SQLExpression4 groupBy(boolean condition, SQLExpression4