-
Notifications
You must be signed in to change notification settings - Fork 91
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
Query indexBy with OneToOne relation result in nullable TKey #422
Comments
Explicitly specifying
|
I'm running into a similar issue - same conclusion. It's broken since v1.3.29 and my wild guess would be the exact same commit as mentioned by @noemi-salaun . Here's my stack trace:
my dynamic query: $qb = $this->em->createQueryBuilder()
->select('episode.id')
->from('VideoBundle:Episode', 'episode', 'episode.id')
->where('episode.segmentsComplete = false')
->andWhere('0 != SIZE(episode.segments)')
->andWhere(
'0 < (SELECT COUNT(last_segment.id) FROM VideoBundle:Segment as last_segment
WHERE last_segment.episode = episode.id AND last_segment.isLastSegment = true)'
)
->andWhere(
"0 = (SELECT COUNT(segment.id) FROM VideoBundle:Segment as segment
WHERE segment.episode = episode.id AND segment.state != 'distributed')"
)
; class Episode
{
/**
* @var Collection<Segment>
* @ORM\OneToMany(
* targetEntity="App\VideoBundle\Entity\Segment",
* mappedBy="episode",
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
* @ORM\OrderBy({"position" = "ASC"})
*/
private $segments;
} class Segment
{
/**
* @ORM\ManyToOne(
* targetEntity="App\VideoBundle\Entity\Episode",
* inversedBy="segments",
* cascade={"persist"}
* )
* @ORM\JoinColumn(name="episode_id", referencedColumnName="id", nullable=false)
* @var Episode
*/
private $episode;
} |
@mvhirsch Wrong type inference, and an internal error crash, are not similar issues. Please track yours in a separate issue. Thanks. |
It works fine with version 1.3.28 but since version 1.3.29 with this commit 4490e56 , when using a query builder with indexBy refering to a OneToOne relation, I get the error
The
userId
column in my tablesomething
is not nullable, it's literally the primary keyMy entities are defined as follow
and the query
I see in the unit test added in the commit that it's not tested with relationship, only with plain string or int column
The text was updated successfully, but these errors were encountered: