Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-504

DBAL Enum fields migration issue / PostgreSQL

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: None
    • Component/s: Drivers, Schema Managers
    • Security Level: All
    • Labels:
      None
    • Environment:
      postgresql

      Description

      When using Custom Doctrine DBAL Enums the migration created using diff

      works fine the first time.

      However the next time it generates a SQL statement trying to change to field type to INT from integer; (Redundant)
      and a truncated statement:

      "ALTER schemaname.fieldname SET" .. And that's it.

        Issue Links

          Activity

          jos de witte created issue -
          Benjamin Eberlei made changes -
          Field Original Value New Value
          Link This issue is duplicated by DDC-2238 [ DDC-2238 ]
          Hide
          Tom Vogt added a comment -

          Doesn't only happen on Enums. I don't use any enums and I have this problem. I use a couple of geo (postGIS) fields (point, linestring, polygon) as well as array fields, so either or all of those might be causing it, too.

          Show
          Tom Vogt added a comment - Doesn't only happen on Enums. I don't use any enums and I have this problem. I use a couple of geo (postGIS) fields (point, linestring, polygon) as well as array fields, so either or all of those might be causing it, too.
          Hide
          Benjamin Eberlei added a comment -

          We did some changes for PostgreSQL column diffs lately, can you verify this bug still exists on the 2.3 Branch of DBAL?

          Show
          Benjamin Eberlei added a comment - We did some changes for PostgreSQL column diffs lately, can you verify this bug still exists on the 2.3 Branch of DBAL?
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Awaiting Feedback [ 10000 ]
          Hide
          Tom Vogt added a comment -

          I'm running this on Symfony2 with this composer.json config:

          "doctrine/orm": "2.3.*",
          "doctrine/doctrine-bundle": ">=2.1",

          and I'm still getting this issue today.

          Show
          Tom Vogt added a comment - I'm running this on Symfony2 with this composer.json config: "doctrine/orm": "2.3.*", "doctrine/doctrine-bundle": ">=2.1", and I'm still getting this issue today.
          Hide
          Steve Müller added a comment -

          jos de witte Tom Vogt The truncated statement is most probably related to the column default value issue on PostgreSQL which should be fixed in this commit: https://github.com/doctrine/dbal/commit/8fe741053849afadef12b8bef1cc3203966ef78f
          Can you please again check if this still exists in the current master branch.
          If it still exists please provide your mapping information and the changes that cause wrong SQL. Thank you.

          Show
          Steve Müller added a comment - jos de witte Tom Vogt The truncated statement is most probably related to the column default value issue on PostgreSQL which should be fixed in this commit: https://github.com/doctrine/dbal/commit/8fe741053849afadef12b8bef1cc3203966ef78f Can you please again check if this still exists in the current master branch. If it still exists please provide your mapping information and the changes that cause wrong SQL. Thank you.
          Hide
          Tom Vogt added a comment - - edited

          Quick check after updating (composer says my versions are now:

          • Updating doctrine/doctrine-bundle dev-master (2ed4639 => c65e5a2)
            Checking out c65e5a21d1db794511d11fe28918f41bd6072f8f
          • Updating doctrine/dbal 2.3.x-dev (59c310b => 907f30d)
            Checking out 907f30dec77a9e83fdba8705fc642fd7815cbc11

          ) still shows the error happening, but I've only run an update --dump-sql and didn't init a new database or anything.

          here's my mapping for one entity that causes this:

          <?xml version="1.0" encoding="utf-8"?>
          <doctrine-mapping>
          	<entity name="BM2\SiteBundle\Entity\Building">
          		<id name="id" type="integer">
          			<generator strategy="IDENTITY"/>
          		</id>
          		<field name="workers" type="float"/>
          		<field name="active" type="boolean"/>
          		<field name="condition" type="integer"/>
          		<field name="resupply" type="integer"/>
          		<field name="current_speed" type="float"/>
          
          		<many-to-one field="settlement" target-entity="Settlement" inversed-by="buildings"/>
          		<many-to-one field="type" target-entity="BuildingType" inversed-by="buildings"/>
          
          	</entity>
          </doctrine-mapping>
          

          and on " php app/console doctrine:schema:update --dump-sql" I get for this entity:

          ALTER TABLE building ALTER current_speed SET ;

          I do think it is related to the default column indeed, as adding this to an existing database required me to add it with a default value that is not reflected in the mapping data, so the current column definition for this entity is:

                                           Table "public.building"
              Column     |       Type       |                       Modifiers                       
          ---------------+------------------+-------------------------------------------------------
           id            | integer          | not null default nextval('building_id_seq'::regclass)
           settlement_id | integer          | 
           type_id       | integer          | 
           workers       | double precision | not null
           active        | boolean          | not null
           condition     | integer          | not null
           resupply      | integer          | not null
           current_speed | double precision | not null default 1.0
          

          and if I drop the default (alter table building alter current_speed drop default) then the problem disappears. So at least there's a workaround now, thanks!

          Show
          Tom Vogt added a comment - - edited Quick check after updating (composer says my versions are now: Updating doctrine/doctrine-bundle dev-master (2ed4639 => c65e5a2) Checking out c65e5a21d1db794511d11fe28918f41bd6072f8f Updating doctrine/dbal 2.3.x-dev (59c310b => 907f30d) Checking out 907f30dec77a9e83fdba8705fc642fd7815cbc11 ) still shows the error happening, but I've only run an update --dump-sql and didn't init a new database or anything. here's my mapping for one entity that causes this: <?xml version= "1.0" encoding= "utf-8" ?> <doctrine-mapping> <entity name= "BM2\SiteBundle\Entity\Building" > <id name= "id" type= "integer" > <generator strategy= "IDENTITY" /> </id> <field name= "workers" type= "float" /> <field name= "active" type= "boolean" /> <field name= "condition" type= "integer" /> <field name= "resupply" type= "integer" /> <field name= "current_speed" type= "float" /> <many-to-one field= "settlement" target-entity= "Settlement" inversed-by= "buildings" /> <many-to-one field= "type" target-entity= "BuildingType" inversed-by= "buildings" /> </entity> </doctrine-mapping> and on " php app/console doctrine:schema:update --dump-sql" I get for this entity: ALTER TABLE building ALTER current_speed SET ; I do think it is related to the default column indeed, as adding this to an existing database required me to add it with a default value that is not reflected in the mapping data, so the current column definition for this entity is: Table " public .building" Column | Type | Modifiers ---------------+------------------+------------------------------------------------------- id | integer | not null default nextval('building_id_seq'::regclass) settlement_id | integer | type_id | integer | workers | double precision | not null active | boolean | not null condition | integer | not null resupply | integer | not null current_speed | double precision | not null default 1.0 and if I drop the default (alter table building alter current_speed drop default) then the problem disappears. So at least there's a workaround now, thanks!
          Hide
          Steve Müller added a comment -

          Tom Vogt The problem is composer installed from DBAL 2.3-dev branch. But the patch is currently only available in DBAL master. You have to test this with the current DBAL master somehow.

          Show
          Steve Müller added a comment - Tom Vogt The problem is composer installed from DBAL 2.3-dev branch. But the patch is currently only available in DBAL master. You have to test this with the current DBAL master somehow.
          Hide
          Tom Vogt added a comment -

          confirmed fixed:

          Updating dependencies (including require-dev)                          
            - Updating doctrine/dbal (2.3.x-dev 907f30d => dev-master 9ec63e2)
              Checking out 9ec63e25b572db79c09cacccb844e33ed435e479
          
            - Updating doctrine/orm (2.3.x-dev 1a30e0a => dev-master 58c57c5)
              Checking out 58c57c50bf3582a1672bc09733afab4167ebd5ba
          
          php app/console doctrine:generate:entities BM2 --no-backup
          ...
          ALTER TABLE settlement ALTER starvation DROP DEFAULT;
          ...
          

          it is now correctly updating.

          Thanks.

          Show
          Tom Vogt added a comment - confirmed fixed: Updating dependencies (including require-dev) - Updating doctrine/dbal (2.3.x-dev 907f30d => dev-master 9ec63e2) Checking out 9ec63e25b572db79c09cacccb844e33ed435e479 - Updating doctrine/orm (2.3.x-dev 1a30e0a => dev-master 58c57c5) Checking out 58c57c50bf3582a1672bc09733afab4167ebd5ba php app/console doctrine:generate:entities BM2 --no-backup ... ALTER TABLE settlement ALTER starvation DROP DEFAULT; ... it is now correctly updating. Thanks.
          Hide
          Steve Müller added a comment -

          Benjamin Eberlei can you resolve please? I cannot do that...

          Show
          Steve Müller added a comment - Benjamin Eberlei can you resolve please? I cannot do that...
          Benjamin Eberlei made changes -
          Status Awaiting Feedback [ 10000 ] Open [ 1 ]
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]

          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-504, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              jos de witte
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: