I'm just setting up Drupal and Views (latest releases of both). The maintenance notice in Drupal says I need to run database updates to alter the schema. Our database backend is SQL Server (not MySQL). I get this error when I try to run the update job:

The following updates returned messages
views module
Update #7301
Failed: PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Object 'views_view.name' cannot be renamed because the object participates in enforced dependencies.: EXEC sp_rename :old, :new, :type; Array ( [:old] => views_view.name [:new] => name_old [:type] => COLUMN ) in db_change_field() (line 2988 of C:\MSTDrupal\includes\database\database.inc).

Is there something I can do to correct this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mainsequence’s picture

Title: Error Upon Database Update (MSSQL) » "Enforced Dependencies" Error Upon Database Update (MSSQL)
merlinofchaos’s picture

Wow, uh. I have absolutely no idea what that even means. I've never used mssql either. I don't know what an enforced dependency is and it's not something that Views would have set up, that I"m aware of.

dawehner’s picture

Project: Views (for Drupal 7) » Drupal driver for SQL Server and SQL Azure
Version: 7.x-3.x-dev » 7.x-1.x-dev
Component: Miscellaneous » Schema handling

The update function 7301 just adapts the length of the field "name" to 128, why does it rename an existing field?

I guess dependencies are the fact that "name" is part of the unique key.

Maybe the mssql driver does something wrong?

mainsequence’s picture

Actually, it looks like this question has been asked before -- http://drupal.org/node/1008932 -- but still no answer. Is this a change I might be able to make to the database by hand? I'm not sure what exactly it's trying to alter in the update routine, but I could ask our SQL admin to rename a column or something if that's all it is.

panmanphil’s picture

I reported in another issue what is going on in at least some of the cases. The field in question is in a computed column, which in turn is in a unique index.

http://drupal.org/node/1561396

panmanphil’s picture

The routine goes something like this:
- look for indexes, constraints on the field and drop them
- rename to _old
- create a new field with the name/properties/defaults you asked for
- migrate all the data from the old field to the new.

jonestev’s picture

The only way that a column that is used in a computed column can be changed is to delete the computed column then drop or rename any dependencies then recreate the computed column. So the index that uses the computed column can not be deleted unless the computed column is dropped first then the index is dropped and then the computed column is recreated.

panmanphil’s picture

Yep. there is a TODO in the driver source about the computed column, but the trick in this case is finding that the computed column is used in an index and having to drop and then recreate both. So two layers to track to drop and redo instead of just looking for index and computed columns the actual field that is changing are connected too.

panmanphil’s picture

I have created a patch that I think corrects this issue in the way the people who wrote the driver intended it to be. Well, who knows about that but I have built in the detection of changes to columns that have computed "shadow columns" used to create unique indexes and correctly drop and recreate them in the driver.

Could you all give this a try? If it works, I'm hoping that the maintainers will pick up on this and help get this committed.

katannshaw’s picture

I've applied this patch, and it worked great for me.

http://drupal.org/node/1561396#comment-6300106

jcbriggs’s picture

I can confirm that this patch works for me as well. Thanks!

katannshaw’s picture

@panmanphil: Have you tried upgrading from 7.14 to 7.15 with your working patch yet? I'm nervous to do so after the last experience.

jcbriggs’s picture

@jayhawkfan75: FWIW, I am running 7.15 with no issues with the patch on 3 different instances of Drupal

katannshaw’s picture

Very good. I'll give it a try then. Thanks jcbriggs.

panmanphil’s picture

I haven't done the 7.15 update yet, but will soon and report back.

panmanphil’s picture

I did the 7.15 update and had no problems on one of my development sites.

How can we get the maintainers involved to see this thing through?

katannshaw’s picture

@panmanphil: The patched worked great for me, and I was able to apply the 7.14 to 7.15 update without a problem.

I'm not understanding why the maintainers seem to be ignoring this issue, as you seemed to have solved it. I'm at a loss at this point, especially considering was such an important patch to get done.

katannshaw’s picture

FYI: I've created two discussions on this issue and how we can get this looked at by the maintainers:

I don't like posting discussions in multiple places, but I felt that in this case, it would be nice to hear from the maintainers' own site as well as the Drupal community. Hopefully someone could help us out with this one. I really appreciate all that you have done concerning this issue panmanphil, and I'd also like this officially resolved soon.

panmanphil’s picture

Thanks @jayhawhkfan75. I just posted to our Wisconsin user group discussions as well. There seem to be some decently connected people in that group and they may have some ideas. Hopefully we can get somebody to pick this up soon and settle this.

Artusamak’s picture

Status: Active » Fixed

OK guys, thank you for the report, testing and bug fixing it has been integrated in the module now in the dev version, we are kind of looking for time to keep to issue queue up to date and we missed this bug and the fact that it was fixed. We are sorry about it and i wish that it's not going to happen again.

panmanphil’s picture

Great! thanks for responding. I will try out the dev version too and make sure it works as expected.

katannshaw’s picture

Very good Artusamuk. Hopefully the lack of attention was just a fluke. I appreciate you replying to this issue, as well as implementing the patch to the dev version. I'll give it a try as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.