[PostgresPlatform] Fixing change detection when a default is removed #44

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

Member

Change detection when the default value is removed from a field is presently broken and produces invalid SQL.

This patch checks to see if a new default value actually exists before adding the SET DEFAULT '';

Uses DROP DEFAULT when the new default value does not exist

Contributor
butonic commented Dec 12, 2013

@richardfullmer we are stumbling over this in ownCloud: owncloud/core#6310
Why did you close the PR. Is it the wrong approach?

Contributor
butonic commented Dec 12, 2013

Also summoning @deeky666: we are stumbling over this in ownCloud: owncloud/core#6310
Why did you close the PR. Is it the wrong approach? http://www.doctrine-project.org/jira/browse/DBAL-156 gives no reason.

@butonic butonic referenced this pull request in owncloud/3rdparty Dec 12, 2013
Closed

Fix SET DEFAULT when there is no default #64

Member

@butonic I have no idea why @richardfullmer closed this. This PR is really old. I will try to have a look into this later this evening and supply a patch for this issue.

Contributor
butonic commented Dec 12, 2013

@deeky666 I just tested the migration of OC5 to OC6 (where we start using doctrine) and with this PR applied it completes fine. We are asking the database to describe its schema and I think postgresql reports DEFAULT '' when no default is set ... or doctrine interprets whatever postgres reports as such. So this might be fixing a symptom ...

Contributor
butonic commented Dec 12, 2013

looking at the code it might as well be that https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php#L387 always tries to return a default value ... but then again all other platforms also always return a default. MySql then uses CHANGE, Oracle uses MODIFY and thus they do not not have the SQL syntax issues PostgreSqlPlatform runs into. From what I see I think adding the 'default' value to the options array in the _getPortableTableColumnDefinition implementations should only be added when a default value is specified ...

Member

Why did you close the PR

Because it sat for over a year without being commented on or addressed. I've maintained my own fork in the mean time. I'd assumed that I was the only one who had the issue.

Contributor
butonic commented Dec 12, 2013

@richardfullmer nah ... we ran into it with a vengance... it breaks the migration to OC6 for all postgresql users of owncloud. Sadly, nobody seems to have tested it ... oh well ...

Member

Fix included in PR #456.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment