real_data_tests 0.3.8 → 0.3.9

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: 573f1753777e04a6168a09385b8332cedbb4d521d11f1807012a25b8b846013c
4
- data.tar.gz: b884098abbc9134a22479d5e9211a2d8bb153622022ba9116acb0057419cbe4a
3
+ metadata.gz: 3a45102a35d4a4d4bff64e68a4edef1b7e29d8c2ca68c0a957ac2589b8ce3b04
4
+ data.tar.gz: 506f07bccd0524de51819b128a6a707979e68723e513e829e0437a9d7b503b75
5
5
  SHA512:
6
- metadata.gz: 1d4bcb84f7d3ab3ee0901ae46763c912f3c86935930cc17607d500ae7a2e26649f8c6ff629e8215437d8f08ae93d482870e253b294e84e720971c9bf681c7b50
7
- data.tar.gz: 67cad3bda841d3e1de61d61dd30121ef3b6ddfc96a3162438a2b25f904185e6e4c59206d2626e6b40d44a72d123ed123e4073a4fdfe10d04fea807a8702bf689
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
- # Extract the ON CONFLICT clause if it exists
117
- statement, conflict_clause = extract_conflict_clause(statement)
118
-
119
- # Handle VALUES clause formatting
120
- if statement.include?('VALUES')
121
- # Split into pre-VALUES and VALUES parts
122
- parts = statement.split(/VALUES\s*\(/i, 2)
123
- if parts.length == 2
124
- # Clean and process the values
125
- values = clean_values(parts[1].split(/\)\s*$/)[0])
126
-
127
- # Make sure we properly close the VALUES parentheses
128
- statement = "#{parts[0]}VALUES (#{values})"
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
- # Add back the conflict clause if it existed
133
- statement = "#{statement}#{conflict_clause ? ' ' + conflict_clause : ''}"
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
- # Ensure the statement ends with a semicolon
136
- statement += ";" unless statement.end_with?(';')
142
+ chars = values_str.chars
143
+ i = 0
144
+ while i < chars.length
145
+ char = chars[i]
137
146
 
138
- statement
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.8"
4
+ VERSION = "0.3.9"
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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias