mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-27 22:46:04 +00:00
ORM: Skip foreign if for share
This commit is contained in:
@@ -162,7 +162,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
protected int $aliasMaxLength = 256;
|
||||
|
||||
protected bool $indexHints = true;
|
||||
protected bool $skipForeignIfForUpdate = false;
|
||||
protected bool $skipForeignIfLock = false;
|
||||
|
||||
protected Helper $helper;
|
||||
|
||||
@@ -712,7 +712,11 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
*/
|
||||
private function skipForeign(array $params): bool
|
||||
{
|
||||
return $this->skipForeignIfForUpdate && ($params['forUpdate'] ?? false);
|
||||
return $this->skipForeignIfLock &&
|
||||
(
|
||||
($params['forUpdate'] ?? false) ||
|
||||
($params['forShare'] ?? false)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,7 @@ class PostgresqlQueryComposer extends BaseQueryComposer
|
||||
{
|
||||
protected string $identifierQuoteCharacter = '"';
|
||||
protected bool $indexHints = false;
|
||||
protected bool $skipForeignIfForUpdate = true;
|
||||
protected bool $skipForeignIfLock = true;
|
||||
protected int $aliasMaxLength = 128;
|
||||
|
||||
/** @var array<string, string> */
|
||||
|
||||
@@ -157,6 +157,23 @@ class PostgresqlQueryComposerTest extends TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testSelectForShare()
|
||||
{
|
||||
$query = SelectBuilder::create()
|
||||
->from('Comment')
|
||||
->select(['name', 'postId', 'postName'])
|
||||
->forShare()
|
||||
->build();
|
||||
|
||||
$sql = $this->queryComposer->composeSelect($query);
|
||||
|
||||
$expectedSql =
|
||||
'SELECT "comment"."name" AS "name", "comment"."post_id" AS "postId" ' .
|
||||
'FROM "comment" WHERE "comment"."deleted" = false FOR SHARE';
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testDelete1(): void
|
||||
{
|
||||
$query = DeleteBuilder::create()
|
||||
|
||||
Reference in New Issue
Block a user