|
13 | 13 |
|
14 | 14 | use Cycle\Database\Driver\Compiler; |
15 | 15 | use Cycle\Database\Driver\Quoter; |
| 16 | +use Cycle\Database\Query\SelectQuery; |
16 | 17 | use Cycle\Database\Driver\SQLServer\Injection\CompileJson; |
17 | 18 | use Cycle\Database\Injection\Fragment; |
18 | 19 | use Cycle\Database\Injection\FragmentInterface; |
@@ -175,12 +176,19 @@ private function baseSelect(QueryParameters $params, Quoter $q, array $tokens): |
175 | 176 | $this->nameWithAlias(new QueryParameters(), $q, $join['outer'], $join['alias'], true); |
176 | 177 | } |
177 | 178 |
|
| 179 | + $forUpdate = match ($tokens['forUpdate']) { |
| 180 | + SelectQuery::FOR_UPDATE => 'WITH(UPDLOCK,ROWLOCK)', |
| 181 | + SelectQuery::FOR_UPDATE_SKIP_LOCKED => 'WITH(UPDLOCK,READPAST)', |
| 182 | + SelectQuery::FOR_UPDATE_NOWAIT => 'WITH(UPDLOCK,ROWLOCK,NOWAIT)', |
| 183 | + default => '', |
| 184 | + }; |
| 185 | + |
178 | 186 | return \sprintf( |
179 | 187 | "SELECT%s %s\nFROM %s%s%s%s%s%s%s%s%s%s%s", |
180 | 188 | $this->optional(' ', $this->distinct($params, $q, $tokens['distinct'])), |
181 | 189 | $this->columns($params, $q, $tokens['columns']), |
182 | 190 | \implode(', ', $tables), |
183 | | - $this->optional(' ', $tokens['forUpdate'] ? 'WITH (UPDLOCK,ROWLOCK)' : '', ' '), |
| 191 | + $this->optional(' ', $forUpdate, ' '), |
184 | 192 | $this->optional(' ', $this->joins($params, $q, $tokens['join']), ' '), |
185 | 193 | $this->optional("\nWHERE", $this->where($params, $q, $tokens['where'])), |
186 | 194 | $this->optional("\nGROUP BY", $this->groupBy($params, $q, $tokens['groupBy']), ' '), |
|
0 commit comments