diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index e2b95cbe292..23480a77d14 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -20,12 +20,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 1 - - uses: jitterbit/get-changed-files@v1 - id: diff - name: Cpplint run: | ln -snf $PWD/.linters/cpp/hooks/pre-commit.sh $PWD/.linters/cpp/pre-commit.sh - .linters/cpp/pre-commit.sh ${{ steps.diff.outputs.all }} + .linters/cpp/pre-commit.sh $(git --no-pager diff --diff-filter=d --name-only HEAD^ HEAD) build: name: build diff --git a/src/graph/FindPathExecutor.cpp b/src/graph/FindPathExecutor.cpp index 0bfe01f80fa..daeb63a5bfd 100644 --- a/src/graph/FindPathExecutor.cpp +++ b/src/graph/FindPathExecutor.cpp @@ -16,6 +16,10 @@ FindPathExecutor::FindPathExecutor(Sentence *sentence, ExecutionContext *exct) } Status FindPathExecutor::prepare() { + return Status::OK(); +} + +Status FindPathExecutor::prepareClauses() { spaceId_ = ectx()->rctx()->session()->space(); Status status; expCtx_ = std::make_unique(); @@ -71,6 +75,11 @@ Status FindPathExecutor::beforeExecute() { break;; } + status = prepareClauses(); + if (!status.ok()) { + break; + } + status = prepareOver(); if (!status.ok()) { break; diff --git a/src/graph/FindPathExecutor.h b/src/graph/FindPathExecutor.h index 0ad811249ef..f2d72f5751b 100644 --- a/src/graph/FindPathExecutor.h +++ b/src/graph/FindPathExecutor.h @@ -53,6 +53,8 @@ class FindPathExecutor final : public TraverseExecutor { cpp2::RowValue buildPathRow(const Path &path); private: + Status prepareClauses(); + // Do some prepare work that can not do in prepare() Status beforeExecute(); diff --git a/src/graph/test/FindPathTest.cpp b/src/graph/test/FindPathTest.cpp index f21f9acb7f9..6f6a0c0afab 100644 --- a/src/graph/test/FindPathTest.cpp +++ b/src/graph/test/FindPathTest.cpp @@ -559,6 +559,25 @@ TEST_F(FindPathTest, UseUUID) { ASSERT_TRUE(resp.get_rows() != nullptr); ASSERT_EQ(resp.get_rows()->size(), 1); } + { + // without use space + auto client = gEnv->getClient(); + cpp2::ExecutionResponse resp; + auto query = "FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") " + "OVER like UPTO 5 STEPS"; + auto code = client->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code); + ASSERT_EQ("Please choose a graph space with `USE spaceName' firstly", + *(resp.get_error_msg())); + + // multi sentences + query = "USE nba; FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") " + "OVER like UPTO 5 STEPS"; + code = client->execute(query, resp); + ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << *(resp.get_error_msg()); + ASSERT_TRUE(resp.get_rows() != nullptr); + ASSERT_EQ(resp.get_rows()->size(), 1); + } } } // namespace graph } // namespace nebula