real_data_tests 0.3.11 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a18a6616a26a2d4c65ad746e42ac560dd883c302c7ef73113a960309132de449
4
- data.tar.gz: fbbe885c19cbffc91eefa9c0f60c56dcdba519d1a5f21458837aa3dadfede2e7
3
+ metadata.gz: e1ff52aca9c674699aa8e7d5cbe17de0db5860b69f0161b2408a1cd239abeadd
4
+ data.tar.gz: f8bdffcbd90e239bbf92cfc4fea32a0025a31d5a80b53e4c92c9db08c3babfa7
5
5
  SHA512:
6
- metadata.gz: 41e9ce6c2b3d427d5b04cb671378d44e0d9f5d24556698c86e0b3e3d671df0b7a41b3f30207b2bba9224c7ddc89b869c747195d1deb8c8956f1ee37ab4b0e690
7
- data.tar.gz: c07e898c90af0d265f637c21e95fbc1a88e83c3a5c7233e11b8517443707005cff23ab1c3984142e21a3307e5e7c53e16a3cd55bb5a8124ba3cb281e1e9c7eba
6
+ metadata.gz: cfbfb177889ae4ff86637eaa345c89a64faa9357cab0d0ec87a444b29d092fa1fc4750316d818c8afb5d679204a808abcfb6c71fdb47da53f0fdce43d2ebb156
7
+ data.tar.gz: 65c58cc33ef5c68579dd04196a6104d62cd97f3f5d764340bdcbeccbaf69c8181c9dfd6e08812e353ecbf0913467b965b86c3718d928d3abfb80a0be766a8b4a
@@ -78,27 +78,37 @@ module RealDataTests
78
78
  escaped = false
79
79
 
80
80
  sql.each_char do |char|
81
- case char
82
- when '\\'
81
+ if char == '\\'
83
82
  escaped = !escaped
84
- when "'"
85
- in_string = !in_string unless escaped
86
- escaped = false
87
- when ';'
88
- if !in_string
89
- statements << current_statement.strip
90
- current_statement = ''
91
- else
92
- current_statement << char
93
- end
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
90
+ end
91
+ escaped = false
92
+ current_statement << char
93
+ end
94
+
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}"
94
102
  else
95
- escaped = false
96
- current_statement << char
103
+ result << stmt.strip
97
104
  end
98
105
  end
99
106
 
100
- # Add the last statement if it doesn't end with a semicolon
101
- statements << current_statement.strip if current_statement.strip.length > 0
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
111
+ end
102
112
 
103
113
  statements
104
114
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.11"
4
+ VERSION = "0.3.13"
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.11
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias