1
1
" dbext.vim - Commn Database Utility
2
2
" Copyright (C) 2002-10, Peter Bagyinszki, David Fishburn
3
3
" ---------------------------------------------------------------
4
- " Version: 18 .00
4
+ " Version: 19 .00
5
5
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
6
6
" Authors: Peter Bagyinszki <petike1 at dpg dot hu>
7
7
" David Fishburn <dfishburn dot vim at gmail dot com>
8
- " Last Modified: 2012 Oct 31
8
+ " Last Modified: 2013 Apr 29
9
9
" Based On: sqlplus.vim (author: Jamis Buck)
10
10
" Created: 2002-05-24
11
11
" Homepage: http://vim.sourceforge.net/script.php?script_id=356
@@ -38,7 +38,7 @@ if v:version < 700
38
38
echomsg " dbext: Version 4.00 or higher requires Vim7. Version 3.50 can stil be used with Vim6."
39
39
finish
40
40
endif
41
- let g: loaded_dbext_auto = 1800
41
+ let g: loaded_dbext_auto = 1900
42
42
43
43
" Turn on support for line continuations when creating the script
44
44
let s: cpo_save = &cpo
@@ -133,6 +133,7 @@ function! s:DB_buildLists()
133
133
call add (s: conn_params_mv , ' driver' )
134
134
call add (s: conn_params_mv , ' conn_parms' )
135
135
call add (s: conn_params_mv , ' driver_parms' )
136
+ call add (s: conn_params_mv , ' cmd_terminator' )
136
137
137
138
" Saved connection parameters
138
139
let s: saved_conn_params_mv = []
@@ -152,6 +153,7 @@ function! s:DB_buildLists()
152
153
call add (s: saved_conn_params_mv , ' saved_driver' )
153
154
call add (s: saved_conn_params_mv , ' saved_conn_parms' )
154
155
call add (s: saved_conn_params_mv , ' saved_driver_parms' )
156
+ call add (s: saved_conn_params_mv , ' saved_cmd_terminator' )
155
157
156
158
" Configuration parameters
157
159
let s: config_params_mv = []
@@ -541,10 +543,19 @@ function! s:DB_set(name, value)
541
543
" Now set the connection parameters from the profile
542
544
if s: DB_parseProfile (value) == -1
543
545
return -1
546
+ else
547
+ return 0
544
548
endif
545
549
endif
546
550
547
- if index (s: script_params_mv , a: name ) > -1
551
+ if index (s: db_params_mv , tolower (a: name )) > -1
552
+ " Only when the database type has been specified
553
+ " as these parameters are reset often when changing
554
+ " profiles
555
+ if b: dbext_type != ' '
556
+ call s: DB_setWType (tolower (a: name ), value)
557
+ endif
558
+ elseif index (s: script_params_mv , a: name ) > -1
548
559
let s: dbext_ {a: name } = value
549
560
else
550
561
let b: dbext_ {a: name } = value
@@ -1299,16 +1310,19 @@ function! s:DB_promptForParameters(...)
1299
1310
endif
1300
1311
1301
1312
let diag_prompt = s: DB_getDefault (" prompt_" . param)
1302
- let l: old_value = s: DB_get (param, no_default)
1303
- let l: new_value = s: DB_getInput (
1304
- \ diag_prompt,
1305
- \ l: old_value ,
1306
- \ " -1"
1307
- \ )
1313
+ let l: new_value = ' -1'
1314
+ if diag_prompt != ' '
1315
+ let l: old_value = s: DB_get (param, no_default)
1316
+ let l: new_value = s: DB_getInput (
1317
+ \ diag_prompt,
1318
+ \ l: old_value ,
1319
+ \ " -1"
1320
+ \ )
1321
+ endif
1308
1322
endif
1309
1323
" If the user cancelled the input, break from the loop
1310
1324
" this is a new 602 feature
1311
- if l: new_value == " -1 "
1325
+ if l: new_value == ' -1 '
1312
1326
let retval = l: new_value
1313
1327
break
1314
1328
elseif l: new_value !=# l: old_value
@@ -2235,7 +2249,7 @@ function! s:DB_DB2_execSql(str)
2235
2249
let cmd = cmd .
2236
2250
\ s: DB_option (' ' , dbext#DB_getWTypeDefault (" extra" ), ' ' ) .
2237
2251
\ s: DB_option (' -d ' , s: DB_get (" dbname" ), ' ' ) .
2238
- \ s: DB_option (' -l ' , dbext#DB_getWType (" cmd_terminator" ), ' ' ).
2252
+ \ (( dbext#DB_getWType ( " cmd_terminator " ) != ' ' )?( s: DB_option (' -l ' , dbext#DB_getWType (" cmd_terminator" ), ' ' )): ' ' ) .
2239
2253
\ ' -f ' . s: dbext_tempfile
2240
2254
2241
2255
else
@@ -2280,7 +2294,7 @@ function! s:DB_DB2_execSql(str)
2280
2294
2281
2295
let cmd = dbext_bin . ' ' . dbext#DB_getWType (" db2cmd_cmd_options" )
2282
2296
let cmd = cmd . ' ' . s: DB_option (' ' , dbext#DB_getWTypeDefault (" extra" ), ' ' ) .
2283
- \ s: DB_option (' -t' , dbext#DB_getWType (" cmd_terminator" ), ' ' ) .
2297
+ \ (( dbext#DB_getWType ( " cmd_terminator " ) != ' ' )?( s: DB_option (' -t' , dbext#DB_getWType (" cmd_terminator" ), ' ' )): ' ' ) .
2284
2298
\ ' -f ' . s: dbext_tempfile
2285
2299
endif
2286
2300
@@ -3089,9 +3103,10 @@ function! s:DB_PGSQL_check_pgpass()
3089
3103
call s: DB_warningMsg (
3090
3104
\ " dbext:PostgreSQL requires a '" .
3091
3105
\ dbext#DB_getWType (" pgpass" ).
3092
- \ " ' file in order to authenticate. " .
3093
- \ ' This file is missing. ' .
3094
- \ " The binary '" .
3106
+ \ " ' file in order to authenticate. " .
3107
+ \ " This file is missing. If you are using " .
3108
+ \ " a local connection, you can create an " .
3109
+ \ " empty .pgpass file. The binary '" .
3095
3110
\ dbext#DB_getWType (" bin" ).
3096
3111
\ " ' does not accept commandline passwords."
3097
3112
\ )
@@ -5477,12 +5492,12 @@ function! s:DB_getLoginScript(filename)
5477
5492
endif
5478
5493
5479
5494
if custom_login_script_dir == ' '
5480
- let filename = expand (' $VIM' ).' /' .filename
5495
+ let filename = expand (' $VIM' ).' /' .matchstr ( a: filename, ' \f\+ ' )
5481
5496
" Check if the filename is readable
5482
5497
if filereadable (filename)
5483
5498
let sqlf = readfile (filename)
5484
5499
else
5485
- let filename = expand (' $HOME' ).' /' .filename
5500
+ let filename = expand (' $HOME' ).' /' .matchstr ( a: filename, ' \f\+ ' )
5486
5501
if filereadable (filename)
5487
5502
let sqlf = readfile (filename)
5488
5503
else
@@ -5496,7 +5511,7 @@ function! s:DB_getLoginScript(filename)
5496
5511
endif
5497
5512
endif
5498
5513
5499
- if len (sqlf) > 0
5514
+ if ! empty (sqlf)
5500
5515
let sql = join (sqlf, " \n " )." \n "
5501
5516
endif
5502
5517
endif
@@ -7055,7 +7070,7 @@ function! s:DB_searchReplace(str, exp_find_str, exp_get_value, count_matches)
7055
7070
" The above query gathers the preceeding text to make the above
7056
7071
" determination
7057
7072
" if inout !~? '\(in\|out\|inout\|declare\|set\|variable\|''\|/\|@\)'
7058
- if inout !~? s: DB_get (' ignore_variable_regex' )
7073
+ if s: DB_get (' ignore_variable_regex' ) !~? inout
7059
7074
" Check if the variable name is preceeded by a comment character.
7060
7075
" If so, ignore and continue.
7061
7076
if strpart (str, 0 , (index - 1 )) !~ ' \(--\|\/\/\)\s*$'
@@ -7487,7 +7502,7 @@ function! s:DB_parseJava(query)
7487
7502
" These can be single or double quotes
7488
7503
let leading_quote_regex = ' \%(^[\t "]*\)\?'
7489
7504
let leading_quote = matchstr ( query, leading_quote_regex )
7490
- if leading_quote != ' '
7505
+ if substitute ( leading_quote, ' \s\+ ' , ' ' , ' g ' ) != ' '
7491
7506
let query = substitute (query,
7492
7507
\ leading_quote_regex,
7493
7508
\ ' ' ,
@@ -7738,6 +7753,7 @@ function! s:DB_parseProfile(value)
7738
7753
let profile_name = " g:dbext_default_profile_" . a: value
7739
7754
7740
7755
if exists (profile_name)
7756
+ let b: dbext_profile = a: value
7741
7757
let profile_value = g: dbext_default_profile_ {a: value }
7742
7758
else
7743
7759
let rc = -1
0 commit comments