real_data_tests 0.3.9 → 0.3.10

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: 3a45102a35d4a4d4bff64e68a4edef1b7e29d8c2ca68c0a957ac2589b8ce3b04
4
- data.tar.gz: 506f07bccd0524de51819b128a6a707979e68723e513e829e0437a9d7b503b75
3
+ metadata.gz: f76c93165cf56a1bb2e90311afc6bf92f42f17553271a977dec2e17f39afc67f
4
+ data.tar.gz: f1caa35f8eaa904dba0b608484d43d8beffaa7208646e067f046b8add97db10d
5
5
  SHA512:
6
- metadata.gz: e33a481a786ef940d50eabf13b23ddc8175af68ec16892f685809a7acec88a27786f4b54e6588a890167c90a058d690acc7d1ba7d264e0802549590516d499aa
7
- data.tar.gz: 45dcce0d68ce3011521aea9ffcefc7d355af5544c0cc8cc385b37b897e953cd51d9af928536c8c901f7ff35ba33a52df9886ac186b5182aecc0821c83d6ceb91
6
+ metadata.gz: 1097a749d0dd8ad287130dbab5a75c0f526de6689e9877d4f218657d6c03ad49ccd8c0c3cd02697306d1fee41c11c0915f11e4c264e2254cb21013e266d130aa
7
+ data.tar.gz: c0b6f6c9f84558801e5140eea8da6c5f068ad5adbe4dd3ba520e87fe2ef2259921374d52713e8e3a52775b64bb439f426be72a698d83e5a0144b16a6282cfc14
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.10] - 2025-01-14
4
+ ### Fixed
5
+ - Enhanced SQL statement parsing in native loader
6
+ - Improved handling of complex ON CONFLICT clauses with multiple closing parentheses
7
+ - Fixed spacing issues between VALUES and ON CONFLICT clauses
8
+ - Enhanced regex pattern for more precise conflict clause extraction
9
+ - Added proper statement reassembly for complex SQL structures
10
+
3
11
  ## [0.3.9] - 2025-01-14
4
12
  ### Fixed
5
13
  - Enhanced SQL statement parsing in native loader
@@ -113,10 +113,10 @@ module RealDataTests
113
113
  end
114
114
 
115
115
  def clean_sql_statement(statement)
116
- # First, detect if this is an INSERT statement with VALUES
117
- if statement =~ /INSERT INTO.*VALUES\s*\(/i
118
- # Split the statement into three parts: pre-VALUES, values, and post-VALUES (ON CONFLICT clause)
119
- if statement =~ /(.*VALUES\s*\()(.*)(\)\s*(?:ON CONFLICT.*)?;?\s*$)/i
116
+ # Match either INSERT INTO...VALUES or just VALUES
117
+ if statement =~ /(?:INSERT INTO.*)?VALUES\s*\(/i
118
+ # Split the statement into parts, being careful with the ending
119
+ if statement =~ /(.*?VALUES\s*\()(.*)(\)\s*(?:ON CONFLICT.*)?;?\s*$)/i
120
120
  pre_values = $1
121
121
  values_content = $2
122
122
  post_values = $3
@@ -124,9 +124,10 @@ module RealDataTests
124
124
  # Clean the values content while preserving complex JSON
125
125
  cleaned_values = clean_complex_values(values_content)
126
126
 
127
- # Reassemble the statement
127
+ # Reassemble the statement, ensuring exactly one semicolon at the end
128
128
  statement = "#{pre_values}#{cleaned_values}#{post_values}"
129
- statement += ";" unless statement.end_with?(";")
129
+ statement = statement.gsub(/;*\s*$/, '') # Remove any trailing semicolons and whitespace
130
+ statement += ";"
130
131
  end
131
132
  end
132
133
  statement
@@ -138,6 +139,7 @@ module RealDataTests
138
139
  in_quotes = false
139
140
  in_json = false
140
141
  json_brace_count = 0
142
+ escaped = false
141
143
 
142
144
  chars = values_str.chars
143
145
  i = 0
@@ -145,11 +147,14 @@ module RealDataTests
145
147
  char = chars[i]
146
148
 
147
149
  case char
150
+ when '\\'
151
+ current_value << char
152
+ escaped = !escaped
148
153
  when "'"
149
- # Check if this is an escaped quote
150
- if i > 0 && chars[i-1] != '\\'
154
+ if !escaped
151
155
  in_quotes = !in_quotes
152
156
  end
157
+ escaped = false
153
158
  current_value << char
154
159
  when '{'
155
160
  if !in_quotes
@@ -171,6 +176,7 @@ module RealDataTests
171
176
  current_value << char
172
177
  end
173
178
  else
179
+ escaped = false
174
180
  current_value << char
175
181
  end
176
182
  i += 1
@@ -182,6 +188,21 @@ module RealDataTests
182
188
  values.join(', ')
183
189
  end
184
190
 
191
+ def clean_value(value)
192
+ return value if value.start_with?("'") # Already quoted
193
+ return value if value.start_with?("'{") # JSON object
194
+ return 'NULL' if value.upcase == 'NULL'
195
+ return value.downcase if ['true', 'false'].include?(value.downcase)
196
+ return value if value.match?(/^\d+$/) # Numbers
197
+
198
+ if value.match?(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
199
+ "'#{value}'" # UUID
200
+ else
201
+ # Handle any other string value, including those with commas
202
+ "'#{value}'" # Other strings
203
+ end
204
+ end
205
+
185
206
  def clean_values(values_str)
186
207
  values = []
187
208
  current_value = ''
@@ -214,19 +235,5 @@ module RealDataTests
214
235
  values << clean_value(current_value.strip)
215
236
  values.join(', ')
216
237
  end
217
-
218
- def clean_value(value)
219
- return value if value.start_with?("'") # Already quoted
220
- return value if value.start_with?("'{") # JSON object
221
- return 'NULL' if value.upcase == 'NULL'
222
- return value.downcase if ['true', 'false'].include?(value.downcase)
223
- return value if value.match?(/^\d+$/) # Numbers
224
-
225
- if value.match?(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
226
- "'#{value}'" # UUID
227
- else
228
- "'#{value}'" # Other strings
229
- end
230
- end
231
238
  end
232
239
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.9"
4
+ VERSION = "0.3.10"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: real_data_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias