DDC-2560: Schema tool invalid DDL syntax for default values #3215

Open
opened 2026-01-22 14:15:38 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 19, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user ben.davies:

Not sure if this is Postgresql specific or not, but here are the reproduction steps:

Have a table with a column setup like so:

ALTER TABLE usr ADD COLUMN contact_count integer;
ALTER TABLE usr ALTER COLUMN contact_count SET NOT NULL;
ALTER TABLE usr ALTER COLUMN contact_count SET DEFAULT 0;

Have a Entity Column Definition like so:

    /****
     * @var integer $contactCount
     *
     * @ORM\Column(name="contact_count", type="integer", nullable=false)
     */
    private $contactCount = 0;

orm:schema-tool:update will generate the following SQL:

ALTER TABLE usr ALTER contact_count SET ;

adding

options={"default":0}

to the column definition results in no sql being generated (correctly I assume)

Originally created by @doctrinebot on GitHub (Jul 19, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user ben.davies: Not sure if this is Postgresql specific or not, but here are the reproduction steps: Have a table with a column setup like so: ``` ALTER TABLE usr ADD COLUMN contact_count integer; ALTER TABLE usr ALTER COLUMN contact_count SET NOT NULL; ALTER TABLE usr ALTER COLUMN contact_count SET DEFAULT 0; ``` Have a Entity Column Definition like so: ``` /**** * @var integer $contactCount * * @ORM\Column(name="contact_count", type="integer", nullable=false) */ private $contactCount = 0; ``` orm:schema-tool:update will generate the following SQL: ``` ALTER TABLE usr ALTER contact_count SET ; ``` adding ``` options={"default":0} ``` to the column definition results in no sql being generated (correctly I assume)
admin added the Bug label 2026-01-22 14:15:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 19, 2013):

Comment created by @ocramius:

The ORM doesn't support default column values.
That's fine-tuning you can do on the column definitions.

Your "workaround" is actually the correct way of dealing with this kind of DDL change.

@doctrinebot commented on GitHub (Jul 19, 2013): Comment created by @ocramius: The ORM doesn't support default column values. That's fine-tuning you can do on the column definitions. Your "workaround" is actually the correct way of dealing with this kind of DDL change.
Author
Owner

@doctrinebot commented on GitHub (Jul 19, 2013):

Comment created by ben.davies:

I realise the ORM doesn't support default values, but the point is that the schematool picks up a diff in the columns, tries to generate a diff, and generates an invalid sql statement. Surely that is a bug?

@doctrinebot commented on GitHub (Jul 19, 2013): Comment created by ben.davies: I realise the ORM doesn't support default values, but the point is that the schematool picks up a diff in the columns, tries to generate a diff, and generates an invalid sql statement. Surely that is a bug?
Author
Owner

@doctrinebot commented on GitHub (Jul 19, 2013):

Comment created by @ocramius:

[~ben.davies] the DBAL is responsible for generating this wrong DDL... Are you able to reproduce this in DBAL only?

@doctrinebot commented on GitHub (Jul 19, 2013): Comment created by @ocramius: [~ben.davies] the DBAL is responsible for generating this wrong DDL... Are you able to reproduce this in DBAL only?
Author
Owner

@doctrinebot commented on GitHub (Jul 19, 2013):

Comment created by ben.davies:

Happy to try.

@doctrinebot commented on GitHub (Jul 19, 2013): Comment created by ben.davies: Happy to try.
Author
Owner

@doctrinebot commented on GitHub (Jul 19, 2013):

Comment created by ben.davies:

here you go
https://github.com/bendavies/dbal/blob/DBAL-561/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL561Test.php

@doctrinebot commented on GitHub (Jul 19, 2013): Comment created by ben.davies: here you go https://github.com/bendavies/dbal/blob/[DBAL-561](http://www.doctrine-project.org/jira/browse/DBAL-561)/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL561Test.php
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3215