Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-63

Custom Types always detected as changed when orm:schema-tool:update

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.0-BETA4
    • Fix Version/s: None
    • Component/s: Schema Managers
    • Labels:
      None
    • Environment:
      Ubuntu 10.10, MySQL 5.1.49, PHP 5.3.3

      Description

      I defined a custom type for DBAL and used it in an entity annotation. Every time I call doctrine orm:schema-tool:update, even when no changes are been made to the code, DBAL thinks the schema has changed and needs an update. The type declaration is done in cli-config.php, when creating the EntityManager.

      See the code and output below:

      Project/CustomType.php
      namespace Project;
      
      use \Doctrine\DBAL\Platforms\AbstractPlatform,
          \Doctrine\DBAL\Types\Type;
      
      class CustomType extends Type
      {
          const TYPE = 'custom';
      
          public function getSqlDeclaration(array $fieldDeclaration,
                                            AbstractPlatform $platform)
          {
              return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
          }
      
          public function getName()
          {
              return self::TYPE;
          }
      }
      
      Project/Entity.php
      /**
       * @entity
       */
      namespace Project;
      class Entity
      {
          /**
           * @id
           * @column(type="integer")
           */
          private $id;
      
          /**
           * @column(type="custom")
           */
          private $custom;
      }
      
      cli-config.php
      $cache = new \Doctrine\Common\Cache\ApcCache;
      $config = new \Doctrine\ORM\Configuration;
      $config->setMetadataCacheImpl($cache);
      $config->setQueryCacheImpl($cache);
      
      $driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/Project');
      $config->setMetadataDriverImpl($driverImpl);
      
      $config->setProxyDir(APPLICATION_PATH . '/Proxies');
      $config->setProxyNamespace('Proxies');
      $config->setAutoGenerateProxyClasses(true);
      
      $connectionOptions = array(
          'driver'   => 'pdo_mysql',
          'dbname'   => 'project',
          'user'     => '#user#',
          'password' => '#password#',
          'host'     => 'localhost',
      );
      
      \Doctrine\DBAL\Types\Type::addType('custom', 'Project\CustomType');
      $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
      
      $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
          'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
          'em' => new Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em),
      ));
      
      Console Output
      #:~ doctrine orm:schema-tool:create --dump-sql
      CREATE TABLE Entity (id INT NOT NULL, custom VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB
      
      #:~ doctrine orm:schema-tool:create
      Creating database schema...
      Database schema created successfully!
      
      #:~ doctrine orm:schema-tool:update --dump-sql
      ALTER TABLE Entity CHANGE custom custom VARCHAR(255) NOT NULL
      
      #:~ doctrine orm:schema-tool:update --force
      Updating database schema...
      Database schema updated successfully!
      
      #:~ doctrine orm:schema-tool:update --dump-sql
      ALTER TABLE Entity CHANGE custom custom VARCHAR(255) NOT NULL
      

        Activity

        Berny Cantos created issue -
        Hide
        Benjamin Eberlei added a comment -

        Yes, it thinks its a varchar and wants to update that definition. This is a duplicate of DBAL-42

        Show
        Benjamin Eberlei added a comment - Yes, it thinks its a varchar and wants to update that definition. This is a duplicate of DBAL-42
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Duplicate [ 3 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12107 ] jira-feedback2 [ 17673 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17673 ] jira-feedback3 [ 20028 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-63, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Berny Cantos
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: