From bfc699be33121da5bd9efad23c3faaf7c5f527c7 Mon Sep 17 00:00:00 2001 From: Cerys Date: Sat, 30 Nov 2024 00:44:54 +0000 Subject: [PATCH] some work on the DELETE query --- src/QueryBuilder/DeleteQuery/DeleteQuery.php | 31 ++++++++++++++++ .../DeleteQuery/DeleteQueryBuilder.php | 35 +++++++++++++++++++ .../DeleteQuery/DeleteQueryResponse.php | 10 ++++++ src/QueryBuilder/QueryBuilder.php | 5 +++ src/QueryBuilder/QueryBuilderTrait.php | 4 ++- tests/QueryBuilderDeleteTest.php | 22 ++++++++++++ 6 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/QueryBuilder/DeleteQuery/DeleteQuery.php create mode 100644 src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php create mode 100644 src/QueryBuilder/DeleteQuery/DeleteQueryResponse.php create mode 100644 tests/QueryBuilderDeleteTest.php diff --git a/src/QueryBuilder/DeleteQuery/DeleteQuery.php b/src/QueryBuilder/DeleteQuery/DeleteQuery.php new file mode 100644 index 0000000..701d9de --- /dev/null +++ b/src/QueryBuilder/DeleteQuery/DeleteQuery.php @@ -0,0 +1,31 @@ +QueryString = $queryString; + } + public function __toString() + { + return $this->QueryString; + } + + public function RunQuery(DeegraphServer $server): DeleteQueryResponse + { + $response = $server->RunRawRequest( + endpoint: "/api/v1/@query", + method: "POST", + body: $this->QueryString + ); + $temp = json_decode($response, true); + return new DeleteQueryResponse($temp); + } +} diff --git a/src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php b/src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php new file mode 100644 index 0000000..cc9d160 --- /dev/null +++ b/src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php @@ -0,0 +1,35 @@ +RelativePath = $relativePath; + return $this; + } + + public function Build(): DeleteQuery + { + self::ValidateValues(target: $this); + + $builder = "DELETE " . $this->RelativePath; + + return new DeleteQuery(queryString: $builder); + } +} diff --git a/src/QueryBuilder/DeleteQuery/DeleteQueryResponse.php b/src/QueryBuilder/DeleteQuery/DeleteQueryResponse.php new file mode 100644 index 0000000..73c1b1d --- /dev/null +++ b/src/QueryBuilder/DeleteQuery/DeleteQueryResponse.php @@ -0,0 +1,10 @@ +RelativePath($this->TestUUID) + ->Build(); + self::assertEquals( + expected: "DELETE {$this->TestUUID}", + actual: $query + ); + } +}