Skip to content

Commit d784312

Browse files
committed
temp commit
1 parent 7dc5243 commit d784312

File tree

7 files changed

+74
-15
lines changed

7 files changed

+74
-15
lines changed

src/Authentication/BasicAuth.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace Laudis\Neo4j\Authentication;
1515

16+
use Bolt\enum\Signature;
17+
use Bolt\protocol\Response;
1618
use Bolt\protocol\V4_4;
1719
use Bolt\protocol\V5;
1820
use Bolt\protocol\V5_1;

src/Bolt/BoltConnection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public function reset(): void
207207
public function begin(?string $database, ?float $timeout, BookmarkHolder $holder, ?iterable $txMetaData): void
208208
{
209209
$this->consumeResults();
210+
// ADD THIS: Authenticate the connection before beginning transaction
211+
$this->auth->authenticateBolt($this, $this->userAgent);
210212

211213
$extra = $this->buildRunExtra($database, $timeout, $holder, AccessMode::WRITE(), $txMetaData);
212214
$message = $this->messageFactory->createBeginMessage($extra);

src/Bolt/Session.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,37 @@ public function beginTransaction(?iterable $statements = null, ?TransactionConfi
173173

174174
return $tsx;
175175
}
176+
/**
177+
* Begin a read transaction.
178+
*
179+
* @param iterable<Statement>|null $statements
180+
*/
181+
public function beginReadTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface
182+
{
183+
$this->getLogger()?->log(LogLevel::INFO, 'Beginning read transaction', ['statements' => $statements, 'config' => $config]);
184+
$config = $this->mergeTsxConfig($config);
185+
$tsx = $this->startTransaction($config, $this->config->withAccessMode(AccessMode::READ()));
186+
187+
$tsx->runStatements($statements ?? []);
188+
189+
return $tsx;
190+
}
191+
192+
/**
193+
* Begin a write transaction.
194+
*
195+
* @param iterable<Statement>|null $statements
196+
*/
197+
public function beginWriteTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface
198+
{
199+
$this->getLogger()?->log(LogLevel::INFO, 'Beginning write transaction', ['statements' => $statements, 'config' => $config]);
200+
$config = $this->mergeTsxConfig($config);
201+
$tsx = $this->startTransaction($config, $this->config->withAccessMode(AccessMode::write()));
202+
203+
$tsx->runStatements($statements ?? []);
204+
205+
return $tsx;
206+
}
176207

177208
/**
178209
* @return UnmanagedTransactionInterface

src/Contracts/SessionInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ public function run(string $statement, iterable $parameters = [], ?TransactionCo
4747
* @throws Neo4jException
4848
*/
4949
public function beginTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface;
50+
/**
51+
* Begin a read transaction.
52+
*
53+
* @param iterable<Statement>|null $statements
54+
*
55+
* @throws Neo4jException
56+
*/
57+
public function beginReadTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface;
58+
59+
/**
60+
* Begin a write transaction.
61+
*
62+
* @param iterable<Statement>|null $statements
63+
*
64+
* @throws Neo4jException
65+
*/
66+
public function beginWriteTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface;
5067

5168
/**
5269
* @template HandlerResult

src/Databags/SummarizedResult.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ final class SummarizedResult extends CypherList
3939
* @param iterable<mixed, CypherMap<OGMTypes>>|callable():Generator<mixed, CypherMap<OGMTypes>> $iterable
4040
* @param list<string> $keys
4141
*/
42-
public function __construct(?ResultSummary &$summary, iterable|callable $iterable = [], array $keys)
42+
public function __construct(?ResultSummary &$summary, iterable|callable $iterable = [])
4343
{
4444
parent::__construct($iterable);
4545
$this->summary = &$summary;
46-
$this->keys = $keys;
4746
}
4847

4948
/**
@@ -78,11 +77,4 @@ public function jsonSerialize(): array
7877
];
7978
}
8079

81-
/**
82-
* @return list<string>
83-
*/
84-
public function keys(): array
85-
{
86-
return $this->keys;
87-
}
8880
}

testkit-backend/src/Handlers/SessionReadTransaction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function handle($request): TestkitResponseInterface
6464
$id = Uuid::v4();
6565
try {
6666
// TODO - Create beginReadTransaction and beginWriteTransaction
67-
$transaction = $session->beginTransaction(null, $config);
67+
68+
$transaction = $session->beginReadTransaction(null, $config);
6869

6970
$this->repository->addTransaction($id, $transaction);
7071
$this->repository->bindTransactionToSession($request->getSessionId(), $id);

testkit-backend/testkit.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ EXIT_CODE=0
7878

7979
####stub
8080
####test-basic-query
81-
python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_5x0_populates_path_element_ids_with_string
82-
python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_node_element_id_with_id
83-
python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_5x0_populates_node_element_id_with_string
84-
python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_rel_element_id_with_id
85-
python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_path_element_ids_with_long
81+
#python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_5x0_populates_path_element_ids_with_string
82+
#python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_node_element_id_with_id
83+
#python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_5x0_populates_node_element_id_with_string
84+
#python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_rel_element_id_with_id
85+
#python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_4x4_populates_path_element_ids_with_long
8686

8787
##test_tx_run
8888
#tx_run
@@ -110,4 +110,18 @@ python3 -m unittest tests.stub.basic_query.test_basic_query.TestBasicQuery.test_
110110
#python3 -m unittest tests.neo4j.test_tx_run.TestTxRun.test_interwoven_queries || EXIT_CODE=1
111111
#python3 -m unittest tests.neo4j.test_tx_run.TestTxRun.test_unconsumed_result || EXIT_CODE=1
112112

113+
114+
#test_tx_func_run
115+
116+
python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_simple_query
117+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_parameter
118+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_meta_data
119+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_iteration_nested
120+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_updates_last_bookmark_on_commit
121+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_does_not_update_last_bookmark_on_rollback
122+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_client_exception_rolls_back_change
123+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_tx_func_configuration
124+
#python3 -m unittest tests.neo4j.test_tx_func_run.TestTxFuncRun.test_tx_timeout
125+
126+
113127
exit $EXIT_CODE

0 commit comments

Comments
 (0)