Skip to content

Commit ead3573

Browse files
committed
correctly pass through read only mode from session
1 parent bde2564 commit ead3573

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Bolt/BoltConnection.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function reset(): void
179179
public function begin(?string $database, ?float $timeout, BookmarkHolder $holder): void
180180
{
181181
$this->consumeResults();
182-
$extra = $this->buildRunExtra($database, $timeout, $holder);
182+
$extra = $this->buildRunExtra($database, $timeout, $holder, AccessMode::WRITE());
183183

184184
$response = $this->protocol()
185185
->begin($extra)
@@ -211,9 +211,9 @@ public function discard(?int $qid): void
211211
*
212212
* @return BoltMeta
213213
*/
214-
public function run(string $text, array $parameters, ?string $database, ?float $timeout, BookmarkHolder $holder): array
214+
public function run(string $text, array $parameters, ?string $database, ?float $timeout, BookmarkHolder $holder, ?AccessMode $mode): array
215215
{
216-
$extra = $this->buildRunExtra($database, $timeout, $holder);
216+
$extra = $this->buildRunExtra($database, $timeout, $holder, $mode);
217217
$response = $this->protocol()->run($text, $parameters, $extra)
218218
->getResponse();
219219

@@ -293,7 +293,7 @@ public function __destruct()
293293
}
294294
}
295295

296-
private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolder $holder): array
296+
private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolder $holder, ?AccessMode $mode): array
297297
{
298298
$extra = [];
299299
if ($database) {
@@ -307,6 +307,10 @@ private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolde
307307
$extra['bookmarks'] = $holder->getBookmark()->values();
308308
}
309309

310+
if ($mode) {
311+
$extra['mode'] = AccessMode::WRITE() === $mode ? 'w' : 'r';
312+
}
313+
310314
return $extra;
311315
}
312316

src/Bolt/BoltUnmanagedTransaction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public function runStatement(Statement $statement)
105105
$parameters->toArray(),
106106
$this->database,
107107
$this->tsxConfig->getTimeout(),
108-
$this->bookmarkHolder
108+
$this->bookmarkHolder,
109+
$this->config->getAccessMode()
109110
);
110111
} catch (Throwable $e) {
111112
$this->isRolledBack = true;

0 commit comments

Comments
 (0)