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

Open
doctrinebot opened this Issue Jul 19, 2013 · 5 comments

2 participants

@doctrinebot

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)

@doctrinebot

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

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

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

Comment created by ben.davies:

Happy to try.

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment