Problem/Motivation

PostgreSQL's Schema::addField() does not properly detect when a field is part of a newly added primary key, so that it does not calculate T $fixnull variable correctly.

This is because a $keys_new variable is inspected but the variable is actually called $new_keys.

Proposed resolution

Because the variable is actually specified as $keys_new by the interface, rewrite usages of $new_keys to $keys_new instead of the other way around.

This will probably require #2974722: Fix dropping of columns in a composite primary key on MariaDB >=10.2.8 and make it consistent across database drivers for test coverage.

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Needs work
Issue tags: +Needs tests
StatusFileSize
new1.56 KB

Here's the fix, but it needs a test.

daffie’s picture

Title: [PP-2] $fixnull behavior is broken on PostgreSQL's ::addField() » $fixnull behavior is broken on PostgreSQL's ::addField()

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mradcliffe’s picture

StatusFileSize
new2.61 KB

I tried to write a test for this, but I cannot get it to fail.

From what I can read, the bug /should/ be revealed in the following scenario, which I believe i have replicated in the test.

  • Adding a new field
    • when not null is true
    • default is not set
    • initial is set to some value
    • the field is not in the primary key
  • And then this triggers $fixnull
  • the field is created allowing null values
  • the initial value is set on all rows for the new field
  • the field is altered back to being not null
tstoeckler’s picture

Actually this seems to have been fixed by #2616724: Warn when trying to create a database table with a NOT NULL => FALSE primary key already in the meantime. Not sure if the test coverage in #5 is still valuable or if the test coverage added over there already covers that.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

daffie’s picture

Status: Needs work » Closed (outdated)

I am marking this issue as outdated as the patch from comment #5 does not fail.