Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep "Active database" setting in SQL editor (not globally) #5172

Open
crokusek opened this issue Jan 31, 2019 · 5 comments
Open

Keep "Active database" setting in SQL editor (not globally) #5172

crokusek opened this issue Jan 31, 2019 · 5 comments
Milestone

Comments

@crokusek
Copy link

@crokusek crokusek commented Jan 31, 2019

System information:

  • Windows 10
  • 5.3.3.201901202008
  • JRE came with that version

Connection specification:

  • SQL Server

Describe the problem you're observing:

There is no visual feedback that guarantees which DB the current active editor is executing against. This is critical knowledge and available in other DB tools. It is very common for a user to have multiple tabs executing against multiple databases. Switching to a prior tab should list somewhere which database it is pointing to.

Surely there are multiple ways to improve this. There was a prior discussion about this in 628. There was a concern that some existing users would not be happy with the changes proposed there.

Please consider if the following proposal might please everyone. At least one other DB tool works this way:

  1. Key concept is the active catalog dropdown always tracks the db for the current active editor.

  2. (minor) On a new tab, by default it is set to the DB specified from the Connection or from navigator if launched from there somehow.

  3. The DB can be set manually using the dropdown itself. This affects subsequent SQL for only the current editor.

  4. Whenever a command such as "use DatabaseAbc;" is executed in an editor, the dropdown sync's itself to match. Rather than parse commands (error prone) it could instead call 'select db_name()' at the end of each sql command or batch to ensure it has the current value.

  5. When the user switches active tabs, the dropdown is set to whatever DB that tab was executing against that tab before.

Another proposal is to separately show and update the current DB in the status bar lower right hand side each time as the tabs change. Still some implementation such as (4) is involved and then the purpose of the dropdown becomes confusing.

Steps to reproduce, if exist:

  1. Open 3 editors for SQL Server to a connection.
  2. In each editor switch to use a separate database and paste some long scripts in there.
  3. Switch between editors after coming back from lunch, where are you?
@serge-rider

This comment has been minimized.

Copy link
Member

@serge-rider serge-rider commented Feb 11, 2019

Currently DBeaver concept is "One active database/catalog per connection". If you have multiple SQL editors opened for the same connection then they all share the same active database.

DBeaver supports reading active database from server after each query execution:
image

@crokusek

This comment has been minimized.

Copy link
Author

@crokusek crokusek commented Feb 12, 2019

That option is helpful. Vote that option to be checked by default. It works well (except if there is pound sign in the database name related issue #5168).

If there was another option "Retain active database per Editor" or "Independent Editor Connections" then it would be as comfortable as SSMS or TOAD.

Here's what's strange IMO now.

  1. Set option "Open separate connection for each editor",

  2. Set Option "Refresh active schema after SQL Execution"

  3. Open 2 script editors starting from same SQL Server connection.

  4. In Script-1 execute:
    use tempdb;
    select @@spid, db_name() -- shows 111, tempdb and drop down updates

  5. In script-2 execute;
    use Master
    select @@spid, db_name() -- shows 222, master and drop down updates

  6. Click on Script-1 tab.
    Drop down stays same as "master"
    select @@spid, db_name() -- shows 111, "master"

So during step (6) the tool ran a hidden "use master" (even though it is a separate session) sometime before executing the select . Compared to other tools, I think that behavior is unexpected and non-intuitive, especially for a new user. Both SSMS and TOAD do not work like that.

So the recommendation is that when a new tab is selected, to not set the database but instead to just read the current DB for that session and sync the drop down value to match. This seems to be exactly how the SSMS and TOAD are working if anyone wants to see it in action using the above steps.

Anyway if it is decided not to change the behavior, hopefully the issue has been captured accurately for possible future reference.

@serge-rider serge-rider changed the title Active catalog does not always reflect database of current Active Editor Tab. Keep "Active database" setting in SQL editor (not globally) Feb 12, 2019
@serge-rider

This comment has been minimized.

Copy link
Member

@serge-rider serge-rider commented Feb 12, 2019

Perhaps we need yet another config option for that.

@serge-rider serge-rider added this to the 6.0.1 milestone Feb 12, 2019
@crokusek

This comment has been minimized.

Copy link
Author

@crokusek crokusek commented Feb 16, 2019

Not sure how you collectively decide which options are more suitable for new users than others, but
my vote would be to make this new option enabled by default and also enable the option that uses a separate network connection for each tab by default.

@tati-kru tati-kru modified the milestones: 6.0.1, 6.0.5 Mar 12, 2019
@tati-kru tati-kru modified the milestones: 6.0.5, 6.1.2 May 29, 2019
@tati-kru tati-kru added this to Backlog in DBeaver project Jul 3, 2019
@serge-rider serge-rider modified the milestones: 6.1.2, 6.1.3 Jul 7, 2019
@tati-kru tati-kru modified the milestones: 6.1.3, 6.1.5 Jul 22, 2019
@tati-kru tati-kru removed this from Backlog in DBeaver project Jul 22, 2019
@tati-kru tati-kru added this to Backlog in DBeaver project Aug 5, 2019
@serge-rider serge-rider modified the milestones: 6.1.5, 6.3.0 Aug 19, 2019
@tati-kru tati-kru removed this from Backlog in DBeaver project Aug 20, 2019
@tati-kru tati-kru added this to Backlog in DBeaver project Nov 18, 2019
@serge-rider

This comment has been minimized.

Copy link
Member

@serge-rider serge-rider commented Nov 30, 2019

Code impact for this change is too big. We need to refactor all legacy "default object selector" model. We'll add this feature in 6.3.1

@serge-rider serge-rider modified the milestones: 6.3.0, 6.3.1 Nov 30, 2019
@serge-rider serge-rider moved this from Backlog to In Progress in DBeaver project Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
DBeaver project
  
In Progress
3 participants
You can’t perform that action at this time.