real_data_tests 0.3.12 → 0.3.13
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/lib/real_data_tests/rspec_helper.rb +27 -26
- 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: e1ff52aca9c674699aa8e7d5cbe17de0db5860b69f0161b2408a1cd239abeadd
|
4
|
+
data.tar.gz: f8bdffcbd90e239bbf92cfc4fea32a0025a31d5a80b53e4c92c9db08c3babfa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfbfb177889ae4ff86637eaa345c89a64faa9357cab0d0ec87a444b29d092fa1fc4750316d818c8afb5d679204a808abcfb6c71fdb47da53f0fdce43d2ebb156
|
7
|
+
data.tar.gz: 65c58cc33ef5c68579dd04196a6104d62cd97f3f5d764340bdcbeccbaf69c8181c9dfd6e08812e353ecbf0913467b965b86c3718d928d3abfb80a0be766a8b4a
|
@@ -75,41 +75,42 @@ module RealDataTests
|
|
75
75
|
statements = []
|
76
76
|
current_statement = ''
|
77
77
|
in_string = false
|
78
|
-
|
79
|
-
quote_char = nil
|
78
|
+
escaped = false
|
80
79
|
|
81
80
|
sql.each_char do |char|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# Look ahead to see if this is 'ON CONFLICT'
|
92
|
-
potential_conflict = sql[sql.index(char, sql.rindex(current_statement)), 11]
|
93
|
-
in_conflict = potential_conflict&.upcase == 'ON CONFLICT'
|
81
|
+
if char == '\\'
|
82
|
+
escaped = !escaped
|
83
|
+
elsif char == "'" && !escaped
|
84
|
+
in_string = !in_string
|
85
|
+
elsif char == ';' && !in_string
|
86
|
+
# Add the completed statement
|
87
|
+
statements << current_statement.strip unless current_statement.strip.empty?
|
88
|
+
current_statement = ''
|
89
|
+
next
|
94
90
|
end
|
95
|
-
|
91
|
+
escaped = false
|
96
92
|
current_statement << char
|
93
|
+
end
|
97
94
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
# Add the last statement if it exists
|
96
|
+
statements << current_statement.strip unless current_statement.strip.empty?
|
97
|
+
|
98
|
+
# Ensure `ON CONFLICT` stays with the previous statement
|
99
|
+
statements = statements.each_with_object([]) do |stmt, result|
|
100
|
+
if stmt.strip.upcase.start_with?('ON CONFLICT')
|
101
|
+
result[-1] = "#{result.last.strip} #{stmt.strip}"
|
102
|
+
else
|
103
|
+
result << stmt.strip
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
106
|
-
#
|
107
|
-
statements
|
108
|
-
|
109
|
-
|
110
|
-
# Ensure each statement ends with a semicolon
|
111
|
-
stmt.end_with?(';') ? stmt : "#{stmt};"
|
107
|
+
# Normalize spacing around `ON CONFLICT` and ensure semicolons
|
108
|
+
statements.map! do |stmt|
|
109
|
+
stmt = stmt.gsub(/\)\s*ON CONFLICT/, ') ON CONFLICT') # Normalize spacing
|
110
|
+
stmt.strip.end_with?(';') ? stmt.strip : "#{stmt.strip};" # Ensure semicolon
|
112
111
|
end
|
112
|
+
|
113
|
+
statements
|
113
114
|
end
|
114
115
|
|
115
116
|
def extract_conflict_clause(statement)
|