real_data_tests 0.3.9 → 0.3.10
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/real_data_tests/rspec_helper.rb +29 -22
- data/lib/real_data_tests/version.rb +1 -1
- 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: f76c93165cf56a1bb2e90311afc6bf92f42f17553271a977dec2e17f39afc67f
|
4
|
+
data.tar.gz: f1caa35f8eaa904dba0b608484d43d8beffaa7208646e067f046b8add97db10d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
117
|
-
if statement =~ /INSERT INTO.*VALUES\s*\(/i
|
118
|
-
# Split the statement into
|
119
|
-
if statement =~ /(
|
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
|
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
|
-
|
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
|