[SQL Generator] add some operations

This commit is contained in:
jeffcheasey88 2023-11-20 15:05:54 +01:00
parent 7a1a943f66
commit cf088e27cc

View file

@ -49,12 +49,16 @@ public class MySQLRequestBuilder{
BiValue bool = (BiValue)value;
String action = bool.getAction();
if(action.equals("||")) return toStringCondition(bool.left())+" OR "+toStringCondition(bool.right());
if(action.equals("&&")) return toStringCondition(bool.left())+" AND "+toStringCondition(bool.right());
if(action.equals("==")) return toStringCondition(bool.left())+" = "+toStringCondition(bool.right());
throw new RuntimeException("unsuported operation "+action);
}
if(value instanceof MethodCallValue){ //take method call instead of value
MethodCallValue call = (MethodCallValue)value;
String action = call.getToken().getValue();
if(action.equals("contains()")) return call.base().getToken().getValue()+" LIKE \"%?%\"";
if(action.equals("startsWith()")) return call.base().getToken().getValue()+" LIKE \"?%\"";
if(action.equals("endsWith()")) return call.base().getToken().getValue()+" LIKE \"%?\"";
return action;
}
return "default "+value.getClass();