Skip to content
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

[Doctrine Bridge] Check field type before adding Length constraint #31874

merged 1 commit into from Jun 6, 2019
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -60,4 +60,13 @@ class DoctrineLoaderEntity extends DoctrineLoaderParentEntity
* @ORM\Embedded(class=DoctrineLoaderEmbed::class)
public $embedded;
/** @ORM\Column(type="text", nullable=true, length=1000) */
public $textField;
/** @ORM\Id @ORM\Column(type="guid", length=50) */
protected $guidField;
/** @ORM\Column(type="simple_array", length=100) */
public $simpleArrayField = [];
@@ -108,6 +108,16 @@ public function testLoadClassMetadata()
$this->assertCount(1, $embeddedMaxLengthConstraints);
$this->assertInstanceOf(Length::class, $embeddedMaxLengthConstraints[0]);
$this->assertSame(25, $embeddedMaxLengthConstraints[0]->max);
$this->assertCount(0, $classMetadata->getPropertyMetadata('guidField'));
$this->assertCount(0, $classMetadata->getPropertyMetadata('simpleArrayField'));
$textFieldMetadata = $classMetadata->getPropertyMetadata('textField');
$this->assertCount(1, $textFieldMetadata);
$textFieldConstraints = $textFieldMetadata[0]->getConstraints();
$this->assertCount(1, $textFieldConstraints);
$this->assertInstanceOf(Length::class, $textFieldConstraints[0]);
$this->assertSame(1000, $textFieldConstraints[0]->max);
public function testFieldMappingsConfiguration()
@@ -73,7 +73,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
$metadata->addConstraint(new UniqueEntity(['fields' => $mapping['fieldName']]));
if (null === ($mapping['length'] ?? null)) {
if (null === ($mapping['length'] ?? null) || !\in_array($mapping['type'], ['string', 'text'], true)) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.