Skip to content

Solve issue 293 about IDENTITY #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Type/Doctrine/Query/QueryResultTypeWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ public function walkFunction($function)
}

$nullable = ($joinColumn['nullable'] ?? true)
|| $this->isQueryComponentNullable($dqlAlias)
|| $this->hasAggregateWithoutGroupBy();

$fieldType = $this->resolveDatabaseInternalType($typeName, $enumType, $nullable);
Expand Down
5 changes: 4 additions & 1 deletion tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ public function getTestData(): iterable
[new ConstantIntegerType(6), TypeCombinator::addNull($this->numericStringOrInt())],
[new ConstantIntegerType(7), TypeCombinator::addNull(new MixedType())],
[new ConstantIntegerType(8), TypeCombinator::addNull($this->numericStringOrInt())],
[new ConstantIntegerType(9), TypeCombinator::addNull($this->numericStringOrInt())],
]),
'
SELECT IDENTITY(m.oneNull),
Expand All @@ -1386,8 +1387,10 @@ public function getTestData(): iterable
IDENTITY(m.compoundPk, \'id\'),
IDENTITY(m.compoundPk, \'version\'),
IDENTITY(m.compoundPkAssoc),
IDENTITY(m.compoundPkAssoc, \'version\')
IDENTITY(m.compoundPkAssoc, \'version\'),
IDENTITY(o.subOne)
FROM QueryResult\Entities\Many m
LEFT JOIN m.oneNull o
',
];

Expand Down
15 changes: 14 additions & 1 deletion tests/Type/Doctrine/data/QueryResult/Entities/One.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;

/**
* @Entity
Expand Down Expand Up @@ -45,6 +45,14 @@ class One
*/
public $stringNullColumn;

/**
* @OneToOne(targetEntity="QueryResult\Entities\SubOne", cascade={"persist"})
* @JoinColumn(nullable=false)
*
* @var SubOne
*/
public $subOne;

/**
* @OneToMany(targetEntity="QueryResult\Entities\Many", mappedBy="one")
*
Expand All @@ -58,4 +66,9 @@ class One
* @var Embedded
*/
public $embedded;

public function __construct()
{
$this->subOne = new SubOne();
}
}
23 changes: 23 additions & 0 deletions tests/Type/Doctrine/data/QueryResult/Entities/SubOne.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php declare(strict_types=1);

namespace QueryResult\Entities;

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;

/**
* @Entity
*/
class SubOne
{
/**
* @GeneratedValue()
* @Column(type="integer")
* @Id
*
* @var string
*/
public $id;
}