real_data_tests 0.3.8 → 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 +16 -0
- data/lib/real_data_tests/rspec_helper.rb +80 -29
- 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,21 @@
|
|
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
|
+
|
11
|
+
## [0.3.9] - 2025-01-14
|
12
|
+
### Fixed
|
13
|
+
- Enhanced SQL statement parsing in native loader
|
14
|
+
- Improved handling of complex ON CONFLICT clauses with multiple closing parentheses
|
15
|
+
- Fixed spacing issues between VALUES and ON CONFLICT clauses
|
16
|
+
- Enhanced regex pattern for more precise conflict clause extraction
|
17
|
+
- Added proper statement reassembly for complex SQL structures
|
18
|
+
|
3
19
|
## [0.3.8] - 2025-01-14
|
4
20
|
### Fixed
|
5
21
|
- Enhanced SQL statement parsing in native loader
|
@@ -113,61 +113,78 @@ module RealDataTests
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def clean_sql_statement(statement)
|
116
|
-
#
|
117
|
-
statement
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
# Clean
|
125
|
-
|
126
|
-
|
127
|
-
#
|
128
|
-
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
|
+
pre_values = $1
|
121
|
+
values_content = $2
|
122
|
+
post_values = $3
|
123
|
+
|
124
|
+
# Clean the values content while preserving complex JSON
|
125
|
+
cleaned_values = clean_complex_values(values_content)
|
126
|
+
|
127
|
+
# Reassemble the statement, ensuring exactly one semicolon at the end
|
128
|
+
statement = "#{pre_values}#{cleaned_values}#{post_values}"
|
129
|
+
statement = statement.gsub(/;*\s*$/, '') # Remove any trailing semicolons and whitespace
|
130
|
+
statement += ";"
|
129
131
|
end
|
130
132
|
end
|
131
|
-
|
132
|
-
# Add back the conflict clause if it existed
|
133
|
-
statement = "#{statement}#{conflict_clause ? ' ' + conflict_clause : ''}"
|
134
|
-
|
135
|
-
# Ensure the statement ends with a semicolon
|
136
|
-
statement += ";" unless statement.end_with?(';')
|
137
|
-
|
138
133
|
statement
|
139
134
|
end
|
140
135
|
|
141
|
-
def
|
142
|
-
values = []
|
136
|
+
def clean_complex_values(values_str)
|
143
137
|
current_value = ''
|
138
|
+
values = []
|
144
139
|
in_quotes = false
|
145
|
-
|
140
|
+
in_json = false
|
141
|
+
json_brace_count = 0
|
142
|
+
escaped = false
|
143
|
+
|
144
|
+
chars = values_str.chars
|
145
|
+
i = 0
|
146
|
+
while i < chars.length
|
147
|
+
char = chars[i]
|
146
148
|
|
147
|
-
values_str.chars.each do |char|
|
148
149
|
case char
|
150
|
+
when '\\'
|
151
|
+
current_value << char
|
152
|
+
escaped = !escaped
|
149
153
|
when "'"
|
150
|
-
|
154
|
+
if !escaped
|
155
|
+
in_quotes = !in_quotes
|
156
|
+
end
|
157
|
+
escaped = false
|
151
158
|
current_value << char
|
152
159
|
when '{'
|
153
|
-
|
160
|
+
if !in_quotes
|
161
|
+
in_json = true
|
162
|
+
json_brace_count += 1
|
163
|
+
end
|
154
164
|
current_value << char
|
155
165
|
when '}'
|
156
|
-
|
166
|
+
if !in_quotes
|
167
|
+
json_brace_count -= 1
|
168
|
+
in_json = json_brace_count > 0
|
169
|
+
end
|
157
170
|
current_value << char
|
158
171
|
when ','
|
159
|
-
if !in_quotes &&
|
172
|
+
if !in_quotes && !in_json
|
160
173
|
values << clean_value(current_value.strip)
|
161
174
|
current_value = ''
|
162
175
|
else
|
163
176
|
current_value << char
|
164
177
|
end
|
165
178
|
else
|
179
|
+
escaped = false
|
166
180
|
current_value << char
|
167
181
|
end
|
182
|
+
i += 1
|
168
183
|
end
|
169
184
|
|
170
|
-
|
185
|
+
# Add the last value
|
186
|
+
values << clean_value(current_value.strip) unless current_value.strip.empty?
|
187
|
+
|
171
188
|
values.join(', ')
|
172
189
|
end
|
173
190
|
|
@@ -181,8 +198,42 @@ module RealDataTests
|
|
181
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)
|
182
199
|
"'#{value}'" # UUID
|
183
200
|
else
|
201
|
+
# Handle any other string value, including those with commas
|
184
202
|
"'#{value}'" # Other strings
|
185
203
|
end
|
186
204
|
end
|
205
|
+
|
206
|
+
def clean_values(values_str)
|
207
|
+
values = []
|
208
|
+
current_value = ''
|
209
|
+
in_quotes = false
|
210
|
+
nested_level = 0
|
211
|
+
|
212
|
+
values_str.chars.each do |char|
|
213
|
+
case char
|
214
|
+
when "'"
|
215
|
+
in_quotes = !in_quotes
|
216
|
+
current_value << char
|
217
|
+
when '{'
|
218
|
+
nested_level += 1
|
219
|
+
current_value << char
|
220
|
+
when '}'
|
221
|
+
nested_level -= 1
|
222
|
+
current_value << char
|
223
|
+
when ','
|
224
|
+
if !in_quotes && nested_level == 0
|
225
|
+
values << clean_value(current_value.strip)
|
226
|
+
current_value = ''
|
227
|
+
else
|
228
|
+
current_value << char
|
229
|
+
end
|
230
|
+
else
|
231
|
+
current_value << char
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
values << clean_value(current_value.strip)
|
236
|
+
values.join(', ')
|
237
|
+
end
|
187
238
|
end
|
188
239
|
end
|