Skip to content

Commit d8465a0

Browse files
committed
fixed consistency when running one-off transactions with http
fixes #49
1 parent 6f2bb6b commit d8465a0

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ services:
2424
- readreplica1
2525
expose:
2626
- 9000
27-
environment:
28-
- XDEBUG_MODE=coverage
2927
neo4j:
3028
networks:
3129
- neo4j

src/Network/Http/HttpSession.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function __construct(RequestFactory $factory, ClientInterface $client, Ht
5252
public function run(iterable $statements): Vector
5353
{
5454
$request = $this->factory->post($this->data, $statements);
55+
$uri = $request->getUri();
56+
$request = $request->withUri($uri->withPath($uri->getPath() . '/commit'));
5557
$response = $this->client->sendRequest($request);
5658
$data = $this->interpretResponse($response);
5759

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
5+
namespace Laudis\Neo4j\Tests\Integration;
6+
7+
8+
use Laudis\Neo4j\ClientBuilder;
9+
use Laudis\Neo4j\Contracts\ClientInterface;
10+
use PHPUnit\Framework\TestCase;
11+
12+
final class HttpConsistencyTest extends TestCase
13+
{
14+
private ClientInterface $client;
15+
16+
protected function setUp(): void
17+
{
18+
parent::setUp();
19+
$this->client = ClientBuilder::create()
20+
->addHttpConnection('default', 'http://neo4j:test@neo4j')
21+
->setDefaultConnection('default')
22+
->build();
23+
}
24+
25+
public function testConsistency(): void
26+
{
27+
$res = $this->client->run('MERGE (n:zzz {name: "bbbb"}) RETURN n');
28+
self::assertEquals(1, $res->count());
29+
self::assertEquals(['name' => 'bbbb'], $res->first()->get('n'));
30+
31+
$res = $this->client->run('MATCH (n:zzz {name: $name}) RETURN n', ['name' => 'bbbb']);
32+
self::assertEquals(1, $res->count());
33+
self::assertEquals(['name' => 'bbbb'], $res->first()->get('n'));
34+
}
35+
}

0 commit comments

Comments
 (0)