add limit
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
jusax23 2023-01-23 22:10:33 +01:00
parent 71f6fbf117
commit e33dbcdfca
7 changed files with 72 additions and 60 deletions

View file

@ -1 +1,4 @@
# DBlang
sql Querys with js ot ts Syntax.
[![status-badge](https://ci.jusax.de/api/badges/jusax23/dblang/status.svg)](https://ci.jusax.de/jusax23/dblang)

View file

@ -25,6 +25,10 @@ export class Handler {
sql += " having " + havingS[0];
}
}
if (q.limitD != null) {
sql += " limit ?";
args.push(q.limitD);
}
return [sql, args];
}
@ -60,16 +64,16 @@ export class Handler {
function joinArg(type: string, s: any) {
return (a: (allModifierInput)[]): serializeReturn => {
let args: primaryData[] = [];
let sql = "(" + a.map(d => {
let sql = a.map(d => {
if (d instanceof Attribute) return d;
if (d instanceof Modifier || d instanceof selectQuery || d instanceof Aggregation) {
let [sqli, argsi] = d.serialize(s);
args.push(...(argsi.flat(Infinity)));
return sqli;
return "("+sqli+")";
}
args.push(d);
return "?";
}).join(" " + type + " ") + ")";
}).join(" " + type + " ");
return [sql, args]
}

View file

@ -35,6 +35,11 @@ export class selectQuery {
this.havingD = m;
return this;
}
limitD: number | null = null;
limit(i: number) {
this.limitD = i;
return this;
}
serialize(handler = Handler): serializeReturn {
return handler.querys.select(this);