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
{
$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";
if(sizeof($this->PermissionTypes)) $builder .= implode(separator: ",", array: $this->PermissionTypes);
if($this->GrantOn != "") $builder .= " ON $this->GrantOn";
if($this->GrantWhere != "") $builder .= " WHERE $this->GrantWhere";
return new GrantQuery(queryString: $builder);
}
@ -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;
}
}

10
src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php

@ -34,11 +34,11 @@ final class InsertQueryBuilder implements QueryBuilderInterface
$builder = "INSERT INTO $this->RelativePath";
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->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";
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->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";
return new InsertQuery($builder);
}

8
src/QueryBuilder/QueryBuilders/PutQueryBuilder.php

@ -25,13 +25,13 @@ final class PutQueryBuilder implements QueryBuilderInterface
public function Build(): PutQuery
{
$builder = "PUT $this->PutWhat";
if($this->PutData != "") $builder .= " \"$this->PutData\" ";
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";
if($this->Safe) $builder .= " SAFE";
return new PutQuery($builder);
}

8
src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php

@ -34,10 +34,10 @@ final class SelectQueryBuilder implements QueryBuilderInterface
public function Build(): SelectQuery
{
$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(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;
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