sqlsnip 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/sqlsnip +16 -2
- data/lib/sqlsnip/version.rb +1 -1
- data/lib/sqlsnip.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 540b170ccb1ae5a38045089f209f9b373ab46695e2c96dbb3eb40450789cb36f
|
4
|
+
data.tar.gz: ccebd8ecef866998db72f924a1c7ad06677d86eaf1d013b3eca6d86459dd9973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e3ffd644aedf35c9ab808b0f1184b77e1c27b86f8c5b7cd3566da050959e250af8cad0ae7330090dff1b790269205afbe90dcf7bcf35fba91aa444d6ca28fce
|
7
|
+
data.tar.gz: fa073d37e19ce9cbcc3835777fa94dacac2c9426a3a4ed864cf5958b4ae0209ceddf0fab47e55e7fba53a3162d247d2f256520f162479bf1969033d591824307
|
data/exe/sqlsnip
CHANGED
@@ -44,7 +44,7 @@ SPEC = %(
|
|
44
44
|
sqlsnip can be used to create a vim macro in .vimrcc that executes the
|
45
45
|
selected text or the whole file:
|
46
46
|
|
47
|
-
function! PrepareSqlRange() range
|
47
|
+
\\function! PrepareSqlRange() range
|
48
48
|
let path = expand('%:p')
|
49
49
|
let start_line = line("'<")
|
50
50
|
let end_line = line("'>")
|
@@ -68,7 +68,21 @@ SPEC = %(
|
|
68
68
|
|
69
69
|
...or to just replace the current selected text with drop statements
|
70
70
|
|
71
|
-
|
71
|
+
\\function! ReplaceSqlRange() range " ChatGPT
|
72
|
+
let start_line = line("'<")
|
73
|
+
let end_line = line("'>")
|
74
|
+
let save_cursor = getpos('.')
|
75
|
+
let range_text = getline(start_line, end_line)
|
76
|
+
let path = expand('%:p')
|
77
|
+
let shell_output = system('exe/sqlsnip -ds"" ' . path)
|
78
|
+
let shell_output_lines = split(shell_output, "\n")
|
79
|
+
call deletebufline('%', start_line, end_line)
|
80
|
+
call append(start_line - 1, shell_output_lines)
|
81
|
+
call setpos('.', save_cursor)
|
82
|
+
endfunction
|
83
|
+
|
84
|
+
" CTRL+I - insert drop statements
|
85
|
+
map <C-I> :call ReplaceSqlRange()<CR>
|
72
86
|
|
73
87
|
)
|
74
88
|
|
data/lib/sqlsnip/version.rb
CHANGED
data/lib/sqlsnip.rb
CHANGED
@@ -145,14 +145,14 @@ module Sqlsnip
|
|
145
145
|
IO.readlines(file).each.with_index { |line, i|
|
146
146
|
line.chomp!
|
147
147
|
i += 1
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
-
@search_path_stmt = line
|
148
|
+
break if !stop_line.nil? && i > stop_line
|
149
|
+
next if line =~ /^\s*$/
|
150
|
+
if @lines.empty? && @search_path.nil? && line =~ /^\s*set\s+search_path/
|
151
|
+
@search_path_stmt = line
|
152
|
+
elsif !start_line.nil? && i < start_line
|
153
|
+
;
|
152
154
|
elsif stop_line.nil? || i <= stop_line
|
153
155
|
@lines << line
|
154
|
-
else
|
155
|
-
break
|
156
156
|
end
|
157
157
|
}
|
158
158
|
end
|