Compare commits

...

2 Commits

Author SHA1 Message Date
Cerys Lewis 1cd138b3bd returns proper constructors 5 months ago
Cerys Lewis b1055d3148 aligning 5 months ago
  1. 18
      src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php
  2. 10
      src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php
  3. 8
      src/QueryBuilder/QueryBuilders/PutQueryBuilder.php
  4. 8
      src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php
  5. 4
      src/QueryInstance/GrantQuery.php
  6. 3
      src/QueryInstance/InsertQuery.php
  7. 2
      src/QueryInstance/PutQuery.php

18
src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php

@ -27,9 +27,10 @@ final class GrantQueryBuilder implements QueryBuilderInterface
public function Build(): GrantQuery public function Build(): GrantQuery
{ {
$builder = "GRANT "; $builder = "GRANT ";
if(sizeof($this->PermissionTypes)) $builder .= implode(separator: ",", array: $this->PermissionTypes);
if($this->GrantOn != "") $builder .= " ON $this->GrantOn"; if(sizeof($this->PermissionTypes)) $builder .= implode(separator: ",", array: $this->PermissionTypes);
if($this->GrantWhere != "") $builder .= " WHERE $this->GrantWhere"; if($this->GrantOn != "") $builder .= " ON $this->GrantOn";
if($this->GrantWhere != "") $builder .= " WHERE $this->GrantWhere";
return new GrantQuery(queryString: $builder); return new GrantQuery(queryString: $builder);
} }
@ -64,4 +65,15 @@ final class GrantQueryBuilder implements QueryBuilderInterface
$this->GrantWhere = "$target $operator->value $value"; $this->GrantWhere = "$target $operator->value $value";
return $this; return $this;
} }
public function IsDelegatable(): GrantQueryBuilder
{
$this->GrantDelegatable = true;
return $this;
}
public function NotDelegatable(): GrantQueryBuilder
{
$this->GrantDelegatable = false;
return $this;
}
} }

10
src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php

@ -34,11 +34,11 @@ final class InsertQueryBuilder implements QueryBuilderInterface
$builder = "INSERT INTO $this->RelativePath"; $builder = "INSERT INTO $this->RelativePath";
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys); if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys);
if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas); if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas);
if($this->Values != "") $builder .= "VALUES $this->Values"; if($this->Values != "") $builder .= "VALUES " . $this->Values;
if($this->Duplicate) $builder .= "DUPLICATE"; if($this->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE"; if($this->Replace) $builder .= "REPLACE";
return new InsertQuery($builder); return new InsertQuery($builder);
} }

8
src/QueryBuilder/QueryBuilders/PutQueryBuilder.php

@ -25,13 +25,13 @@ final class PutQueryBuilder implements QueryBuilderInterface
public function Build(): PutQuery public function Build(): PutQuery
{ {
$builder = "PUT $this->PutWhat"; $builder = "PUT $this->PutWhat";
if($this->PutData != "") $builder .= " \"$this->PutData\" "; if($this->PutData != "") $builder .= " \"$this->PutData\" ";
if($this->PutAt != "") $builder .= "AT $this->PutAt"; if($this->PutAt != "") $builder .= "AT " . $this->PutAt;
elseif($this->PutInto != "") $builder .= "INTO $this->PutInto"; elseif($this->PutInto != "") $builder .= "INTO " . $this->PutInto;
else throw new QueryBuilderRequiredFieldIsNotSetException(); else throw new QueryBuilderRequiredFieldIsNotSetException();
if($this->Safe) $builder .= " SAFE"; if($this->Safe) $builder .= " SAFE";
return new PutQuery($builder); return new PutQuery($builder);
} }

8
src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php

@ -34,10 +34,10 @@ final class SelectQueryBuilder implements QueryBuilderInterface
public function Build(): SelectQuery public function Build(): SelectQuery
{ {
$builder = "SELECT "; $builder = "SELECT ";
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths); if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);
if($this->From != "") $builder .= " FROM $this->From"; if($this->From != "") $builder .= " FROM " . $this->From;
if($this->Where != "") $builder .= " WHERE $this->Where"; if($this->Where != "") $builder .= " WHERE " . $this->Where;
if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf"; if($this->InstanceOf != "") $builder .= " INSTANCEOF " . $this->InstanceOf;
return new SelectQuery(queryString: $builder); return new SelectQuery(queryString: $builder);
} }

4
src/QueryInstance/GrantQuery.php

@ -9,13 +9,13 @@ use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class GrantQuery extends QueryInstanceSuperclass implements QueryInstanceInterface final class GrantQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{ {
public function RunQuery(DeegraphServer $deegraphServer) public function RunQuery(DeegraphServer $deegraphServer): GrantQueryResponse
{ {
$response = $deegraphServer->RunRawRequest( $response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query", endpoint: "/api/v1/@query",
method: "POST", method: "POST",
body: $this->QueryString, body: $this->QueryString,
); );
return GrantQueryResponse::FromAPIResponse(response: $response); return new GrantQueryResponse(response: $response);
} }
} }

3
src/QueryInstance/InsertQuery.php

@ -3,6 +3,7 @@
namespace Darksparrow\DeegraphInteractions\QueryInstance; namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\InsertQueryResponse; use Darksparrow\DeegraphInteractions\QueryResponse\InsertQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass; use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
@ -15,6 +16,6 @@ final class InsertQuery extends QueryInstanceSuperclass implements QueryInstance
method: "POST", method: "POST",
body: $this->QueryString, body: $this->QueryString,
); );
return InsertQueryResponse::FromAPIResponse(response: $response); return new InsertQueryResponse(response: $response);
} }
} }

2
src/QueryInstance/PutQuery.php

@ -16,6 +16,6 @@ final class PutQuery extends QueryInstanceSuperclass implements QueryResponseInt
method: "POST", method: "POST",
body: $this->QueryString, body: $this->QueryString,
); );
return PutQueryResponse::FromAPIResponse(response: $response); return new PutQueryResponse(response: $response);
} }
} }

Loading…
Cancel
Save