real_data_tests 0.3.8 → 0.3.9
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 +62 -18
- 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: 3a45102a35d4a4d4bff64e68a4edef1b7e29d8c2ca68c0a957ac2589b8ce3b04
|
4
|
+
data.tar.gz: 506f07bccd0524de51819b128a6a707979e68723e513e829e0437a9d7b503b75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e33a481a786ef940d50eabf13b23ddc8175af68ec16892f685809a7acec88a27786f4b54e6588a890167c90a058d690acc7d1ba7d264e0802549590516d499aa
|
7
|
+
data.tar.gz: 45dcce0d68ce3011521aea9ffcefc7d355af5544c0cc8cc385b37b897e953cd51d9af928536c8c901f7ff35ba33a52df9886ac186b5182aecc0821c83d6ceb91
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.9] - 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.8] - 2025-01-14
|
4
12
|
### Fixed
|
5
13
|
- Enhanced SQL statement parsing in native loader
|
@@ -113,29 +113,73 @@ 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
|
+
# 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
|
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
|
128
|
+
statement = "#{pre_values}#{cleaned_values}#{post_values}"
|
129
|
+
statement += ";" unless statement.end_with?(";")
|
129
130
|
end
|
130
131
|
end
|
132
|
+
statement
|
133
|
+
end
|
131
134
|
|
132
|
-
|
133
|
-
|
135
|
+
def clean_complex_values(values_str)
|
136
|
+
current_value = ''
|
137
|
+
values = []
|
138
|
+
in_quotes = false
|
139
|
+
in_json = false
|
140
|
+
json_brace_count = 0
|
134
141
|
|
135
|
-
|
136
|
-
|
142
|
+
chars = values_str.chars
|
143
|
+
i = 0
|
144
|
+
while i < chars.length
|
145
|
+
char = chars[i]
|
137
146
|
|
138
|
-
|
147
|
+
case char
|
148
|
+
when "'"
|
149
|
+
# Check if this is an escaped quote
|
150
|
+
if i > 0 && chars[i-1] != '\\'
|
151
|
+
in_quotes = !in_quotes
|
152
|
+
end
|
153
|
+
current_value << char
|
154
|
+
when '{'
|
155
|
+
if !in_quotes
|
156
|
+
in_json = true
|
157
|
+
json_brace_count += 1
|
158
|
+
end
|
159
|
+
current_value << char
|
160
|
+
when '}'
|
161
|
+
if !in_quotes
|
162
|
+
json_brace_count -= 1
|
163
|
+
in_json = json_brace_count > 0
|
164
|
+
end
|
165
|
+
current_value << char
|
166
|
+
when ','
|
167
|
+
if !in_quotes && !in_json
|
168
|
+
values << clean_value(current_value.strip)
|
169
|
+
current_value = ''
|
170
|
+
else
|
171
|
+
current_value << char
|
172
|
+
end
|
173
|
+
else
|
174
|
+
current_value << char
|
175
|
+
end
|
176
|
+
i += 1
|
177
|
+
end
|
178
|
+
|
179
|
+
# Add the last value
|
180
|
+
values << clean_value(current_value.strip) unless current_value.strip.empty?
|
181
|
+
|
182
|
+
values.join(', ')
|
139
183
|
end
|
140
184
|
|
141
185
|
def clean_values(values_str)
|