Skip to content

Commit

Permalink
prooph#189 Consistenly use single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-gerneth committed Feb 7, 2019
1 parent 3c719c1 commit cc3d043
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/WriteLockStrategy/MariaDbMetadataLockStrategy.php
Expand Up @@ -40,7 +40,7 @@ public function __construct(\PDO $connection, int $timeout = 0xffffff)
public function getLock(string $name): bool
{
try {
$res = $this->connection->query('SELECT GET_LOCK("' . $name . '", ' . $this->timeout . ') as `get_lock`');
$res = $this->connection->query('SELECT GET_LOCK(\'' . $name . '\', ' . $this->timeout . ') as \'get_lock\'');
} catch (\PDOException $e) {
// ER_USER_LOCK_DEADLOCK: we only care for deadlock errors and fail locking
if ('3058' === $this->connection->errorCode()) {
Expand All @@ -64,7 +64,7 @@ public function getLock(string $name): bool

public function releaseLock(string $name): bool
{
$this->connection->exec('DO RELEASE_LOCK("' . $name . '") as `release_lock`');
$this->connection->exec('DO RELEASE_LOCK(\'' . $name . '\') as \'release_lock\'');

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/WriteLockStrategy/MysqlMetadataLockStrategy.php
Expand Up @@ -36,7 +36,7 @@ public function __construct(\PDO $connection, int $timeout = -1)
public function getLock(string $name): bool
{
try {
$res = $this->connection->query('SELECT GET_LOCK("' . $name . '", ' . $this->timeout . ') as `get_lock`');
$res = $this->connection->query('SELECT GET_LOCK(\'' . $name . '\', ' . $this->timeout . ') as \'get_lock\'');
} catch (\PDOException $e) {
// ER_USER_LOCK_DEADLOCK: we only care for deadlock errors and fail locking
if ('3058' === $this->connection->errorCode()) {
Expand All @@ -60,7 +60,7 @@ public function getLock(string $name): bool

public function releaseLock(string $name): bool
{
$this->connection->exec('DO RELEASE_LOCK("' . $name . '") as `release_lock`');
$this->connection->exec('DO RELEASE_LOCK(\'' . $name . '\') as \'release_lock\'');

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/WriteLockStrategy/MariaDbMetadataLockStrategyTest.php
Expand Up @@ -65,7 +65,7 @@ public function it_requests_lock_with_given_name()

$connection = $this->prophesize(\PDO::class);

$connection->query(Argument::containingString('GET_LOCK("lock"'))
$connection->query(Argument::containingString('GET_LOCK(\'lock\''))
->willReturn($statement->reveal())
->shouldBeCalled();

Expand All @@ -86,7 +86,7 @@ public function it_requests_lock_without_timeout()

$connection = $this->prophesize(\PDO::class);

$connection->query(Argument::containingString("16777215"))
$connection->query(Argument::containingString('16777215'))
->willReturn($statement->reveal())
->shouldBeCalled();

Expand Down Expand Up @@ -190,7 +190,7 @@ public function it_releases_lock()
{
$connection = $this->prophesize(\PDO::class);

$connection->exec(Argument::containingString('RELEASE_LOCK("lock"'))->shouldBeCalled();
$connection->exec(Argument::containingString('RELEASE_LOCK(\'lock\''))->shouldBeCalled();

$strategy = new MariaDbMetadataLockStrategy($connection->reveal());

Expand Down
4 changes: 2 additions & 2 deletions tests/WriteLockStrategy/MysqlMetadataLockStrategyTest.php
Expand Up @@ -53,7 +53,7 @@ public function it_requests_lock_with_given_name()

$connection = $this->prophesize(\PDO::class);

$connection->query(Argument::containingString('GET_LOCK("lock"'))
$connection->query(Argument::containingString('GET_LOCK(\'lock\''))
->willReturn($statement->reveal())
->shouldBeCalled();

Expand Down Expand Up @@ -178,7 +178,7 @@ public function it_releases_lock()
{
$connection = $this->prophesize(\PDO::class);

$connection->exec(Argument::containingString('RELEASE_LOCK("lock"'))->shouldBeCalled();
$connection->exec(Argument::containingString('RELEASE_LOCK(\'lock\''))->shouldBeCalled();

$strategy = new MysqlMetadataLockStrategy($connection->reveal());

Expand Down

0 comments on commit cc3d043

Please sign in to comment.