DDC-2221: In YAML, joinColumn names are ignored in One to Many and Many To One relationships #2794

Closed
opened 2026-01-22 14:03:54 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 3, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user schow:

When using YAML configuration to define 1:M, M:1 relationships, the joinColumn.name entry is ignored and Doctrine tries to use the default *_id convention.

Using the Doctrine2 tutorial example, I created YAML mapping for the Bug entity:

config/yaml/Bug.dcm.yml

Bug:
type: entity
table: bugs
id:
id:
type: integer
generator:
strategy: AUTO
fields:
description:
type: text
created:
type: datetime
status:
type: string
manyToOne:
reporter:
targetEntity: User
inversedBy: reportedBugs
joinColumm:
name: reporterId
referencedColumnName: id
engineer:
targetEntity: User
inversedBy: assignedBugs
joinColumm:
name: engineerId
referencedColumnName: id
manyToMany:
products:
targetEntity: Product

I then tried to run list_bugs:

<?php // list_bugs.php require_once "bootstrap.php"; $dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ORDER BY b.created DESC"; $query = $em->createQuery($dql); $query->setMaxResults(30); $bugs = $query->getResult(); foreach($bugs AS $bug) { echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n"; echo " Reported by: ".$bug->getReporter()->name."\n"; echo " Assigned to: ".$bug->getEngineer()->name."\n"; foreach($bug->getProducts() AS $product) { echo " Platform: ".$product->getName()."\n"; } echo "\n"; However, I get this error message: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b0_.reporter_id' in 'field list'' in /Library/WebServer/Documents/DoctrineTutorial/Doctrine/DBAL/Connection.php:646 Stack trace: #0 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/DBAL/Connection.php(646): PDO->query('SELECT b0_.id A...') #1 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(46): Doctrine\DBAL\Connection->executeQuery('SELECT b0_.id A...', Array, Array, NULL) #2 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/Query.php(264): Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(Doctrine\DBAL\Connection), Array, Array) #3 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/AbstractQuery.php(737): Doctrine\ORM\Query->_doExecute()
Originally created by @doctrinebot on GitHub (Jan 3, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user schow: When using YAML configuration to define 1:M, M:1 relationships, the joinColumn.name entry is ignored and Doctrine tries to use the default *_id convention. Using the Doctrine2 tutorial example, I created YAML mapping for the Bug entity: # config/yaml/Bug.dcm.yml Bug: type: entity table: bugs id: id: type: integer generator: strategy: AUTO fields: description: type: text created: type: datetime status: type: string manyToOne: reporter: targetEntity: User inversedBy: reportedBugs joinColumm: name: reporterId referencedColumnName: id engineer: targetEntity: User inversedBy: assignedBugs joinColumm: name: engineerId referencedColumnName: id manyToMany: products: targetEntity: Product I then tried to run list_bugs: <?php // list_bugs.php require_once "bootstrap.php"; $dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ORDER BY b.created DESC"; $query = $em->createQuery($dql); $query->setMaxResults(30); $bugs = $query->getResult(); foreach($bugs AS $bug) { echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n"; echo " Reported by: ".$bug->getReporter()->name."\n"; echo " Assigned to: ".$bug->getEngineer()->name."\n"; foreach($bug->getProducts() AS $product) { echo " Platform: ".$product->getName()."\n"; } echo "\n"; However, I get this error message: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b0_.reporter_id' in 'field list'' in /Library/WebServer/Documents/DoctrineTutorial/Doctrine/DBAL/Connection.php:646 Stack trace: #0 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/DBAL/Connection.php(646): PDO->query('SELECT b0_.id A...') #1 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(46): Doctrine\DBAL\Connection->executeQuery('SELECT b0_.id A...', Array, Array, NULL) #2 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/Query.php(264): Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(Doctrine\DBAL\Connection), Array, Array) #3 /Library/WebServer/Documents/DoctrineTutorial/Doctrine/ORM/AbstractQuery.php(737): Doctrine\ORM\Query->_doExecute()
admin added the Bug label 2026-01-22 14:03:54 +01:00
admin closed this issue 2026-01-22 14:03:55 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 3, 2013):

Comment created by @ocramius:

It's "joinColumn", not "joinColumm"

@doctrinebot commented on GitHub (Jan 3, 2013): Comment created by @ocramius: It's "joinColumn", not "joinColumm"
Author
Owner

@doctrinebot commented on GitHub (Jan 3, 2013):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 3, 2013): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Jan 3, 2013):

Comment created by schow:

...And that is why I should not be working on this when I'm barely awake. Sorry.

@doctrinebot commented on GitHub (Jan 3, 2013): Comment created by schow: ...And that is why I should not be working on this when I'm barely awake. Sorry.
Author
Owner

@doctrinebot commented on GitHub (Jan 3, 2013):

Comment created by @ocramius:

No prob :)

@doctrinebot commented on GitHub (Jan 3, 2013): Comment created by @ocramius: No prob :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2794