提交 93da57e0 编写于 作者: C Cosmin Popescu

version 5.1

上级 156131f6
......@@ -568,6 +568,34 @@ shortcut.
Alternatively, you can execute the `WbDisplay` command. See
[here](http://www.sql-workbench.net/manual/console-mode.html) for more detail.
## Filtering the resultset
While in the result window, you can filter the displayed rows. With the cursor
on a resultset, you can just call the `SWSqlFilterColumn` command with the
name of the column as a parameter (you can also click `tab` after the command,
a list of available columns will be displayed). After this you will be asked
to insert a filter value.
The filter value can be a regular expression pattern or an arithmetic value
(this begins with `>`, `<` or `==`)
*Note*: The filtering is done row by row. This means that if you have a
multirow column, the filtering will be done based on each row of that column
and not by the full value.
*Note2*: If you want to filter for a mathematical value for equality, you have
to insert two equal signs (`==`). For example: `== 471`.
## Hiding columns
While in a result window, you can hide columns from a result set.
With the cursor on a resultset, you can call the `SWSqlHideColumn` command.
The command takes as an argument the name of the column to hide (there is also
an autocomplete with the available columns).
Example: `SWSqlHideColumn last_name`
SQL commands
========================================
......@@ -949,6 +977,74 @@ Reconnects the database explorer. This is useful if a timeout has occured
while having a database connection opened. Then you call the
`SWDbExplorerReconnect` in order to be able to execute commands again.
## SWSqlShowAllColumns
This will unhide all hidden columns from the current result set
## SWSqlShowOnlyColumn
*Parameters*:
* column name: the name of the column to show
This will hide all the columns from the current resultset with the exception
of the mentioned column.
*Note*: there is an autocomplete for the column name
## SWSqlShowOnlyColumns
* column names: a list of white space separated list of columns to be shown
This will hide all the columns from the current resultset with the exception
of the mentioned columns
*Note*: there is an autocomplete for the column names
## SWSqlShowColumn
*Parameters*:
* column name: the name of the column to show
This will show the indicated column name (assuming that it is hidden)
*Note*: there is an autocomplete for the column name
## SWSqlHideColumn
*Parameters*:
* column name: the name of the column to hide
This will hide the indeicated column.
*Note*: there is an autocomplete for the column name
## SWSqlFilterColumn
*Parameters*:
* column name: the name of the column to filter
This will apply a filter on the specified column.
*Note*: there is an autocomplete for the column name
## SWSqlUnfilterColumn
*Parameters*:
* column name: the name of the column to unfilter
This will remove any filters applied on the specified column.
*Note*: there is an autocomplete for the column name
## SWSqlRemoveAllFilters
This will remove all filters applied for the current resultset.
Settings
========================================
......
......@@ -35,7 +35,46 @@
" asynchronous (you can execute any command asynchronous)
" fully customizable
"
"
function! sw#complete_ports(findstart, base, P)
let result = []
for port in s:ports
if port =~ '^' . a:base
call add(result, port)
endif
endfor
return result
endfunction
function! sw#get_server_port()
if exists('b:port')
return b:port
endif
let b_nr = bufnr('%')
let s:ports = []
bufdo if exists('b:port') | if (index(s:ports, b:port) < 0) | call add(s:ports, b:port) | endif | endif
execute "normal \<c-o>"
if len(s:ports) == 0
return -1
endif
if len(s:ports) == 1
return s:ports[0]
endif
let s:ports = s:ports
let prompt = ''
for port in s:ports
let prompt = prompt . (prompt == '' ? '' : ', ') . port
endfor
return input('Please choose a port (' . prompt . '): ', '', 'customlist,sw#complete_ports')
endfunction
let s:error = 0
if !exists('g:Sw_unique_id')
let g:Sw_unique_id = 1
......@@ -119,10 +158,13 @@ function! sw#async_end()
endfunction
function! sw#got_async_result(unique_id)
let s:error = 0
if s:get_buff_unique_id() == a:unique_id
call sw#interrupt('sw#async_end()')
endif
redraw!
if !s:error
redraw!
endif
return ''
endfunction
......@@ -152,10 +194,17 @@ endfunction
" Executes an sql command{{{1
function! sw#execute_sql(command, wait_result)
if (!exists('b:port'))
let port = sw#get_server_port()
if port == ''
return
endif
if (port == -1)
call sw#display_error("This buffer is not an sql workbench buffer.")
return
endif
let g:sw_last_sql_query = a:command
if (exists('w:auto_added1') && exists('w:auto_added2'))
let s1 = substitute(w:auto_added1, "\n", '', 'g')
......@@ -177,7 +226,7 @@ function! sw#execute_sql(command, wait_result)
endfor
endif
endif
return sw#server#execute_sql(a:command, a:wait_result, b:port)
return sw#server#execute_sql(a:command, a:wait_result, port)
endfunction
" Exports as ods{{{1
......@@ -446,6 +495,7 @@ function! sw#autocomplete_profile_for_buffer(ArgLead, CmdLine, CursorPos)
endfunction
function! sw#display_error(msg)
let s:error = 1
echohl WarningMsg
echomsg a:msg
echohl None
......
......@@ -93,13 +93,20 @@ function! s:pipe_execute(type, cmd, wait_result, ...)
let uid = b:unique_id
endif
let statements = 0
let sql = a:cmd
if a:type == 'COM' || a:type == 'DBE'
let delimiter = ';'
if exists('b:delimiter')
let delimiter = b:delimiter
endif
let statements = len(sw#sql_split(a:cmd, delimiter))
let statements = sw#sql_split(a:cmd, delimiter)
let sql = ''
for statement in statements
let sql .= (sql == '' ? '' : delimiter . "\n==========\n") . statement
endfor
if !(a:cmd =~ '\v^[^\n]+\n$')
let sql .= delimiter
endif
endif
try
......@@ -108,7 +115,7 @@ import vim
import socket
import re
identifier = vim.eval('v:servername') + "#" + vim.eval('uid')
cmd = vim.eval('a:cmd')
cmd = vim.eval('sql')
port = int(vim.eval('port'))
type = vim.eval('a:type')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
......@@ -116,10 +123,10 @@ s.connect(('127.0.0.1', port))
packet = ''
packet += type
if vim.eval('a:wait_result') == '0' and vim.eval('a:type') != 'VAL':
packet += "!#identifier = " + identifier + "\n"
packet += '?' + identifier + '?'
#end if
packet += cmd
packet = str(len(packet)) + "?" + vim.eval('statements') + "#" + packet
packet = str(len(packet)) + "#" + packet
s.sendall(packet)
result = ''
if vim.eval('a:wait_result') == '1':
......
此差异已折叠。
此差异已折叠。
......@@ -186,6 +186,14 @@ command! -bang -nargs=* SWSqlAutocomplete call sw#autocomplete#cache(<bang>0, <f
command! -nargs=1 -complete=customlist,sw#autocomplete#complete_cache_name SWSqlAutocompleteLoad call sw#autocomplete#load(<f-args>)
command! -nargs=1 -complete=customlist,sw#autocomplete#complete_cache_name SWSqlAutocompletePersist call sw#autocomplete#persist(<f-args>)
command! SWSqlBufferRestore call sw#session#restore_sqlbuffer()
command! -nargs=0 SWSqlShowAllColumns call sw#sqlwindow#show_all_columns()
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlShowOnlyColumn call sw#sqlwindow#show_only_column(<f-args>)
command! -nargs=+ -complete=customlist,sw#sqlwindow#complete_columns SWSqlShowOnlyColumns call sw#sqlwindow#show_only_columns([<f-args>])
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlShowColumn call sw#sqlwindow#show_column(<f-args>, 1)
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlHideColumn call sw#sqlwindow#hide_column(<f-args>, 1)
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlFilterColumn call sw#sqlwindow#filter_column(<f-args>)
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlUnfilterColumn call sw#sqlwindow#un_filter_column(<f-args>)
command! -nargs=0 SWSqlRemoveAllFilters call sw#sqlwindow#remove_all_filters()
command! -nargs=+ -complete=customlist,sw#autocomplete_profile SWServerStart call sw#server#run(<f-args>)
command! -nargs=1 SWServerStop call sw#server#stop(<f-args>)
......@@ -193,7 +201,7 @@ command! -nargs=1 SWServerStop call sw#server#stop(<f-args>)
augroup sw
autocmd sw BufDelete,BufWipeout * call sw#session#sync()
autocmd sw SessionLoadPost * call sw#session#restore()
autocmd sw BufEnter * call sw#sqlwindow#close_all_result_sets()
""autocmd sw BufEnter * call sw#sqlwindow#close_all_result_sets()
""autocmd sw BufEnter * call sw#session#check()
""autocmd sw TabEnter * call sw#dbexplorer#restore_from_session()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册