real_data_tests 0.3.7 → 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 +16 -0
- data/lib/real_data_tests/rspec_helper.rb +67 -20
- 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,21 @@
|
|
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
|
+
|
11
|
+
## [0.3.8] - 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.7] - 2025-01-14
|
4
20
|
### Fixed
|
5
21
|
- Corrected SQL value handling in native loader
|
@@ -103,36 +103,83 @@ module RealDataTests
|
|
103
103
|
statements
|
104
104
|
end
|
105
105
|
|
106
|
+
def extract_conflict_clause(statement)
|
107
|
+
# Use a more precise regex that handles multiple closing parentheses
|
108
|
+
if statement =~ /(.+?\))\s*(ON\s+CONFLICT\s+.*?)(?:;?\s*$)/i
|
109
|
+
[$1, $2.strip]
|
110
|
+
else
|
111
|
+
[statement.sub(/;?\s*$/, ''), nil]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
106
115
|
def clean_sql_statement(statement)
|
107
|
-
#
|
108
|
-
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
|
109
123
|
|
110
|
-
|
111
|
-
|
112
|
-
# Split into pre-VALUES and VALUES parts
|
113
|
-
parts = statement.split(/VALUES\s*\(/i, 2)
|
114
|
-
if parts.length == 2
|
115
|
-
# Clean and process the values
|
116
|
-
values = clean_values(parts[1].split(/\)\s*$/)[0])
|
124
|
+
# Clean the values content while preserving complex JSON
|
125
|
+
cleaned_values = clean_complex_values(values_content)
|
117
126
|
|
118
127
|
# Reassemble the statement
|
119
|
-
statement = "#{
|
128
|
+
statement = "#{pre_values}#{cleaned_values}#{post_values}"
|
129
|
+
statement += ";" unless statement.end_with?(";")
|
120
130
|
end
|
121
131
|
end
|
122
|
-
|
123
|
-
# Add back the conflict clause if it existed
|
124
|
-
statement += " #{conflict_clause}" if conflict_clause
|
125
|
-
statement += ";"
|
126
|
-
|
127
132
|
statement
|
128
133
|
end
|
129
134
|
|
130
|
-
def
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
141
|
+
|
142
|
+
chars = values_str.chars
|
143
|
+
i = 0
|
144
|
+
while i < chars.length
|
145
|
+
char = chars[i]
|
146
|
+
|
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
|
135
177
|
end
|
178
|
+
|
179
|
+
# Add the last value
|
180
|
+
values << clean_value(current_value.strip) unless current_value.strip.empty?
|
181
|
+
|
182
|
+
values.join(', ')
|
136
183
|
end
|
137
184
|
|
138
185
|
def clean_values(values_str)
|