1
1
" dbext.vim - Commn Database Utility
2
2
" ---------------------------------------------------------------
3
- " Version: 2.10
3
+ " Version: 2.11
4
4
" Authors: Peter Bagyinszki <[email protected] >
5
5
" David Fishburn <[email protected] >
6
- " Last Modified: Tue Sep 14 2004 5:48:10 PM
6
+ " Last Modified: Wed Sep 22 2004 10:35:18 AM
7
7
" Based On: sqlplus.vim (author: Jamis Buck <[email protected] >)
8
8
" Created: 2002-05-24
9
9
" Homepage: http://vim.sourceforge.net/script.php?script_id=356
14
14
" - Requires multvals.vim to be installed. Download from:
15
15
" http://www.vim.org/script.php?script_id=171
16
16
"
17
- " SourceForge: $Revision: 1.30 $
17
+ " SourceForge: $Revision: 1.31 $
18
18
"
19
19
" Help: :h dbext.txt
20
20
@@ -28,7 +28,7 @@ if !exists("loaded_multvals") || loaded_multvals < 304
28
28
echomsg " dbext: You need to have multvals version 3.4 or higher"
29
29
finish
30
30
endif
31
- let g: loaded_dbext = 210
31
+ let g: loaded_dbext = 211
32
32
33
33
" Script variable defaults {{{
34
34
let s: mv_sep = " ,"
@@ -103,6 +103,7 @@ function! s:DB_buildLists()
103
103
let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' custom_title' )
104
104
let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' use_tbl_alias' )
105
105
let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' delete_temp_file' )
106
+ let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' dbext_version' )
106
107
107
108
" DB server specific params
108
109
" See below for 3 additional DB2 items
@@ -528,6 +529,7 @@ function! s:DB_getDefault(name)
528
529
elseif a: name == # " replace_title" |return (exists (" g:dbext_default_replace_title" )?g: dbext_default_replace_title .' ' :0 )
529
530
elseif a: name == # " use_tbl_alias" |return (exists (" g:dbext_default_use_tbl_alias" )?g: dbext_default_use_tbl_alias .' ' :' d' )
530
531
elseif a: name == # " delete_temp_file" |return (exists (" g:dbext_default_delete_temp_file" )?g: dbext_default_delete_temp_file .' ' :' 1' )
532
+ elseif a: name == # " dbext_version" |return (g: loaded_dbext )
531
533
elseif a: name == # " ASA_bin" |return (exists (" g:dbext_default_ASA_bin" )?g: dbext_default_ASA_bin .' ' :' dbisql' )
532
534
elseif a: name == # " ASA_cmd_terminator" |return (exists (" g:dbext_default_ASA_cmd_terminator" )?g: dbext_default_ASA_cmd_terminator .' ' :' ;' )
533
535
elseif a: name == # " ASA_cmd_options" |return (exists (" g:dbext_default_ASA_cmd_options" )?g: dbext_default_ASA_cmd_options .' ' :' -nogui' )
@@ -1347,7 +1349,9 @@ function! s:DB_ASA_execSql(str)
1347
1349
let output = output . s: DB_getWType (" cmd_terminator" )
1348
1350
endif
1349
1351
1350
- let tempfile = tempname ()
1352
+ " Ensure the tempfile has a .sql extension, windows automatically
1353
+ " adds an extension, Linux does not.
1354
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1351
1355
exe ' redir! > ' . tempfile
1352
1356
silent echo output
1353
1357
redir END
@@ -1481,7 +1485,9 @@ function! s:DB_ASE_execSql(str)
1481
1485
let output = output . s: DB_getWType (" cmd_terminator" )
1482
1486
endif
1483
1487
1484
- let tempfile = tempname ()
1488
+ " Ensure the tempfile has a .sql extension, windows automatically
1489
+ " adds an extension, Linux does not.
1490
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1485
1491
exe ' redir! > ' . tempfile
1486
1492
silent echo output
1487
1493
redir END
@@ -1664,7 +1670,9 @@ function! s:DB_DB2_execSql(str)
1664
1670
let output = output . s: DB_getWType (" cmd_terminator" )
1665
1671
endif
1666
1672
1667
- let tempfile = tempname ()
1673
+ " Ensure the tempfile has a .sql extension, windows automatically
1674
+ " adds an extension, Linux does not.
1675
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1668
1676
exe ' redir! > ' . tempfile
1669
1677
silent echo output
1670
1678
redir END
@@ -1700,7 +1708,9 @@ function! s:DB_DB2_execSql(str)
1700
1708
let output = output . s: DB_getWType (" cmd_terminator" )
1701
1709
endif
1702
1710
1703
- let tempfile = tempname ()
1711
+ " Ensure the tempfile has a .sql extension, windows automatically
1712
+ " adds an extension, Linux does not.
1713
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1704
1714
exe ' redir! > ' . tempfile
1705
1715
silent echo output
1706
1716
redir END
@@ -1873,7 +1883,9 @@ function! s:DB_INGRES_execSql(str)
1873
1883
let output = output . s: DB_getWType (" cmd_terminator" )
1874
1884
endif
1875
1885
1876
- let tempfile = tempname ()
1886
+ " Ensure the tempfile has a .sql extension, windows automatically
1887
+ " adds an extension, Linux does not.
1888
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1877
1889
exe ' redir! > ' . tempfile
1878
1890
silent echo output
1879
1891
redir END
@@ -1956,7 +1968,9 @@ function! s:DB_INTERBASE_execSql(str)
1956
1968
let output = output . s: DB_getWType (" cmd_terminator" )
1957
1969
endif
1958
1970
1959
- let tempfile = tempname ()
1971
+ " Ensure the tempfile has a .sql extension, windows automatically
1972
+ " adds an extension, Linux does not.
1973
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
1960
1974
exe ' redir! > ' . tempfile
1961
1975
silent echo output
1962
1976
redir END
@@ -2041,7 +2055,9 @@ function! s:DB_MYSQL_execSql(str)
2041
2055
let output = output . s: DB_getWType (" cmd_terminator" )
2042
2056
endif
2043
2057
2044
- let tempfile = tempname ()
2058
+ " Ensure the tempfile has a .sql extension, windows automatically
2059
+ " adds an extension, Linux does not.
2060
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
2045
2061
exe ' redir! > ' . tempfile
2046
2062
silent echo output
2047
2063
redir END
@@ -2164,7 +2180,9 @@ function! s:DB_SQLITE_execSql(str)
2164
2180
let output = output . s: DB_getWType (" cmd_terminator" )
2165
2181
endif
2166
2182
2167
- let tempfile = tempname ()
2183
+ " Ensure the tempfile has a .sql extension, windows automatically
2184
+ " adds an extension, Linux does not.
2185
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
2168
2186
exe ' redir! > ' . tempfile
2169
2187
silent echo output
2170
2188
redir END
@@ -2289,7 +2307,9 @@ function! s:DB_ORA_execSql(str)
2289
2307
let output = output . s: DB_getWType (" cmd_terminator" )
2290
2308
endif
2291
2309
2292
- let tempfile = tempname ()
2310
+ " Ensure the tempfile has a .sql extension, windows automatically
2311
+ " adds an extension, Linux does not.
2312
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
2293
2313
exe ' redir! > ' . tempfile
2294
2314
silent echo output
2295
2315
redir END
@@ -2436,7 +2456,9 @@ function! s:DB_PGSQL_execSql(str)
2436
2456
let output = output . s: DB_getWType (" cmd_terminator" )
2437
2457
endif
2438
2458
2439
- let tempfile = tempname ()
2459
+ " Ensure the tempfile has a .sql extension, windows automatically
2460
+ " adds an extension, Linux does not.
2461
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
2440
2462
exe ' redir! > ' . tempfile
2441
2463
silent echo output
2442
2464
redir END
@@ -2584,7 +2606,9 @@ function! s:DB_SQLSRV_execSql(str)
2584
2606
let output = output . s: DB_getWType (" cmd_terminator" )
2585
2607
endif
2586
2608
2587
- let tempfile = tempname ()
2609
+ " Ensure the tempfile has a .sql extension, windows automatically
2610
+ " adds an extension, Linux does not.
2611
+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
2588
2612
exe ' redir! > ' . tempfile
2589
2613
silent echo output
2590
2614
redir END
@@ -2845,6 +2869,10 @@ function! DB_getListColumn(...)
2845
2869
" Convert newlines into commas
2846
2870
" let col_list = substitute( col_list, '\w\>\zs[ '."\<C-J>".']*\ze\w', '\1, ', 'g' )
2847
2871
let col_list = substitute ( col_list, ' \w\>\zs[^.].\{-}\ze\<\w' , ' , ' , ' g' )
2872
+ " Make sure the column list does not end in a newline, makes
2873
+ " pasting into a buffer more difficult since you cannot
2874
+ " insert it between words
2875
+ let col_list = substitute ( col_list, " \\ s*\\ n$" , ' ' , ' ' )
2848
2876
else
2849
2877
let col_list = substitute ( col_list, ' ,\s*' , " \n " , ' g' )
2850
2878
endif
0 commit comments