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

fixed #33 #34

Merged
merged 1 commit into from
Dec 20, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ Instant REST API over your existing or new database in minutes.

#### Supported Operators

| 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] |
| =in= | <= | in | [X] |
| =out= | <= | not in | [X] |
| 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] |
| =in= | <= | in | [X] |
| =out= | <= | not in | [X] |
| =like= | like | like | [X] |



### MySQL (Planned)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.homihq.db2rest.rsql;

import com.homihq.db2rest.rsql.operators.CustomRSQLOperators;
import com.homihq.db2rest.rsql.operators.handler.jooq.JooqCustomRSQLOperators;
import com.homihq.db2rest.rsql.parser.JooqRSQLVisitor;
import com.homihq.db2rest.schema.SchemaService;
import cz.jirutka.rsql.parser.RSQLParser;
Expand Down Expand Up @@ -32,7 +33,7 @@ public String getWhereClause(String tableName, String rSql) {
public void getWhereClause(SelectJoinStep<Record> selectFromStep, String tableName, String rSql) {
Table table = schemaService.getTableByName(tableName).orElseThrow();

Node rootNode = new RSQLParser().parse(rSql);
Node rootNode = new RSQLParser(JooqCustomRSQLOperators.customOperators()).parse(rSql);

log.info("root node - {}", rootNode);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class RSQLOperatorHandlers {
static {


OPERATOR_HANDLER_MAP.put(LIKE.getSymbol(), new LikeOperatorHandler());

OPERATOR_HANDLER_MAP.put(START_WITH.getSymbol(), new StartWithOperatorHandler());
OPERATOR_HANDLER_MAP.put(END_WITH.getSymbol(), new EndWithOperatorHandler());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.homihq.db2rest.rsql.operators.handler.jooq;

import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import cz.jirutka.rsql.parser.ast.RSQLOperators;

import java.util.Arrays;
import java.util.Set;

public class JooqCustomRSQLOperators extends RSQLOperators {

public static final ComparisonOperator LIKE = new ComparisonOperator("=like=", false);
public static final ComparisonOperator START_WITH = new ComparisonOperator("=startWith=", false);
public static final ComparisonOperator END_WITH = new ComparisonOperator("=endWith=", false);

public static Set<ComparisonOperator> customOperators() {
Set<ComparisonOperator> comparisonOperators = defaultOperators();
comparisonOperators.addAll(Arrays.asList(LIKE, START_WITH, END_WITH));
return comparisonOperators;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.homihq.db2rest.rsql.operators.handler.jooq;

import com.homihq.db2rest.rsql.operators.handler.OperatorHandler;
import org.jooq.Condition;

import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.val;

public class JooqLikeOperatorHandler implements JooqOperatorHandler {

private static final String OPERATOR = " like ";

@Override
public Condition handle(String columnName, String value, Class type) {
//return columnName + OPERATOR + "'%" + value + "%'";
return
field(columnName)
.like(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class JooqRSQLOperatorHandlers {
OPERATOR_HANDLER_MAP.put(LESS_THAN.getSymbol(), new JooqLessThanOperatorHandler());
OPERATOR_HANDLER_MAP.put(LESS_THAN_OR_EQUAL.getSymbol(), new JooqLessThanEqualToOperatorHandler());
OPERATOR_HANDLER_MAP.put(NOT_EQUAL.getSymbol(), new JooqNotEqualToOperatorHandler());
OPERATOR_HANDLER_MAP.put(LIKE.getSymbol(), new JooqLikeOperatorHandler());
}

public static JooqOperatorHandler getOperatorHandler(String symbol) {
Expand Down