Skip to content

Commit 6bc55bd

Browse files
authored
feat: SELECT FOR UPDATE support (#268)
1 parent 00a9d22 commit 6bc55bd

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ services:
88
depends_on:
99
- emulator
1010
emulator:
11-
image: "gcr.io/cloud-spanner-emulator/emulator:1.5.28"
11+
image: "gcr.io/cloud-spanner-emulator/emulator:1.5.30"

src/Query/Grammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function compileInsertGetId(Builder $query, $values, $sequence)
6464
*/
6565
protected function compileLock(Builder $query, $value)
6666
{
67-
return '';
67+
return $value === true ? 'for update' : '';
6868
}
6969

7070
/**

tests/Query/BuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,15 +994,15 @@ public function test_lock(): void
994994
$conn = $this->getDefaultConnection();
995995
$qb = $conn->table(self::TABLE_NAME_USER);
996996
$sql = $qb->lock()->toRawSql();
997-
$this->assertSame('select * from `User`', $sql);
997+
$this->assertSame('select * from `User` for update', $sql);
998998
}
999999

10001000
public function test_lockForUpdate(): void
10011001
{
10021002
$conn = $this->getDefaultConnection();
10031003
$qb = $conn->table(self::TABLE_NAME_USER);
10041004
$sql = $qb->lockForUpdate()->toRawSql();
1005-
$this->assertSame('select * from `User`', $sql);
1005+
$this->assertSame('select * from `User` for update', $sql);
10061006
}
10071007

10081008
public function test_sharedLock(): void

0 commit comments

Comments
 (0)