some TODO items squezed

This commit is contained in:
2021-12-19 12:07:26 +01:00
parent eebb270f47
commit 04c0ed3f03
5 changed files with 49 additions and 35 deletions

View File

@@ -174,9 +174,9 @@ std::unique_ptr<ValueNode> USql::eval_function_value_node(Table *table, Row &row
}
// at this moment no functions without parameter(s) or first param can be null
// TODO exception here or better parsing
if (evaluatedPars.empty() || evaluatedPars[0]->isNull())
return std::make_unique<NullValueNode>();
throw Exception("eval_function_value_node, no function parameter or first is null, function: " + fnc->function);
// return std::make_unique<NullValueNode>();
// TODO use some enum
if (fnc->function == "lower") return lower_function(evaluatedPars);
@@ -216,8 +216,8 @@ std::unique_ptr<ValueNode> USql::eval_arithmetic_operator(ColumnType outType, Ar
return std::make_unique<NullValueNode>();
if (outType == ColumnType::float_type) {
double l = left->getDoubleValue();
double r = right->getDoubleValue();
auto l = left->getDoubleValue();
auto r = right->getDoubleValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<DoubleValueNode>(l + r);
@@ -232,8 +232,8 @@ std::unique_ptr<ValueNode> USql::eval_arithmetic_operator(ColumnType outType, Ar
}
} else if (outType == ColumnType::integer_type) {
long l = left->getIntegerValue();
long r = right->getIntegerValue();
auto l = left->getIntegerValue();
auto r = right->getIntegerValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<IntValueNode>(l + r);
@@ -248,17 +248,27 @@ std::unique_ptr<ValueNode> USql::eval_arithmetic_operator(ColumnType outType, Ar
}
} else if (outType == ColumnType::varchar_type) {
std::string l = left->getStringValue();
std::string r = right->getStringValue();
auto l = left->getStringValue();
auto r = right->getStringValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<StringValueNode>(l + r);
default:
throw Exception("eval_arithmetic_operator, varchar type implement me!!");
}
}
// TODO date node should support addition and subtraction
} else if (outType == ColumnType::date_type) {
auto l = left->getDateValue();
auto r = right->getDateValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<IntValueNode>(l + r);
case ArithmeticalOperatorType::minus_operator:
return std::make_unique<IntValueNode>(l - r);
default:
throw Exception("eval_arithmetic_operator, date_type type implement me!!");
}
}
throw Exception("eval_arithmetic_operator, implement me!!");
}