real_data_tests 0.3.5 → 0.3.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35d81ac18056a163df010e92d75c5bd36896836d070f8c74041048ab98918cdf
4
- data.tar.gz: 50d5df4a36a88f58b6dbc76494db155bc68b5b9ca1cf8cbd45b22a4bd8cd6166
3
+ metadata.gz: f325960594ac352b4fbaae4adafb38256bde54feed249140838971e61c5fcef1
4
+ data.tar.gz: d977dda68eac4fa8d13c82dc5a00bba7dd3b27e9c876ab5847a3b3b254cc7d4f
5
5
  SHA512:
6
- metadata.gz: fb2bf7729c1b3a0c86a073924b8c50b0a2005885d93acb7bdd419f12db87e858801222235c6a1c437144b53f57b9375ee56e76c467e6b1d4e643a403131153c9
7
- data.tar.gz: ff37ab1ab9d6c2b33efb657905bb682c4d99cd22a7533e8b19db95d9949f11e621f0d750fbb829f8d61c377faa64d008c66bcdd703a072fae349d4d80c369ab2
6
+ metadata.gz: 40c69c54f989318441e697487673f7c019907cddcea3d81fa9b5775964fc2a6a76994b97093465d57f26521813780292f58d28f11ed75638222b458a75e514f8
7
+ data.tar.gz: bce1cd39d64e2501b222135477c7e10d38769ae26b47827c3c76efb8d2651cdffae689ad3c8e2bb9bd0bdd1315e9f2dbfcdd3dd576079589c75d3d7585c2668c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.7] - 2025-01-14
4
+ ### Fixed
5
+ - Corrected SQL value handling in native loader
6
+ - Fixed boolean value handling, particularly at the end of VALUES clauses
7
+ - Improved handling of NULL values and numbers
8
+ - Added proper whitespace cleaning for values
9
+ - Enhanced value type detection for correct quoting
10
+
11
+ ## [0.3.6] - 2025-01-14
12
+ ### Fixed
13
+ - Further enhanced SQL statement handling in native loader
14
+ - Fixed handling of SQL statements with ON CONFLICT clauses
15
+ - Improved quoting for company names containing spaces
16
+ - Added proper handling of trailing semicolons
17
+ - Enhanced detection and preservation of SQL statement structure
18
+
3
19
  ## [0.3.5] - 2025-01-14
4
20
  ### Fixed
5
21
  - Enhanced SQL statement handling in native loader
@@ -104,22 +104,82 @@ module RealDataTests
104
104
  end
105
105
 
106
106
  def clean_sql_statement(statement)
107
+ # Extract the ON CONFLICT clause if it exists
108
+ statement, conflict_clause = extract_conflict_clause(statement)
109
+
107
110
  # Handle VALUES clause formatting
108
111
  if statement.include?('VALUES')
109
112
  # Split into pre-VALUES and VALUES parts
110
113
  parts = statement.split(/VALUES\s*\(/i, 2)
111
114
  if parts.length == 2
112
- # Properly quote UUIDs and strings in the VALUES part
113
- values_part = parts[1]
114
- values_part = values_part.gsub(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?=[,\s)])/i, "'\\1'")
115
- # Quote unquoted string values
116
- values_part = values_part.gsub(/,\s*([^',\s][^,\s]*)(?=[,\s)])/, ", '\\1'")
115
+ # Clean and process the values
116
+ values = clean_values(parts[1].split(/\)\s*$/)[0])
117
+
117
118
  # Reassemble the statement
118
- statement = parts[0] + 'VALUES (' + values_part
119
+ statement = "#{parts[0]}VALUES (#{values})"
119
120
  end
120
121
  end
121
122
 
123
+ # Add back the conflict clause if it existed
124
+ statement += " #{conflict_clause}" if conflict_clause
125
+ statement += ";"
126
+
122
127
  statement
123
128
  end
129
+
130
+ def extract_conflict_clause(statement)
131
+ if statement =~ /(.+?)(\s+ON\s+CONFLICT\s+.*?)(?:;?\s*$)/i
132
+ [$1, $2.strip]
133
+ else
134
+ [statement.sub(/;?\s*$/, ''), nil]
135
+ end
136
+ end
137
+
138
+ def clean_values(values_str)
139
+ values = []
140
+ current_value = ''
141
+ in_quotes = false
142
+ nested_level = 0
143
+
144
+ values_str.chars.each do |char|
145
+ case char
146
+ when "'"
147
+ in_quotes = !in_quotes
148
+ current_value << char
149
+ when '{'
150
+ nested_level += 1
151
+ current_value << char
152
+ when '}'
153
+ nested_level -= 1
154
+ current_value << char
155
+ when ','
156
+ if !in_quotes && nested_level == 0
157
+ values << clean_value(current_value.strip)
158
+ current_value = ''
159
+ else
160
+ current_value << char
161
+ end
162
+ else
163
+ current_value << char
164
+ end
165
+ end
166
+
167
+ values << clean_value(current_value.strip)
168
+ values.join(', ')
169
+ end
170
+
171
+ def clean_value(value)
172
+ return value if value.start_with?("'") # Already quoted
173
+ return value if value.start_with?("'{") # JSON object
174
+ return 'NULL' if value.upcase == 'NULL'
175
+ return value.downcase if ['true', 'false'].include?(value.downcase)
176
+ return value if value.match?(/^\d+$/) # Numbers
177
+
178
+ if value.match?(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
179
+ "'#{value}'" # UUID
180
+ else
181
+ "'#{value}'" # Other strings
182
+ end
183
+ end
124
184
  end
125
185
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.7"
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.5
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias