tsql_parser 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee8b4d7afa83f298c53d2f34be1012948466a1dc17dfb022bc59a723e7558c84
4
- data.tar.gz: 29154ff1736be248f22c84a3e985699b1b3c1eadca44295634a9c27dba4cd848
3
+ metadata.gz: 75691620d6ff57a073073f7438189fb9858a74f06737872ac0d38994fd9293ba
4
+ data.tar.gz: a5f2bdf884135c00ca792a0f6e8b321d5959295836072c5a9a182f641eced85e
5
5
  SHA512:
6
- metadata.gz: 01de8daed01b64881f3f112dc2233ea2a3fe27ffddd3e95940ed353425b36a2b2ae5631661cd81faab998494992149be1bc20d1adbd6939305350e2e8e9ab03e
7
- data.tar.gz: f3212645945c40035938a96664e3f6df3044716750e12874f0cf4d40424729cea5054d42bbeb3335be7b914b7a5fbd14fb29c158163a39344b0f956dfd09c6b4
6
+ metadata.gz: '058f424ea22ebcf1e84ce1dcd0dacec6360210ab145ef71946a30bd989b71463b373526aebe01ba1a0d0e42c3701c2ad42f1e14f8a993fe93ff68cecf4708745'
7
+ data.tar.gz: 1a405f6ae5c149dd653179979fa17f9db0fd64804e5ef60f6bfbc4d1e4521f526796aee807714619e1547019bc8aeebd3b248d05aaf7469d2f2d0e659f770610
@@ -18,12 +18,16 @@ module TSqlParser::Parsing
18
18
  class FlatSqlContainer
19
19
  def initialize(token = nil)
20
20
  @token = token
21
- @children = []
22
21
  @siblings = []
23
22
 
24
23
  unless token.nil?
25
24
  if token.has_nodes?
26
25
  token.get_nodes.each do |n|
26
+ if n.get_token[:comment]
27
+ comment_token = n.get_token
28
+ comment_token[:value] = "#{comment_token[:value]}\n"
29
+ n.set_token comment_token
30
+ end
27
31
  @siblings << n
28
32
  end
29
33
  end
@@ -46,26 +50,14 @@ module TSqlParser::Parsing
46
50
  @siblings << token
47
51
  end
48
52
 
49
- def add_child(token)
50
- @children << SqlContainer.new(token)
51
- end
52
-
53
53
  def has_siblings?
54
54
  @siblings.size > 0
55
55
  end
56
56
 
57
- def has_children?
58
- @children.size > 0
59
- end
60
-
61
57
  def get_siblings
62
58
  @siblings
63
59
  end
64
60
 
65
- def get_children
66
- @children
67
- end
68
-
69
61
  def get_token
70
62
  @token.get_token
71
63
  end
@@ -195,7 +195,11 @@ module TSqlParser::Parsing
195
195
  formatted << "\n#{tab * (tab_count + 1)}#{table}"
196
196
  formatted << "#{tab * (tab_count + 2)}(#{columns})"
197
197
  formatted << "#{tab * (tab_count + 1)}VALUES"
198
- formatted << "#{tab * (tab_count + 2)}(#{values})"
198
+ if s.end_with? ");"
199
+ formatted << "#{tab * (tab_count + 2)}(#{values}"
200
+ else
201
+ formatted << "#{tab * (tab_count + 2)}(#{values})"
202
+ end
199
203
  end
200
204
  formatted.join("\n") unless formatted.empty?
201
205
  end
@@ -102,6 +102,17 @@ module TSqlParser::Parsing
102
102
  next
103
103
  end
104
104
 
105
+ if comment and c != "\n"
106
+ builder << c
107
+ next
108
+ elsif comment and c == "\n"
109
+ puts "comment builder: #{builder}"
110
+ specific_tokens << builder unless builder.empty?
111
+ builder = ""
112
+ comment = false
113
+ next
114
+ end
115
+
105
116
  if c == "'" and not multiline_comment and not comment
106
117
  if not string
107
118
  string = true
@@ -125,17 +136,7 @@ module TSqlParser::Parsing
125
136
  next
126
137
  end
127
138
 
128
- if comment and c != "\n"
129
- builder << c
130
- next
131
- elsif comment and c == "\n"
132
- specific_tokens << builder unless builder.empty?
133
- builder = ""
134
- comment = false
135
- next
136
- end
137
-
138
- if delimiters.include? c and !multiline_comment and !string
139
+ if delimiters.include? c and !multiline_comment and !string and !comment
139
140
  specific_tokens << builder unless builder.empty?
140
141
  specific_tokens << c unless skip_delimiters.include? c
141
142
  builder = ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsql_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Stauffer