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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9613e7cdfc987dd88b0726c3cfe9f9bc31cf4877267988c70fe2c52bf96b163
4
- data.tar.gz: 654f32e804769aca3cc0415b0455d0d4f481b6fc8e01625a3bd52fc43e11ee6d
3
+ metadata.gz: e1ff52aca9c674699aa8e7d5cbe17de0db5860b69f0161b2408a1cd239abeadd
4
+ data.tar.gz: f8bdffcbd90e239bbf92cfc4fea32a0025a31d5a80b53e4c92c9db08c3babfa7
5
5
  SHA512:
6
- metadata.gz: 80f42c596ef4fef11a44272c8a94089700428cc414030024410531e74ee6709d55fdff7b0de3b47a733b73aaf5e576cf519c746f9d4af60bfad978feefa5235f
7
- data.tar.gz: 0656dede260673942b237c12e94566156fdbed104b864c23b2617c69871088af97afaf6d21fcce6772e3e4a25dcc80e24450f189600d863b6b7a4992c1e9d491
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
- in_conflict = false
79
- quote_char = nil
78
+ escaped = false
80
79
 
81
80
  sql.each_char do |char|
82
- # Detect start of quoted strings
83
- if (char == "'" || char == '"') && !in_string
84
- in_string = true
85
- quote_char = char
86
- # Detect end of quoted strings (matching quote type)
87
- elsif (char == "'" || char == '"') && in_string && char == quote_char
88
- in_string = false
89
- # Track if we're in an ON CONFLICT clause
90
- elsif char == 'O' && !in_string && current_statement.strip.end_with?(')')
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
- # Only split on semicolon if we're not in a string and not in an ON CONFLICT clause
99
- if char == ';' && !in_string && !in_conflict
100
- statements << current_statement.strip
101
- current_statement = ''
102
- in_conflict = false
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
- # Add any remaining statement
107
- statements << current_statement.strip if current_statement.strip.length > 0
108
-
109
- statements.map do |stmt|
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.12"
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.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias