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. 12
      src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php
  2. 2
      src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php
  3. 4
      src/QueryBuilder/QueryBuilders/PutQueryBuilder.php
  4. 6
      src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php
  5. 4
      src/QueryInstance/GrantQuery.php
  6. 3
      src/QueryInstance/InsertQuery.php
  7. 2
      src/QueryInstance/PutQuery.php

12
src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php

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

2
src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php

@ -36,7 +36,7 @@ final class InsertQueryBuilder implements QueryBuilderInterface
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($this->Values != "") $builder .= "VALUES $this->Values";
if($this->Values != "") $builder .= "VALUES " . $this->Values;
if($this->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";

4
src/QueryBuilder/QueryBuilders/PutQueryBuilder.php

@ -27,8 +27,8 @@ final class PutQueryBuilder implements QueryBuilderInterface
$builder = "PUT $this->PutWhat";
if($this->PutData != "") $builder .= " \"$this->PutData\" ";
if($this->PutAt != "") $builder .= "AT $this->PutAt";
elseif($this->PutInto != "") $builder .= "INTO $this->PutInto";
if($this->PutAt != "") $builder .= "AT " . $this->PutAt;
elseif($this->PutInto != "") $builder .= "INTO " . $this->PutInto;
else throw new QueryBuilderRequiredFieldIsNotSetException();
if($this->Safe) $builder .= " SAFE";

6
src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php

@ -35,9 +35,9 @@ final class SelectQueryBuilder implements QueryBuilderInterface
{
$builder = "SELECT ";
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);
if($this->From != "") $builder .= " FROM $this->From";
if($this->Where != "") $builder .= " WHERE $this->Where";
if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf";
if($this->From != "") $builder .= " FROM " . $this->From;
if($this->Where != "") $builder .= " WHERE " . $this->Where;
if($this->InstanceOf != "") $builder .= " INSTANCEOF " . $this->InstanceOf;
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
{
public function RunQuery(DeegraphServer $deegraphServer)
public function RunQuery(DeegraphServer $deegraphServer): GrantQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query",
method: "POST",
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;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\InsertQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
@ -15,6 +16,6 @@ final class InsertQuery extends QueryInstanceSuperclass implements QueryInstance
method: "POST",
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",
body: $this->QueryString,
);
return PutQueryResponse::FromAPIResponse(response: $response);
return new PutQueryResponse(response: $response);
}
}

Loading…
Cancel
Save