ORM: Join sub-query (#2757)

* orm join sub-query

* tests
This commit is contained in:
Yuri Kuznetsov
2023-05-31 17:01:43 +03:00
committed by GitHub
parent 260a5c89ef
commit d4aa9745ca
5 changed files with 276 additions and 68 deletions

View File

@@ -29,8 +29,10 @@
namespace tests\unit\Espo\ORM\Query\Part;
use Espo\ORM\Query\Part\Expression;
use Espo\ORM\Query\Part\Join;
use Espo\ORM\Query\Part\Expression as Expr;
use Espo\ORM\Query\SelectBuilder;
class JoinTest extends \PHPUnit\Framework\TestCase
{
@@ -50,6 +52,8 @@ class JoinTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($join->isRelation());
$this->assertFalse($join->isTable());
$this->assertEquals(Join::TYPE_RELATION, $join->getType());
}
public function testCreate2(): void
@@ -68,6 +72,8 @@ class JoinTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($join->isTable());
$this->assertFalse($join->isRelation());
$this->assertEquals(Join::TYPE_TABLE, $join->getType());
}
public function testCreate3(): void
@@ -77,4 +83,18 @@ class JoinTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('Test', $join->getTarget());
$this->assertEquals('testAlias', $join->getAlias());
}
public function testCreate4(): void
{
$join = Join::createWithSubQuery(
SelectBuilder::create()
->select(Expression::value(true))
->build()
,
'a'
);
$this->assertTrue($join->isSubQuery());
$this->assertEquals(Join::TYPE_SUB_QUERY, $join->getType());
}
}