Skip to content

Commit

Permalink
Merge pull request #56 from alxsabo/v5.2
Browse files Browse the repository at this point in the history
Sync with JVM client 5.2.4
  • Loading branch information
ml054 authored Dec 6, 2023
2 parents 0fafc79 + dab44dd commit 61e72e9
Show file tree
Hide file tree
Showing 417 changed files with 2,358 additions and 961 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/RavenClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: [ "8.1", "8.2" ]
serverVersion: [ "5.2", "5.4" ]
fail-fast: false

env:
RAVENDB_BUILD_TYPE: nightly
RAVEN_License: ${{ secrets.RAVEN_LICENSE }}
Expand All @@ -21,12 +27,8 @@ jobs:
RAVENDB_PHP_TEST_CA_PATH: "/usr/local/share/ca-certificates/ca.crt"
RAVENDB_TEST_CLIENT_CERT_PATH: "./certs/java.pem"

SERVER_VERSION: ${{ matrix.serverVersion }}

strategy:
matrix:
php-versions: [ "8.1", "8.2" ]
serverVersion: [ "5.2", "5.4" ]
fail-fast: false

steps:
- name: Check out repository code
Expand Down
39 changes: 39 additions & 0 deletions src/Documents/BulkInsert/BulkInsertOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace RavenDB\Documents\BulkInsert;

class BulkInsertOptions
{
private bool $useCompression = false;
private bool $skipOverwriteIfUnchanged = false;

public function isUseCompression(): bool
{
return $this->useCompression;
}

public function setUseCompression(bool $useCompression): void
{
$this->useCompression = $useCompression;
}

/**
* Determines whether we should skip overwriting a document when it is updated by exactly the same document (by comparing the content and the metadata)
*
* @return bool
*/
public function isSkipOverwriteIfUnchanged(): bool
{
return $this->skipOverwriteIfUnchanged;
}

/**
* Determines whether we should skip overwriting a document when it is updated by exactly the same document (by comparing the content and the metadata)
*
* @param bool $skipOverwriteIfUnchanged
*/
public function setSkipOverwriteIfUnchanged(bool $skipOverwriteIfUnchanged): void
{
$this->skipOverwriteIfUnchanged = $skipOverwriteIfUnchanged;
}
}
2 changes: 1 addition & 1 deletion src/Documents/Commands/Batches/BatchPatchCommandData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Commands that patches multiple documents using same patch script
* CAUTION: This command does not update session state after .saveChanges() call
*/
// !status: DONE

class BatchPatchCommandData implements CommandDataInterface
{
private StringSet $seenIds;
Expand Down
2 changes: 0 additions & 2 deletions src/Documents/Commands/Batches/ClusterWideBatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use RavenDB\Documents\Session\TransactionMode;
use RavenDB\Http\RaftCommandInterface;
use RavenDB\Utils\RaftIdGenerator;

// !status: DONE
class ClusterWideBatchCommand extends SingleNodeBatchCommand implements RaftCommandInterface
{
private ?bool $disableAtomicDocumentWrites = null;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/Batches/CommandType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use RavenDB\Exceptions\IllegalArgumentException;

// !status: DONE
class CommandType
{
const NONE = 'None';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use RavenDB\Exceptions\IllegalArgumentException;
use RavenDB\Utils\StringUtils;

// !status: DONE
class CopyAttachmentCommandData implements CommandDataInterface
{
private ?string $id = null;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/Batches/DeleteCommandData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use RavenDB\Documents\Session\InMemoryDocumentSessionOperations;
use RavenDB\Exceptions\IllegalArgumentException;

// !status: DONE
class DeleteCommandData implements CommandDataInterface
{
private string $id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use RavenDB\Documents\Conventions\DocumentConventions;
use RavenDB\Documents\Session\InMemoryDocumentSessionOperations;

// !status: DONE
class DeleteCompareExchangeCommandData implements CommandDataInterface
{
public ?int $index;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/Batches/IdAndChangeVector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RavenDB\Documents\Commands\Batches;

// !status: DONE
class IdAndChangeVector
{
private ?string $id = null;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/Batches/IdAndChangeVectorList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use RavenDB\Type\TypedList;

// !status: DONE
class IdAndChangeVectorList extends TypedList
{
public function __construct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use RavenDB\Exceptions\IllegalArgumentException;
use RavenDB\Utils\StringUtils;

// !status: DONE
class MoveAttachmentCommandData implements CommandDataInterface
{
private ?string $id = null;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/Batches/PatchCommandData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use RavenDB\Documents\Session\InMemoryDocumentSessionOperations;
use RavenDB\Exceptions\IllegalArgumentException;

// !status: DONE
class PatchCommandData implements CommandDataInterface
{
private string $id;
Expand Down
3 changes: 2 additions & 1 deletion src/Documents/Commands/ConditionalGetDocumentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace RavenDB\Documents\Commands;

use RavenDB\Constants\Headers;
use RavenDB\Constants\HttpStatusCode;
use RavenDB\Http\HttpCache;
use RavenDB\Http\HttpRequest;
Expand Down Expand Up @@ -38,7 +39,7 @@ public function createRequest(ServerNode $serverNode): HttpRequestInterface
{
$request = new HttpRequest($this->createUrl($serverNode), HttpRequest::GET);

$request->addHeader("If-None-Match", $this->changeVector);
$request->addHeader(Headers::IF_NONE_MATCH, $this->changeVector);

return $request;
}
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/DeleteDocumentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use RavenDB\Http\ServerNode;
use RavenDB\Http\VoidRavenCommand;

// !status: DONE
class DeleteDocumentCommand extends VoidRavenCommand
{
private ?string $id = null;
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/ExplainQueryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Symfony\Component\Serializer\Annotation\SerializedName;

// !status: DONE
class ExplainQueryResponse
{
/** @SerializedName ("IndexName") */
Expand Down
1 change: 0 additions & 1 deletion src/Documents/Commands/ExplainQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Symfony\Component\Serializer\Annotation\SerializedName;

// !status: DONE
class ExplainQueryResult implements ResultInterface
{
/** @SerializedName ("Index") */
Expand Down
97 changes: 71 additions & 26 deletions src/Documents/Commands/GetDocumentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace RavenDB\Documents\Commands;

use DateTime;
use InvalidArgumentException;
use RavenDB\Constants\Counters;
use RavenDB\Documents\Operations\TimeSeries\AbstractTimeSeriesRangeSet;
Expand All @@ -18,7 +19,6 @@
use RavenDB\Type\StringArray;
use RavenDB\Utils\UrlUtils;

// !status: DONE
class GetDocumentsCommand extends RavenCommand
{
private string $id = '';
Expand All @@ -29,6 +29,8 @@ class GetDocumentsCommand extends RavenCommand
private bool $includeAllCounters = false;

private ?AbstractTimeSeriesRangeSet $timeSeriesIncludes = null;
private ?StringArray $revisionsIncludeByChangeVector = null;
private ?DateTime $revisionsIncludeByDateTime = null;
private ?StringArray $compareExchangeValueIncludes = null;

private bool $metadataOnly = false;
Expand All @@ -45,34 +47,32 @@ public function __construct()
parent::__construct(GetDocumentsResult::class);
}

/**
* @param StringArray|array|null $ids
*/
protected function setIds($ids): void
protected function setIds(StringArray|array|null $ids): void
{
$this->ids = is_array($ids) ? StringArray::fromArray($ids, true) : $ids;
}

/**
* @param StringArray|array|null $includes
*/
protected function setIncludes($includes): void
protected function setIncludes(StringArray|array|null $includes): void
{
$this->includes = is_array($includes) ? StringArray::fromArray($includes) : $includes;
}

/**
* @param StringArray|array|null $counters
*/
protected function setCounters($counters)
protected function setCounters(StringArray|array|null $counters)
{
$this->counters = is_array($counters) ? StringArray::fromArray($counters) : $counters;
}

/**
* @param StringArray|array|null $compareExchangeValueIncludes
*/
protected function setCompareExchangeValueIncludes($compareExchangeValueIncludes)
public function setRevisionsIncludeByChangeVector(StringArray|array|null $revisionsIncludeByChangeVector): void
{
$this->revisionsIncludeByChangeVector = is_array($revisionsIncludeByChangeVector) ? StringArray::fromArray($revisionsIncludeByChangeVector) : $revisionsIncludeByChangeVector;
}

public function setRevisionsIncludeByDateTime(?DateTime $revisionsIncludeByDateTime): void
{
$this->revisionsIncludeByDateTime = $revisionsIncludeByDateTime;
}

protected function setCompareExchangeValueIncludes(StringArray|array|null $compareExchangeValueIncludes)
{
$this->compareExchangeValueIncludes = is_array($compareExchangeValueIncludes) ? StringArray::fromArray($compareExchangeValueIncludes) : $compareExchangeValueIncludes;
}
Expand All @@ -83,7 +83,7 @@ protected function setCompareExchangeValueIncludes($compareExchangeValueIncludes
* @param bool $metadataOnly
* @return GetDocumentsCommand
*/
public static function forMultipleDocuments($ids, $includes, bool $metadataOnly = false): GetDocumentsCommand
public static function forMultipleDocuments(StringArray|array|null $ids, StringArray|array|null $includes, bool $metadataOnly = false): GetDocumentsCommand
{
if (empty($ids)) {
throw new InvalidArgumentException("Please supply at least one id");
Expand All @@ -103,7 +103,7 @@ public static function forMultipleDocuments($ids, $includes, bool $metadataOnly
* @param bool $metadataOnly
* @return GetDocumentsCommand
*/
public static function forSingleDocument(string $id, $includes = null, bool $metadataOnly = false): GetDocumentsCommand
public static function forSingleDocument(string $id, StringArray|array|null $includes = null, bool $metadataOnly = false): GetDocumentsCommand
{
if (empty($id)) {
throw new IllegalArgumentException("id cannot be null");
Expand Down Expand Up @@ -137,16 +137,20 @@ public static function withStartAndPageSize(int $start, int $pageSize): GetDocum
* @return GetDocumentsCommand
*/
public static function withCounters(
$ids,
$includes,
$counterIncludes,
StringArray|array|null $ids,
StringArray|array|null $includes,
StringArray|array|null $counterIncludes,
StringArray|array|null $revisionsIncludeByChangeVector,
DateTime|null $revisionsIncludeByDateTime,
?AbstractTimeSeriesRangeSet $timeSeriesIncludes,
$compareExchangeValueIncludes,
StringArray|array|null $compareExchangeValueIncludes,
bool $metadata
): GetDocumentsCommand {
$command = GetDocumentsCommand::forMultipleDocuments($ids, $includes, $metadata);

$command->setCounters($counterIncludes);
$command->setRevisionsIncludeByChangeVector($revisionsIncludeByChangeVector);
$command->setRevisionsIncludeByDateTime($revisionsIncludeByDateTime);
$command->timeSeriesIncludes = $timeSeriesIncludes;
$command->setCompareExchangeValueIncludes($compareExchangeValueIncludes);

Expand All @@ -163,11 +167,11 @@ public static function withCounters(
* @return GetDocumentsCommand
*/
public static function withAllCounters(
$ids,
$includes,
StringArray|array|null $ids,
StringArray|array|null $includes,
bool $includeAllCounters,
AbstractTimeSeriesRangeSet $timeSeriesIncludes,
$compareExchangeValueIncludes,
StringArray|array|null $compareExchangeValueIncludes,
bool $metadataOnly
): GetDocumentsCommand {
$command = GetDocumentsCommand::forMultipleDocuments($ids, $includes, $metadataOnly);
Expand All @@ -179,6 +183,36 @@ public static function withAllCounters(
return $command;
}

/**
* @param StringArray|array|null $ids
* @param StringArray|array|null $includes
* @param StringArray|array|null $counterIncludes
* @param AbstractTimeSeriesRangeSet $timeSeriesIncludes
* @param StringArray|array|null $compareExchangeValueIncludes
* @param bool $metadataOnly
* @return GetDocumentsCommand
*/
public static function withRevisions(
StringArray|array|null $ids,
StringArray|array|null $includes,
StringArray|array|null $counterIncludes,
StringArray|array|null $revisionsIncludesByChangeVector,
?DateTime $revisionIncludeByDateTimeBefore,
AbstractTimeSeriesRangeSet $timeSeriesIncludes,
StringArray|array|null $compareExchangeValueIncludes,
bool $metadataOnly
): GetDocumentsCommand {
$command = GetDocumentsCommand::forMultipleDocuments($ids, $includes, $metadataOnly);

$command->setCounters($counterIncludes);
$command->setRevisionsIncludeByChangeVector($revisionsIncludesByChangeVector);
$command->setRevisionsIncludeByDateTime($revisionIncludeByDateTimeBefore);
$command->timeSeriesIncludes = $timeSeriesIncludes;
$command->setCompareExchangeValueIncludes($compareExchangeValueIncludes);

return $command;
}

public static function withStartWith(
?string $startWith,
?string $startAfter,
Expand Down Expand Up @@ -280,6 +314,17 @@ public function createUrl(ServerNode $serverNode): string
}
}

if (($this->revisionsIncludeByChangeVector !== null) && count($this->revisionsIncludeByChangeVector)) {
foreach ($this->revisionsIncludeByChangeVector as $changeVector) {
$path .= "&revisions=" . UrlUtils::escapeDataString($changeVector);
}
}

if ($this->revisionsIncludeByDateTime !== null) {
$path .= "&revisionsBefore=" . UrlUtils::escapeDataString(NetISO8601Utils::format($this->revisionsIncludeByDateTime, true));
}


if (($this->compareExchangeValueIncludes !== null) && count($this->compareExchangeValueIncludes)) {
foreach ($this->compareExchangeValueIncludes as $compareExchangeValue) {
$path .= "&cmpxchg=" . urlEncode($compareExchangeValue);
Expand Down
Loading

0 comments on commit 61e72e9

Please sign in to comment.