Feature #28868

Default Doctrine Annotation for single object relation should be derived automatically

Added by Christian Müller almost 4 years ago. Updated almost 4 years ago.

Status:Resolved Start date:2011-08-09
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Persistence
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch:

Description

/** * @var \Me\MyPackage\Domain\Model\DepartmentPerson
*/
protected $departmentPerson = NULL;

Will result in strange errors that are not really helpful. Should by default create OneToOne or ManyToOne (maybe better) Relation (tbd) or at least give some warning on compile?

Associated revisions

Revision 3c6ac910
Added by Sascha Egerer almost 4 years ago

[TASK] Throw exception if type of relation is not defined

If a relation to a non standard datatype is defined in a model you have to define the type
of the relation (OneToOne, OneToMany...). If not doctrine tries to convert the related
model to a string and throws an exception.

Add an extra exception for this special case which gives a hint what's wrong.

Change-Id: I0252e4ea07854908d5a04c3d083e560174f9ca77
Resolves: #28868

History

#1 Updated by Sascha Egerer almost 4 years ago

I got the same case wich throws a "Object of class XXX\XXX\Domain\Model\ClassName could not be converted to string" exception.

But I think it's a better idea to throw an exception in this case, wich explains that there is something missing for the relation.

#2 Updated by Karsten Dambekalns almost 4 years ago

  • Category set to Persistence
  • Status changed from New to Needs Feedback
  • Assigned To set to Karsten Dambekalns

Since there cannot be a reasonable default (OneToOne vs @ManyToOne) this will not be changed. Also, you *could* actually want to store "objects as strings" using @__toString(), so an exception during compile is not an option either.

Any better ideas?

#3 Updated by Robert Lemke almost 4 years ago

  • Target version changed from 1.0 beta 1 to 1.0 beta 2

#4 Updated by Karsten Dambekalns almost 4 years ago

  • Tracker changed from Bug to Feature

#5 Updated by Mr. Hudson almost 4 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 2 of change I0252e4ea07854908d5a04c3d083e560174f9ca77 has been pushed to the review server.
It is available at http://review.typo3.org/4549

#6 Updated by Karsten Dambekalns almost 4 years ago

The exception idea is fine, if someone really wants to store objects as string using __toString() a simple type attribute to @Column is possible.

#7 Updated by Karsten Dambekalns almost 4 years ago

  • Target version changed from 1.0 beta 2 to 1.0 beta 1

Fine for beta 1 IMHO.

#8 Updated by Sascha Egerer almost 4 years ago

Karsten Dambekalns wrote:

The exception idea is fine, if someone really wants to store objects as string using __toString() a simple type attribute to @Column is possible.

Ok that's true! Thx for your fast review!

#9 Updated by Sascha Egerer almost 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF