Skip to content

Commit 18dac75

Browse files
committed
add round method
1 parent ea07374 commit 18dac75

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/client/compiler/parser/SQLMethods.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class SQLMethodStore {
5656
this.pushOneParameterMethod("month" , "integer","date");
5757
this.pushOneParameterMethod("day" , "integer","date");
5858
this.pushOneParameterMethod("year" , "integer","date");
59+
this.pushOneParameterMethod("round" , "integer","float");
5960

6061
let countMethod = new SQLMethod("count", true, "integer", [new SQLMethodParameter("spalte", "text")]);
6162
countMethod.acceptsStarParameter = true;
@@ -65,6 +66,10 @@ export class SQLMethodStore {
6566
strftimeMethod.acceptsStarParameter = true;
6667
this.methods.push(strftimeMethod);
6768

69+
let round2Params = new SQLMethod("round", false, "float", [new SQLMethodParameter("number", "float"), new SQLMethodParameter("digits", "integer")]);
70+
round2Params.acceptsStarParameter = false;
71+
this.methods.push(round2Params);
72+
6873
}
6974

7075
getMethods(identifier: string){

src/client/compiler/parser/SQLTypes.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class SQLBaseType extends SQLType {
137137
getBinaryResult(operator: TokenType, value1: any, value2: any): any {
138138
switch (operator) {
139139
case TokenType.concatenation:
140-
if (value1 != null && value2 != null) return value1 + value2;
140+
if (value1 != null && value2 != null) return (value1 + "") + (value2 + "");
141141
return value1 != null ? value1 : value2;
142142
case TokenType.plus:
143143
if (value1 != null && value2 != null) return value1 + value2;
@@ -398,7 +398,14 @@ SQLBaseType.addBaseTypes(baseTypes);
398398
varcharType.addBinaryOperation(TokenType.concatenation, varcharType, varcharType);
399399
varcharType.addBinaryOperation(TokenType.concatenation, charType, varcharType);
400400
varcharType.addBinaryOperation(TokenType.concatenation, textType, textType);
401+
varcharType.addBinaryOperation(TokenType.concatenation, floatType, textType);
402+
varcharType.addBinaryOperation(TokenType.concatenation, intType, textType);
403+
404+
401405
textType.addBinaryOperation(TokenType.concatenation, textType, textType);
406+
textType.addBinaryOperation(TokenType.concatenation, floatType, textType);
407+
textType.addBinaryOperation(TokenType.concatenation, intType, textType);
408+
402409
varcharType.addBinaryOperation(TokenType.keywordLike, varcharType, booleanType);
403410
varcharType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
404411
textType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
@@ -429,6 +436,8 @@ for (let i = 0; i < numericTypes.length; i++) {
429436
numericTypes[i].addBinaryOperation(numericBinaryOperators, numericTypes[j], numericTypes[j]);
430437
numericTypes[i].addBinaryOperation(comparisonOperators, numericTypes[j], booleanType);
431438
}
439+
numericTypes[i].addBinaryOperation(TokenType.concatenation, varcharType, textType);
440+
numericTypes[i].addBinaryOperation(TokenType.concatenation, textType, textType);
432441
numericTypes[i].unaryOperators = [TokenType.minus];
433442
}
434443

0 commit comments

Comments
 (0)