sqlsnip 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 540b170ccb1ae5a38045089f209f9b373ab46695e2c96dbb3eb40450789cb36f
4
- data.tar.gz: ccebd8ecef866998db72f924a1c7ad06677d86eaf1d013b3eca6d86459dd9973
3
+ metadata.gz: da5dc4aa93bac3c09d7b2df296116bbe8d9a1ad83785e30b1bf3a253f01d91f6
4
+ data.tar.gz: 78598632051075b2d1893c94bcf4340087d8bc0628d1deaca9c80c1d35cba201
5
5
  SHA512:
6
- metadata.gz: 1e3ffd644aedf35c9ab808b0f1184b77e1c27b86f8c5b7cd3566da050959e250af8cad0ae7330090dff1b790269205afbe90dcf7bcf35fba91aa444d6ca28fce
7
- data.tar.gz: fa073d37e19ce9cbcc3835777fa94dacac2c9426a3a4ed864cf5958b4ae0209ceddf0fab47e55e7fba53a3162d247d2f256520f162479bf1969033d591824307
6
+ metadata.gz: 9ba077ae02097d9d94bbc7d81e8b5cf203f0922dd40c7efaf7d2f580e00659df088bb9dac95f44ac5ab1747574644dd2f0b2dfc64a8d755898b6c12ec9b5cab1
7
+ data.tar.gz: dc1aef5440a47282ec653bf3a65e5cdb48fff8688b81779f6a4b7cd813ce01434e7e33d59d2c8766fa3b3852df22a0f34360ececc40fee84341569c0eb6c0933
data/exe/sqlsnip CHANGED
@@ -68,14 +68,14 @@ SPEC = %(
68
68
 
69
69
  ...or to just replace the current selected text with drop statements
70
70
 
71
- \\function! ReplaceSqlRange() range " ChatGPT
71
+ \\function! ReplaceSqlRange() range
72
72
  let start_line = line("'<")
73
73
  let end_line = line("'>")
74
74
  let save_cursor = getpos('.')
75
75
  let range_text = getline(start_line, end_line)
76
76
  let path = expand('%:p')
77
77
  let shell_output = system('exe/sqlsnip -ds"" ' . path)
78
- let shell_output_lines = split(shell_output, "\n")
78
+ let shell_output_lines = split(shell_output, "\\n")
79
79
  call deletebufline('%', start_line, end_line)
80
80
  call append(start_line - 1, shell_output_lines)
81
81
  call setpos('.', save_cursor)
@@ -83,7 +83,6 @@ SPEC = %(
83
83
 
84
84
  " CTRL+I - insert drop statements
85
85
  map <C-I> :call ReplaceSqlRange()<CR>
86
-
87
86
  )
88
87
 
89
88
  opts, args = ShellOpts.process(SPEC, ARGV)
@@ -101,3 +100,17 @@ if !opts.drop_only?
101
100
  puts source.lines
102
101
  end
103
102
 
103
+ __END__
104
+ \\function! ReplaceSqlRange() range
105
+ let start_line = line("'<")
106
+ let end_line = line("'>")
107
+ let save_cursor = getpos('.')
108
+ let range_text = getline(start_line, end_line)
109
+ let path = expand('%:p')
110
+ let shell_output = system('exe/sqlsnip -ds"" ' . path)
111
+ let shell_output_lines = split(shell_output, "\n")
112
+ call deletebufline('%', start_line, end_line)
113
+ call append(start_line - 1, shell_output_lines)
114
+ call setpos('.', save_cursor)
115
+ endfunction
116
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sqlsnip
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/sqlsnip.rb CHANGED
@@ -23,6 +23,7 @@ module Sqlsnip
23
23
 
24
24
  TABLE_RE = /(?:#{TABLE_MODIFIERS_RE}\s+)*table\s+(?:#{IF_NOT_EXISTS_RE}?\s+)?(#{UID_RE})/i
25
25
  VIEW_RE = /(?:#{VIEW_MODIFIERS_RE}\s+)*view\s+(#{UID_RE})/i
26
+ MATERIALIZED_VIEW_RE = /materialized\s+view\s*(#{UID_RE})/i
26
27
  FUNCTION_RE = /function\s+(#{UID_RE})\s*\((.*?)\)\s+(?:returns|$)/i
27
28
  PROCEDURE_RE = /function\s+(#{UID_RE})\s*\((.*?)\)\s+(?:as|$)/i
28
29
  TRIGGER_RE = /trigger\s+(#{UID_RE})\s+.*\s+on\s+(#{UID_RE})/i
@@ -89,6 +90,9 @@ module Sqlsnip
89
90
  when TABLE_RE
90
91
  table = $1
91
92
  sql = "drop table if exists #{table} cascade;"
93
+ when MATERIALIZED_VIEW_RE
94
+ view = $1
95
+ sql = "drop materialized view if exists #{view} cascade;"
92
96
  when VIEW_RE
93
97
  view = $1
94
98
  sql = "drop view if exists #{view} cascade;"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlsnip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen