DDC-574: PHP Mapping Driver generates notnull => false, instead of nullable => true #708

Closed
opened 2026-01-22 12:47:34 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (May 6, 2010).

Originally assigned to: @jwage on GitHub.

Jira issue originally created by user andyajadeh:

I tried to import a schema from postgresql database, to a php file mapping.
I had created that database using doctrine schema tool with annotation mapping.

to import it, I used:

php doctrine orm:convert-mapping --from-database php ./php

and I got something like:

<?php

use Doctrine\ORM\Mapping\ClassMetadataInfo;

$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE*TYPE*NONE);
$metadata->setPrimaryTable(array(
   'name' => 'mdp',
  ));
$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING*DEFERRED*IMPLICIT);
$metadata->mapField(array(
   'id' => true,
   'fieldName' => 'id',
   'columnName' => 'id',
   'type' => 'integer',
  ));
$metadata->mapField(array(
   'fieldName' => 'rrn',
   'columnName' => 'rrn',
   'type' => 'string',
   'length' => 50,
   'fixed' => false,
   'notnull' => false,
  ));

$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR*TYPE*SEQUENCE);

When I try to drop & create the database using this php mapping, the "notnull => false" doesn't work.
The column definition in the database is still NOT NULL. But when I add "nullable => true", it works like I expected (DEFAULT NULL::character varying)

Originally created by @doctrinebot on GitHub (May 6, 2010). Originally assigned to: @jwage on GitHub. Jira issue originally created by user andyajadeh: I tried to import a schema from postgresql database, to a php file mapping. I had created that database using doctrine schema tool with annotation mapping. to import it, I used: ``` php doctrine orm:convert-mapping --from-database php ./php ``` and I got something like: ``` <?php use Doctrine\ORM\Mapping\ClassMetadataInfo; $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE*TYPE*NONE); $metadata->setPrimaryTable(array( 'name' => 'mdp', )); $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING*DEFERRED*IMPLICIT); $metadata->mapField(array( 'id' => true, 'fieldName' => 'id', 'columnName' => 'id', 'type' => 'integer', )); $metadata->mapField(array( 'fieldName' => 'rrn', 'columnName' => 'rrn', 'type' => 'string', 'length' => 50, 'fixed' => false, 'notnull' => false, )); $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR*TYPE*SEQUENCE); ``` When I try to drop & create the database using this php mapping, the "notnull => false" doesn't work. The column definition in the database is still NOT NULL. But when I add "nullable => true", it works like I expected (DEFAULT NULL::character varying)
admin added the Bug label 2026-01-22 12:47:34 +01:00
admin closed this issue 2026-01-22 12:47:35 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 10, 2010):

Comment created by shurakai:

Hi Andy,

do you think you could add such a .sql testfile for us? I will look into this shortly afterwards.

Thanks for helping!

@doctrinebot commented on GitHub (May 10, 2010): Comment created by shurakai: Hi Andy, do you think you could add such a .sql testfile for us? I will look into this shortly afterwards. Thanks for helping!
Author
Owner

@doctrinebot commented on GitHub (May 11, 2010):

Comment created by andyajadeh:

this is my table I imported. thanks.

@doctrinebot commented on GitHub (May 11, 2010): Comment created by andyajadeh: this is my table I imported. thanks.
Author
Owner

@doctrinebot commented on GitHub (May 14, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (May 14, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/eb82bf9d148fbb5a3189

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/eb82bf9d148fbb5a3189 - [10601_mdp.schema.sql](https://gist.github.com/eb82bf9d148fbb5a3189#file-10601_mdp-schema-sql)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#708