From ad97b8ee773f498a5fbc34fc5f24f8639d1328c1 Mon Sep 17 00:00:00 2001 From: "kyle.cao" Date: Thu, 9 Sep 2021 23:10:06 +0800 Subject: [PATCH] Fix time() infinite loop (#2820) --- src/graph/visitor/DeduceTypeVisitor.cpp | 1 + .../features/expression/FunctionCall.feature | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/graph/visitor/DeduceTypeVisitor.cpp b/src/graph/visitor/DeduceTypeVisitor.cpp index d4573d322fa..f03ccd3b5a3 100644 --- a/src/graph/visitor/DeduceTypeVisitor.cpp +++ b/src/graph/visitor/DeduceTypeVisitor.cpp @@ -34,6 +34,7 @@ static const std::unordered_map kConstantValues = { {Value::Type::STRING, Value("123")}, {Value::Type::DATE, Value(Date())}, {Value::Type::DATETIME, Value(DateTime())}, + {Value::Type::TIME, Value(Time())}, {Value::Type::VERTEX, Value(Vertex())}, {Value::Type::EDGE, Value(Edge())}, {Value::Type::PATH, Value(Path())}, diff --git a/tests/tck/features/expression/FunctionCall.feature b/tests/tck/features/expression/FunctionCall.feature index 17ba3613233..bb5dcc1602e 100644 --- a/tests/tck/features/expression/FunctionCall.feature +++ b/tests/tck/features/expression/FunctionCall.feature @@ -121,3 +121,20 @@ Feature: Function Call Expression Then the result should be, in any order: | result | | NULL | + + Scenario: error check + When executing query: + """ + RETURN timestamp("2000-10-10T10:00:00") + true + """ + Then a SemanticError should be raised at runtime: `(timestamp("2000-10-10T10:00:00")+true)' is not a valid expression, can not apply `+' to `INT' and `BOOL'. + When executing query: + """ + RETURN time("10:00:00") + 3 + """ + Then a SemanticError should be raised at runtime: `(time("10:00:00")+3)' is not a valid expression, can not apply `+' to `TIME' and `INT'. + When executing query: + """ + RETURN datetime("2000-10-10T10:00:00") + 3 + """ + Then a SemanticError should be raised at runtime: `(datetime("2000-10-10T10:00:00")+3)' is not a valid expression, can not apply `+' to `DATETIME' and `INT'.