real_data_tests 0.3.11 → 0.3.12

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: a18a6616a26a2d4c65ad746e42ac560dd883c302c7ef73113a960309132de449
4
- data.tar.gz: fbbe885c19cbffc91eefa9c0f60c56dcdba519d1a5f21458837aa3dadfede2e7
3
+ metadata.gz: e9613e7cdfc987dd88b0726c3cfe9f9bc31cf4877267988c70fe2c52bf96b163
4
+ data.tar.gz: 654f32e804769aca3cc0415b0455d0d4f481b6fc8e01625a3bd52fc43e11ee6d
5
5
  SHA512:
6
- metadata.gz: 41e9ce6c2b3d427d5b04cb671378d44e0d9f5d24556698c86e0b3e3d671df0b7a41b3f30207b2bba9224c7ddc89b869c747195d1deb8c8956f1ee37ab4b0e690
7
- data.tar.gz: c07e898c90af0d265f637c21e95fbc1a88e83c3a5c7233e11b8517443707005cff23ab1c3984142e21a3307e5e7c53e16a3cd55bb5a8124ba3cb281e1e9c7eba
6
+ metadata.gz: 80f42c596ef4fef11a44272c8a94089700428cc414030024410531e74ee6709d55fdff7b0de3b47a733b73aaf5e576cf519c746f9d4af60bfad978feefa5235f
7
+ data.tar.gz: 0656dede260673942b237c12e94566156fdbed104b864c23b2617c69871088af97afaf6d21fcce6772e3e4a25dcc80e24450f189600d863b6b7a4992c1e9d491
@@ -75,32 +75,41 @@ module RealDataTests
75
75
  statements = []
76
76
  current_statement = ''
77
77
  in_string = false
78
- escaped = false
78
+ in_conflict = false
79
+ quote_char = nil
79
80
 
80
81
  sql.each_char do |char|
81
- case char
82
- when '\\'
83
- 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
94
- else
95
- escaped = false
96
- current_statement << 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'
94
+ end
95
+
96
+ current_statement << char
97
+
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
97
103
  end
98
104
  end
99
105
 
100
- # Add the last statement if it doesn't end with a semicolon
106
+ # Add any remaining statement
101
107
  statements << current_statement.strip if current_statement.strip.length > 0
102
108
 
103
- statements
109
+ statements.map do |stmt|
110
+ # Ensure each statement ends with a semicolon
111
+ stmt.end_with?(';') ? stmt : "#{stmt};"
112
+ end
104
113
  end
105
114
 
106
115
  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.11"
4
+ VERSION = "0.3.12"
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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias