Compare commits
2 commits
eed8d36c0b
...
3a01244199
Author | SHA1 | Date | |
---|---|---|---|
3a01244199 | |||
23ebf3c75a |
2 changed files with 20 additions and 1 deletions
|
@ -825,7 +825,25 @@ export class Handler {
|
|||
}
|
||||
builder.addCode(")");
|
||||
return builder;
|
||||
}
|
||||
},
|
||||
coalesce: (handler: Handler, a: allModifierInput[]): QueryBuilder => {
|
||||
const builder = new QueryBuilder();
|
||||
builder.addCode("COALESCE(");
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
const e = a[i];
|
||||
if (e instanceof Attribute || e instanceof AttributeAlias) builder.addCode(e.getString());
|
||||
else if (e instanceof Alias)
|
||||
builder.addCode(handler.builders.escapeID(e.toString()));
|
||||
else if (e instanceof Modifier || e instanceof selectQuery || e instanceof Aggregation) {
|
||||
builder.append(e.serialize(handler));
|
||||
} else {
|
||||
builder.addInjection(e);
|
||||
}
|
||||
if (i < a.length - 1) builder.addCode(", ");
|
||||
}
|
||||
builder.addCode(")");
|
||||
return builder;
|
||||
},
|
||||
}
|
||||
|
||||
datatypes = {
|
||||
|
|
|
@ -24,6 +24,7 @@ export const regexp = (a: allModifierInput, b: allModifierInput) => new BooleanM
|
|||
export const exists = (q: selectQuery) => new BooleanModifier("exists", [q]);
|
||||
|
||||
export const concat = (...args: allModifierInput[]) => new StringModifier("concat", args);
|
||||
export const coalesce = (...args: allModifierInput[]) => new StringModifier("coalesce", args);
|
||||
|
||||
//aggregations
|
||||
export const count = (a: Attribute) => new Aggregation("count", a);
|
||||
|
|
Loading…
Reference in a new issue