From 329b538c83cc88ec8b1f9f18c97380c7b883241f Mon Sep 17 00:00:00 2001 From: grabdoc Date: Tue, 19 Dec 2023 23:17:00 -0600 Subject: [PATCH] working #27 --- README.md | 19 ++++++++++------- .../LessThanEqualToOperatorHandler.java | 2 ++ .../JooqLessThanEqualToOperatorHandler.java | 21 +++++++++++++++++++ .../jooq/JooqRSQLOperatorHandlers.java | 3 +++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqLessThanEqualToOperatorHandler.java diff --git a/README.md b/README.md index d0fed74f..4830f6c6 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,18 @@ Instant REST API over your existing or new database in minutes. #### Supported Operators -| Operator | Postgresql | Description | -|----------|------------|-----------------------| -| == | = | equals | -| > | > | greater than | -| =gt= | > | greater than | -| >= | >= | greater than or equal | -| =gt= | > | greater than or equal | +| Operator | Postgresql | Description | Supported | +|----------|------------|-----------------------|-----------| +| == | = | equals | [X] | +| > | > | greater than | [X] | +| =gt= | > | greater than | [X] | +| >= | >= | greater than or equal | [X] | +| =gt= | > | greater than or equal | [X] | +| < | < | less than | [X] | +| =lt= | < | less than | [X] | +| <= | <= | less than or equal | [X] | +| =le= | <= | less than or equal | [X] | + ### MySQL (Planned) diff --git a/src/main/java/com/homihq/db2rest/rsql/operators/handler/LessThanEqualToOperatorHandler.java b/src/main/java/com/homihq/db2rest/rsql/operators/handler/LessThanEqualToOperatorHandler.java index 8d44d8d4..ab6a1af6 100644 --- a/src/main/java/com/homihq/db2rest/rsql/operators/handler/LessThanEqualToOperatorHandler.java +++ b/src/main/java/com/homihq/db2rest/rsql/operators/handler/LessThanEqualToOperatorHandler.java @@ -1,5 +1,7 @@ package com.homihq.db2rest.rsql.operators.handler; + +@Deprecated public class LessThanEqualToOperatorHandler implements OperatorHandler { private static final String OPERATOR = " <= "; diff --git a/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqLessThanEqualToOperatorHandler.java b/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqLessThanEqualToOperatorHandler.java new file mode 100644 index 00000000..f995e15c --- /dev/null +++ b/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqLessThanEqualToOperatorHandler.java @@ -0,0 +1,21 @@ +package com.homihq.db2rest.rsql.operators.handler.jooq; + + +import org.jooq.Condition; + +import static org.jooq.impl.DSL.field; +import static org.jooq.impl.DSL.val; + +public class JooqLessThanEqualToOperatorHandler implements JooqOperatorHandler { + + private static final String OPERATOR = " <= "; + + @Override + public Condition handle(String columnName, String value, Class type) { + ///return columnName + OPERATOR + parseValue(value, type); + + return + field(columnName).le(val(value)); + } + +} diff --git a/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqRSQLOperatorHandlers.java b/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqRSQLOperatorHandlers.java index ddc37e15..214c4d02 100644 --- a/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqRSQLOperatorHandlers.java +++ b/src/main/java/com/homihq/db2rest/rsql/operators/handler/jooq/JooqRSQLOperatorHandlers.java @@ -2,6 +2,8 @@ +import com.homihq.db2rest.rsql.operators.handler.LessThanEqualToOperatorHandler; + import java.util.HashMap; import java.util.Map; @@ -16,6 +18,7 @@ public class JooqRSQLOperatorHandlers { OPERATOR_HANDLER_MAP.put(GREATER_THAN.getSymbol(), new JooqGreaterThanOperatorHandler()); OPERATOR_HANDLER_MAP.put(GREATER_THAN_OR_EQUAL.getSymbol(), new JooqGreaterThanEqualToOperatorHandler()); OPERATOR_HANDLER_MAP.put(LESS_THAN.getSymbol(), new JooqLessThanOperatorHandler()); + OPERATOR_HANDLER_MAP.put(LESS_THAN_OR_EQUAL.getSymbol(), new JooqLessThanEqualToOperatorHandler()); } public static JooqOperatorHandler getOperatorHandler(String symbol) {