First Working Version #1

Merged
jusax23 merged 14 commits from dev into main 2023-02-14 23:33:55 +01:00
7 changed files with 72 additions and 60 deletions
Showing only changes of commit e33dbcdfca - Show all commits

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

View file

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