This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 192020 - add ability to cycle through SQL history
Summary: add ability to cycle through SQL history
Status: NEW
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.4
Hardware: PC Other
: P3 normal with 1 vote (vote)
Assignee: Libor Fischmeistr
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2010-11-16 16:58 UTC by athompson
Modified: 2014-10-04 15:38 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
patch for db.core v1 (12.01 KB, patch)
2014-10-04 15:31 UTC, matthias42
Details | Diff
patch for db.sql.editor v1 (18.84 KB, patch)
2014-10-04 15:38 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description athompson 2010-11-16 16:58:46 UTC
The SQL History dialog is time-consuming and awkward.  Unless your queries are extremely short, you can't differentiate between them in the limited space in the dialog. If your queries were that short it would be quicker to type them in again, anyway.  Also, while I can guess the logic behind it, inserting the chosen SQL at the insertion point instead of replacing any current SQL in the editor doesn't adhere to the principle of least astonishment.

Instead, why not do away with the dialog completely and just add arrow buttons on the toolbar to cycle back and forth in your history, much as unix command prompts do?  Hitting an arrow would replace whatever is in the editor with the previous/next item in the history as it works with the command prompt.  Same problem, same solution.  If this weren't the least evil solution to the problem, command prompts would have abandoned it long ago.
Comment 1 athompson 2011-07-25 16:28:56 UTC
I really do think this is a good idea that would improve productivity.  This can be added without affecting the current system, so why not let users decide which one they prefer?

Also, keyboard shortcuts would be good.  :)
Comment 2 athompson 2013-04-05 20:33:17 UTC
The current history options have improved, but it would still be very convenient to have a hotkey which allows you to cycle through you SQL history. Having to take your hand off of the keyboard, click the History button, and look through the dialog to find the command you want to modify or simply run again is more time consuming and breaks concentration. I reiterate that there's a reason (aside from UI format) that command prompts invariably work this way.
Comment 3 matthias42 2014-10-04 15:31:37 UTC
Created attachment 149703 [details]
patch for db.core v1

The attached patch adds an API to have read-only access to the SQL history (the Set of entries and the entries themselfs are copied on access).
Comment 4 matthias42 2014-10-04 15:38:04 UTC
Created attachment 149704 [details]
patch for db.sql.editor v1

This is the second part and depends on the changes to db.core from the first patch. This patch introduces a new Action (SQLInplaceHistoryAction), that:

1. Adds a boolean property to the Document that holds the SQL-File org.netbeans.modules.db.sql.editor.ui.actions.SQLInplaceHistoryAction
2. Invokes code completion

The SQLCompletionProvider is modified to pick up the new property from the Document. If the property is present and true, a new completion code patch is invoked (and the property reset), that compares the current statement prefix with the history. If a history entry hold the same prefix it is added as a completion item. Selecting an entry replaces the current statement prefix with the selected SQL statement.