[SQL Generator] select

This commit is contained in:
jeffcheasey88 2023-11-20 14:42:47 +01:00
parent d7b367fcad
commit 5b6da187cc
2 changed files with 16 additions and 5 deletions

View file

@ -1,7 +1,10 @@
package dev.peerat.mapping.providers.mysql;
import java.util.ArrayList;
import java.util.List;
import dev.peerat.parser.java.Value;
import dev.peerat.parser.java.Value.LambdaValue;
import dev.peerat.parser.java.Value.MethodCallValue;
public class MySQLRequestBuilder{
@ -20,8 +23,16 @@ public class MySQLRequestBuilder{
return "SELECT *";
}
if(method.equals("select()")){
throw new RuntimeException(value.getParameters().get(0)+"");
// return "SELECT ";
LambdaValue include = (LambdaValue) value.getParameters().get(0);
MethodCallValue keep = (MethodCallValue)include.getOperations().get(0);
List<String> binds = new ArrayList<>();
for(Value param : keep.getParameters()){
binds.add(param.getToken().getValue());
}
String result = ""; //optimise with iterator
for(String bind : binds) result+=","+bind;
result=result.substring(1);
return "SELECT "+result;
}
return null;
@ -29,6 +40,7 @@ public class MySQLRequestBuilder{
public void build(){
this.select = toStringOperation(calls.get(0));
throw new RuntimeException(this.select);
}
}

View file

@ -42,15 +42,14 @@ public class MySQLProvider implements Provider{
Value value = operation.getValue();
if(value instanceof MethodCallValue){
MethodCallValue call = (MethodCallValue)value;
throw new RuntimeException(clazz.getName().getValue()+" - "+call);
/*List<MethodCallValue> list = new LinkedList<>();
List<MethodCallValue> list = new LinkedList<>();
while(call.base() instanceof MethodCallValue){
list.add(0, call);
call = (MethodCallValue) call.base();
}
list.add(0, call);
MySQLRequestBuilder builder = new MySQLRequestBuilder(list);
builder.build();*/
builder.build();
}
}