Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 33f52f7

Browse files
authored
Merge pull request #104 from adam-cowley/master
Throw Exception on empty query string. Fixes #101
2 parents 2041c6a + d5cff49 commit 33f52f7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Connection/Connection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public function createPipeline($query = null, $parameters = [], $tag = null)
107107
public function run($statement, $parameters = null, $tag = null)
108108
{
109109
$this->checkSession();
110+
if (empty($statement)) {
111+
throw new \InvalidArgumentException(sprintf('Expected a non-empty Cypher statement, got "%s"', $statement));
112+
}
110113
$parameters = (array) $parameters;
111114

112115
try {

tests/Integration/CypherIntegrationTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,12 @@ public function testPathIsReturned()
5757
$this->assertInstanceOf(Path::class, $record1->get('p'));
5858
$this->assertInstanceOf(Path::class, $record2->get('p'));
5959
}
60+
61+
/**
62+
* @expectedException InvalidArgumentException
63+
*/
64+
public function testExceptionIsThrownOnEmptyStatement() {
65+
$query = '';
66+
$this->client->run($query);
67+
}
6068
}

0 commit comments

Comments
 (0)