Trouble with view and proc code getting out of sync

I am using Datagrip with SQL Server 2008. I started using Datagrip because of my extremely positive experience with IntelliJ, Pycharm, and CLion.

I am having a heck of a time with stored procedures and view code not refreshing. I can synchronize, I can select help->invalidate caches but I still get stale code when I open the objects.

I can turn on the "notify when object has changed", then click on Revert Local Changes after I open it.. but that takes 30-40 seconds each time before the link to revert actually works. Then, every time I make a change and commit it, it pops up again. Shouldn't the version that was just committed to the server match what is in my edit?

I am not understanding why reverting is slow and why synchronizing is not working. It seems that if I synchronize (or do invalidate  cache) I should get the "current" version?

It has gotten to the point that I don't trust Datagrip despite all its awesome features. I am always uncomfortable that I may be losing some important change done outside of Datagrip.

Is there something I should be doing in the connection settings or in setup that will force newly opened objects to always reflect the current state of the server?

Thanks much,

Chris

 

 

38 comments
Comment actions Permalink

@Aman Subhan

1. No, your source code is applied only when you click submit, it will show you the code to be executed, so that is not kind of background operation. Also, you can always review queries performed by DG in SQL log (Help/Show SQL log...)

0
Comment actions Permalink

For my first question from Devs, I havnt received any answer yet.

In reference to the point 2 in my last comment please see this feature screenshot from Devart DBForge

 

Can we have this kind of cache refresh capability?

0
Comment actions Permalink

Hello, everybody! In 2018.3 we are testing the new functionality. Please, give it a try.

  1. Turn on Notify when the outdated object is opened

  2. If the source code is changed from another place, you'll see the notification.

  3. Choose to synchronise the database if you wish.

0
Comment actions Permalink

I thought I had a synchronization issue as described above, but found that I was not using the tool properly.  I was expecting it to act exactly like SQL Management Studio.  Below is what was doing.

  1. Double click a procedure which then brings up a the CREATE PROCEDURE.
  2. Change the CREATE to ALTER and then make my change.
  3. Select all text and click run.
  4. Expect my procedure to be updated.
  5. It did not alter on the server. Forcing refresh did not help

The problem was that the file opened after double clicking procedure was not capable of running the script. This is what worked for me.

  1. Double click a procedure which then brings up a the CREATE PROCEDURE.
  2. Select all of the text and create a new scratch file...pasting the text to the scratch file.
  3. Change the CREATE to ALTER and then make my change.
  4. Select all text and click run.
  5. The alter statement has now altered the procedure on the database.

I hope this helps someone.

 

 

 

1
Comment actions Permalink

Fortunately, for me anyway, most of the sync/desync issues have been resolved over the past several updates.

I haven't experienced that specific problem before. An alternative to selecting all text, creating a new scratch file and pasting it in might be to right-click the proc and select "SQL Scripts -> Generate DDL to Console". It essentially does the same thing but without creating a new scratch file with the copy/paste, removing a few steps. Hope that helps!

0
Comment actions Permalink

A Hebden6719

Your first approach is right, but don't change CREATE to ALTER. DataGrip can submit the code in a proper way.

Just make the changes you need and press the Submit button. It's with green arrow.

 

0
Comment actions Permalink

@Maxim, that has never worked for me if the proc already exists on the server. It fails because it executes a CREATE statement instead of ALTER. I always have to change it to ALTER in the script first. This is for MSSQL databases, not sure if that works for other types.

0
Comment actions Permalink

What version are you using? Please, see my screenshot.

0

Please sign in to leave a comment.