Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-574

PHP Mapping Driver generates notnull => false, instead of nullable => true

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA1
    • Fix Version/s: 2.0-BETA2
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None
    • Environment:
      PHP 5.3.1
      PostgreSql 8.4

      Description

      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)

        Activity

        Hide
        Christian Heinrich added a comment -

        Hi Andy,

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

        Thanks for helping!

        Show
        Christian Heinrich added a comment - Hi Andy, do you think you could add such a .sql testfile for us? I will look into this shortly afterwards. Thanks for helping!
        Hide
        Andy Aja deh added a comment -

        this is my table I imported. thanks.

        Show
        Andy Aja deh added a comment - this is my table I imported. thanks.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Andy Aja deh
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: