use of com.bluenimble.platform.db.query.impls.SqlQueryCompiler in project serverless by bluenimble.
the class TestWithBindingsQueryCompiler method main.
public static void main(String[] args) throws Exception {
Map<String, Object> bindings = new HashMap<String, Object>();
bindings.put("alpha", "alpha-val");
bindings.put("beta", new Date());
Query query = new JsonQuery(Json.load(new File("tests/queries/with-bindings.json")), bindings);
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select);
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
use of com.bluenimble.platform.db.query.impls.SqlQueryCompiler in project serverless by bluenimble.
the class TestQueryCompilerWithOperators method main.
public static void main(String[] args) throws Exception {
Query query = new JsonQuery(Json.load(new File("tests/queries/with-operators.json")));
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select);
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
use of com.bluenimble.platform.db.query.impls.SqlQueryCompiler in project serverless by bluenimble.
the class OrientDatabase method compile.
private CompiledQuery compile(String entity, Query.Construct construct, final Query query, final boolean returnBefore) throws DatabaseException {
final String fEntity = entity;
QueryCompiler compiler = new SqlQueryCompiler(construct) {
private static final long serialVersionUID = -1248971549807669897L;
@Override
protected void onQuery(Timing timing, Query query) throws DatabaseException {
super.onQuery(timing, query);
if (Timing.start.equals(timing)) {
return;
}
if (query.start() > 0) {
buff.append(Lang.SPACE).append(Sql.Skip).append(Lang.SPACE).append(query.start());
}
if (query.count() > 0) {
buff.append(Lang.SPACE).append(Sql.Limit).append(Lang.SPACE).append(query.count());
}
}
@Override
protected void onSelect(Timing timing, Select select) throws DatabaseException {
super.onSelect(timing, select);
if (Timing.end.equals(timing) && returnBefore) {
buff.append(Lang.SPACE).append(Sql.ReturnBefore);
}
}
@Override
protected String operatorFor(Operator operator) {
if (Operator.ftq.equals(operator)) {
return Lucene;
} else if (Operator.regex.equals(operator)) {
return Maches;
}
return super.operatorFor(operator);
}
@Override
protected void entity() {
buff.append(fEntity);
}
};
return compiler.compile(query);
}
use of com.bluenimble.platform.db.query.impls.SqlQueryCompiler in project serverless by bluenimble.
the class TestStartPageQueryCompiler method main.
public static void main(String[] args) throws Exception {
Query query = new JsonQuery(Json.load(new File("tests/queries/complete.json")));
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select) {
private static final long serialVersionUID = -1248971549807669897L;
@Override
protected void onQuery(Timing timing, Query query) throws DatabaseException {
super.onQuery(timing, query);
if (Timing.start.equals(timing)) {
return;
}
if (query.start() > 0) {
buff.append(Lang.SPACE).append("skip").append(Lang.SPACE).append(query.start());
}
if (query.count() > 0) {
buff.append(Lang.SPACE).append("limit").append(Lang.SPACE).append(query.count());
}
}
};
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
use of com.bluenimble.platform.db.query.impls.SqlQueryCompiler in project serverless by bluenimble.
the class TestQueryCompiler method main.
public static void main(String[] args) throws Exception {
Query query = new JsonQuery(Json.load(new File("tests/queries/simple.json")));
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select);
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
Aggregations