Skip to content

Commit

Permalink
feat: 2.0.90优化range处理
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Oct 9, 2024
1 parent 29902c6 commit 9865309
Show file tree
Hide file tree
Showing 32 changed files with 151 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<packaging>pom</packaging>
<version>2.0.82</version>
<version>2.0.90</version>
<name>easy-query</name>
<description>java object query distributed connector</description>
<url>https://github.com/xuejmnet/easy-query</url>
Expand Down Expand Up @@ -44,7 +44,7 @@
<module>sql-processor</module>
<module>sql-ksp-processor</module>
<!-- 以下是不需要deploy到远程仓库的-->
<module>sql-test</module>
<!-- <module>sql-test</module>-->
</modules>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion sql-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import com.easy.query.core.util.EasyClassUtil;
import com.easy.query.core.util.EasyCollectionUtil;
import com.easy.query.core.util.EasySQLSegmentUtil;
import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.Collection;
import java.util.HashMap;
Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-db-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-clickhouse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-dameng/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-db2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-gauss-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-kingbase-es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>sql-kingbase-es</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-mssql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-oracle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-pgsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-db-support/sql-sqlite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-extension</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-extension/sql-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-extension/sql-kt-springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-extension/sql-solon-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-extension/sql-springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions sql-ksp-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-ksp-processor</artifactId>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>com.easy-query</groupId>
<artifactId>sql-processor</artifactId>
<version>2.0.82</version>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion sql-platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-platform</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-platform/sql-api-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>sql-platform</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-api-proxy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,18 @@ default void rangeClosed(PropTypeColumn<TProperty> valLeft, PropTypeColumn<TProp
* @return
*/
default void rangeClosed(boolean conditionLeft, PropTypeColumn<TProperty> valLeft, boolean conditionRight, PropTypeColumn<TProperty> valRight) {
ValueFilter valueFilter = getEntitySQLContext().getEntityExpressionBuilder().getExpressionContext().getValueFilter();
range(getEntitySQLContext(), this.getTable(), this.getValue(), conditionLeft && valueFilter.accept(this.getTable(), this.getValue(), valLeft), valLeft, conditionRight && valueFilter.accept(this.getTable(), this.getValue(), valRight), valRight, SQLRangeEnum.CLOSED);
range(getEntitySQLContext(), this.getTable(), this.getValue(), conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.CLOSED);
}


static <TProp> void range(EntitySQLContext entitySQLContext, TableAvailable table, String property, boolean conditionLeft, PropTypeColumn<TProp> valLeft, boolean conditionRight, PropTypeColumn<TProp> valRight, SQLRangeEnum sqlRange) {
ValueFilter valueFilter = entitySQLContext.getEntityExpressionBuilder().getExpressionContext().getValueFilter();
boolean acceptLeft = valueFilter.accept(table, property, valLeft);
boolean acceptRight = valueFilter.accept(table, property, valRight);
range0(entitySQLContext, table, property, conditionLeft && acceptLeft, valLeft, conditionRight && acceptRight, valRight, sqlRange);
}

static <TProp> void range0(EntitySQLContext entitySQLContext, TableAvailable table, String property, boolean conditionLeft, PropTypeColumn<TProp> valLeft, boolean conditionRight, PropTypeColumn<TProp> valRight, SQLRangeEnum sqlRange) {

if (conditionLeft && conditionRight) {
entitySQLContext._whereAnd(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,17 @@ default void rangeClosed(TProperty valLeft, TProperty valRight) {
* @return
*/
default void rangeClosed(boolean conditionLeft, TProperty valLeft, boolean conditionRight, TProperty valRight) {
ValueFilter valueFilter = getEntitySQLContext().getEntityExpressionBuilder().getExpressionContext().getValueFilter();
range(getEntitySQLContext(), this.getTable(), this.getValue(), conditionLeft && valueFilter.accept(this.getTable(), this.getValue(), valLeft), valLeft, conditionRight && valueFilter.accept(this.getTable(), this.getValue(), valRight), valRight, SQLRangeEnum.CLOSED);
range(getEntitySQLContext(), this.getTable(), this.getValue(), conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.CLOSED);
}

static <TProp> void range(EntitySQLContext entitySQLContext, TableAvailable table, String property, boolean conditionLeft, TProp valLeft, boolean conditionRight, TProp valRight, SQLRangeEnum sqlRange) {
ValueFilter valueFilter = entitySQLContext.getEntityExpressionBuilder().getExpressionContext().getValueFilter();
boolean acceptLeft = valueFilter.accept(table, property, valLeft);
boolean acceptRight = valueFilter.accept(table, property, valRight);
range0(entitySQLContext, table, property, conditionLeft && acceptLeft, valLeft, conditionRight && acceptRight, valRight, sqlRange);
}

static <TProp> void range0(EntitySQLContext entitySQLContext, TableAvailable table, String property, boolean conditionLeft, TProp valLeft, boolean conditionRight, TProp valRight, SQLRangeEnum sqlRange) {
if (conditionLeft && conditionRight) {
entitySQLContext._whereAnd(() -> {
entitySQLContext.accept(new SQLPredicateImpl(filter -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,35 @@ public interface DSLRangeAggregatePredicate<TProperty> extends DSLRangePredicate

@Override
default void rangeOpenClosed(boolean conditionLeft, TProperty valLeft, boolean conditionRight, TProperty valRight) {
rangeFilter(getEntitySQLContext(),this,conditionLeft,_toFunctionSerializeValue(valLeft),conditionRight,_toFunctionSerializeValue(valRight),SQLRangeEnum.OPEN_CLOSED);
rangeFilter(getEntitySQLContext(), this, conditionLeft, _toFunctionSerializeValue(valLeft), conditionRight, _toFunctionSerializeValue(valRight), SQLRangeEnum.OPEN_CLOSED);
}

@Override
default void rangeOpen(boolean conditionLeft, TProperty valLeft, boolean conditionRight, TProperty valRight) {
rangeFilter(getEntitySQLContext(),this,conditionLeft,_toFunctionSerializeValue(valLeft),conditionRight,_toFunctionSerializeValue(valRight),SQLRangeEnum.OPEN);
rangeFilter(getEntitySQLContext(), this, conditionLeft, _toFunctionSerializeValue(valLeft), conditionRight, _toFunctionSerializeValue(valRight), SQLRangeEnum.OPEN);
}

@Override
default void rangeClosedOpen(boolean conditionLeft, TProperty valLeft, boolean conditionRight, TProperty valRight) {
rangeFilter(getEntitySQLContext(),this,conditionLeft,_toFunctionSerializeValue(valLeft),conditionRight,_toFunctionSerializeValue(valRight),SQLRangeEnum.CLOSED_OPEN);
rangeFilter(getEntitySQLContext(), this, conditionLeft, _toFunctionSerializeValue(valLeft), conditionRight, _toFunctionSerializeValue(valRight), SQLRangeEnum.CLOSED_OPEN);
}

@Override
default void rangeClosed(boolean conditionLeft, TProperty valLeft, boolean conditionRight, TProperty valRight) {

rangeFilter(getEntitySQLContext(),this,conditionLeft,_toFunctionSerializeValue(valLeft),conditionRight,_toFunctionSerializeValue(valRight),SQLRangeEnum.CLOSED);
rangeFilter(getEntitySQLContext(), this, conditionLeft, _toFunctionSerializeValue(valLeft), conditionRight, _toFunctionSerializeValue(valRight), SQLRangeEnum.CLOSED);
}


static <TProp> void rangeFilter(EntitySQLContext entitySQLContext, DSLSQLFunctionAvailable dslSQLFunction, boolean conditionLeft, TProp valLeft, boolean conditionRight, TProp valRight, SQLRangeEnum sqlRange) {
ValueFilter valueFilter = entitySQLContext.getEntityExpressionBuilder().getExpressionContext().getValueFilter();
rangeFilter0(entitySQLContext,dslSQLFunction,conditionLeft && valueFilter.accept(dslSQLFunction.getTable(), null, valLeft),valLeft,conditionRight && valueFilter.accept(dslSQLFunction.getTable(), null, valRight),valRight,sqlRange);
boolean acceptLeft = valueFilter.accept(dslSQLFunction.getTable(), null, valLeft);
boolean acceptRight = valueFilter.accept(dslSQLFunction.getTable(), null, valRight);
rangeFilter0(entitySQLContext, dslSQLFunction, conditionLeft && acceptLeft, valLeft, conditionRight && acceptRight, valRight, sqlRange);
}

static <TProp> void rangeFilter0(EntitySQLContext entitySQLContext, DSLSQLFunctionAvailable dslSQLFunction, boolean conditionLeft, TProp valLeft, boolean conditionRight, TProp valRight, SQLRangeEnum sqlRange) {
if (conditionLeft && conditionRight) {
entitySQLContext._whereAnd(()->{
entitySQLContext._whereAnd(() -> {
entitySQLContext.accept(new SQLAggregatePredicateImpl(filter -> {
boolean openFirst = SQLRangeEnum.openFirst(sqlRange);
rangeCompareFilter(filter, dslSQLFunction, openFirst ? SQLPredicateCompareEnum.GT : SQLPredicateCompareEnum.GE, valLeft);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.easy.query.core.proxy.predicate.aggregate;

import com.easy.query.core.annotation.Table;
import com.easy.query.core.enums.SQLPredicateCompareEnum;
import com.easy.query.core.enums.SQLRangeEnum;
import com.easy.query.core.expression.builder.AggregateFilter;
Expand Down Expand Up @@ -42,12 +43,19 @@ default void rangeClosedOpen(boolean conditionLeft, PropTypeColumn<TProperty> va

@Override
default void rangeClosed(boolean conditionLeft, PropTypeColumn<TProperty> valLeft, boolean conditionRight, PropTypeColumn<TProperty> valRight) {
ValueFilter valueFilter = getEntitySQLContext().getEntityExpressionBuilder().getExpressionContext().getValueFilter();
rangeFilter(getEntitySQLContext(), this, conditionLeft && valueFilter.accept(this.getTable(), null, valLeft), valLeft, conditionRight && valueFilter.accept(this.getTable(), null, valRight), valRight, SQLRangeEnum.CLOSED);
rangeFilter(getEntitySQLContext(), this, conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.CLOSED);
}


static <TProp> void rangeFilter(EntitySQLContext entitySQLContext, DSLSQLFunctionAvailable dslSQLFunction, boolean conditionLeft, PropTypeColumn<TProp> valLeft, boolean conditionRight, PropTypeColumn<TProp> valRight, SQLRangeEnum sqlRange) {
ValueFilter valueFilter = entitySQLContext.getEntityExpressionBuilder().getExpressionContext().getValueFilter();
boolean acceptLeft = valueFilter.accept(dslSQLFunction.getTable(), null, valLeft);
boolean acceptRight = valueFilter.accept(dslSQLFunction.getTable(), null, valRight);
rangeFilter0(entitySQLContext, dslSQLFunction, conditionLeft && acceptLeft, valLeft, conditionRight && acceptRight, valRight, sqlRange);
}


static <TProp> void rangeFilter0(EntitySQLContext entitySQLContext, DSLSQLFunctionAvailable dslSQLFunction, boolean conditionLeft, PropTypeColumn<TProp> valLeft, boolean conditionRight, PropTypeColumn<TProp> valRight, SQLRangeEnum sqlRange) {
if (conditionLeft && conditionRight) {
entitySQLContext._whereAnd(() -> {
entitySQLContext.accept(new SQLAggregatePredicateImpl(filter -> {
Expand Down
2 changes: 1 addition & 1 deletion sql-platform/sql-api4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-platform/sql-api4kt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sql-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>

<artifactId>sql-processor</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions sql-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>2.0.82</version>
<version>2.0.90</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -95,7 +95,7 @@
<dependency>
<groupId>com.easy-query</groupId>
<artifactId>sql-api4kt</artifactId>
<version>2.0.82</version>
<version>2.0.90</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit 9865309

Please sign in to comment.