Toad World® Forums

The Refactoring Utility Doesn't Display Non-Dbo-Schema Objects to Modify

Hi, all. I haven’t used the Refactoring Utility before, and I think that is precisely because of the symptoms I’m describing here.

Using version 5.4.6.1.2, I renamed an attribute in one entity that occurs with the same name in all the entities in my physical model. What I expected was that I could check that attribute name in the Recently Renamed Objects list, and that I would then see all of the non-renamed entities in the Objects to Modify list. Instead, the Objects to Modify list remains empty, as though some refresh has to happen, or the model has corruption causing the model, or entities, not to be recognized for some reason.

In the past I ignored this, and the utility, and moved on. In this case, I have *a ton *of entities to refactor.

One thing I should note: I have another model, and when I open the Refactoring Utility with this model, everything *does *appear in Objects to Modify. The difference – this model has everything in the dbo schema. The scenario I described has all of the entities assigned to a schema called “raw”.

Hello Mark,

The Refactoring Utility doesn’t quite work like that. When you change an object name, it searches through objects text properties (such as SQL code, After Script, Before Script…) and then it displays all found occurrences of the old name and you have the option to refactor them.

When you change an attribute name, it will probably not offer you anything to refactor, unless the old attribute name is referenced in some entity SQL/After Script/Before Script.

However, you can use scripting to rename an attribute in multiple entities at once. If you’d like, I could create such a script for you.

Regards,

Lukas

Lukas, I’m turning my attention back to this because of schema changes I have to make. So if I understand you, you’re saying that references to objects are what the refactoring utility is intended for? Attributes not so much?

I would like to take you up on your offer. I just enabled expert mode and am looking at Script Explorer. I am guessing I can add or modify a script to rename an attribute in multiple entities. If you would be so kind as to create a script sample for me, that would be a huge time-saver!

Hello again Mark,

You’re right, once you rename an object, Refactoring Utility checks all objects SQL, AfterScript and BeforeScript tabs and if there is a reference to the old object name somewhere, it will automatically refactor the code so it references the object by its new name.

As for the script, please see the one enclosed to this post. It automatically renames all “title” attributes to “title new” and lists all changes in Message Explorer. Hopefully, it will be a good starting point for your purposes.

Regards,

Lukas
RenameAttributes.txt (1.38 KB)