real_data_tests 0.3.10 → 0.3.11
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 +32 -28
- 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: a18a6616a26a2d4c65ad746e42ac560dd883c302c7ef73113a960309132de449
|
4
|
+
data.tar.gz: fbbe885c19cbffc91eefa9c0f60c56dcdba519d1a5f21458837aa3dadfede2e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e9ce6c2b3d427d5b04cb671378d44e0d9f5d24556698c86e0b3e3d671df0b7a41b3f30207b2bba9224c7ddc89b869c747195d1deb8c8956f1ee37ab4b0e690
|
7
|
+
data.tar.gz: c07e898c90af0d265f637c21e95fbc1a88e83c3a5c7233e11b8517443707005cff23ab1c3984142e21a3307e5e7c53e16a3cd55bb5a8124ba3cb281e1e9c7eba
|
@@ -17,7 +17,7 @@ module RealDataTests
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
#
|
20
|
+
# Native Ruby implementation
|
21
21
|
def load_real_test_data_native(name)
|
22
22
|
dump_path = File.join(RealDataTests.configuration.dump_path, "#{name}.sql")
|
23
23
|
raise Error, "Test data file not found: #{dump_path}" unless File.exist?(dump_path)
|
@@ -202,38 +202,42 @@ module RealDataTests
|
|
202
202
|
"'#{value}'" # Other strings
|
203
203
|
end
|
204
204
|
end
|
205
|
+
end
|
205
206
|
|
206
|
-
|
207
|
-
|
208
|
-
current_value = ''
|
209
|
-
in_quotes = false
|
210
|
-
nested_level = 0
|
207
|
+
def import
|
208
|
+
@logger.info "Starting SQL import..."
|
211
209
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
210
|
+
ActiveRecord::Base.transaction do
|
211
|
+
begin
|
212
|
+
# Disable foreign key checks and triggers temporarily
|
213
|
+
ActiveRecord::Base.connection.execute('SET session_replication_role = replica;')
|
214
|
+
|
215
|
+
# Split the SQL content into individual statements
|
216
|
+
statements = split_sql_statements(@sql_content)
|
217
|
+
|
218
|
+
statements.each_with_index do |statement, index|
|
219
|
+
next if statement.strip.empty?
|
220
|
+
|
221
|
+
begin
|
222
|
+
@logger.info "Executing statement #{index + 1} of #{statements.length}"
|
223
|
+
cleaned_statement = clean_sql_statement(statement)
|
224
|
+
ActiveRecord::Base.connection.execute(cleaned_statement)
|
225
|
+
rescue ActiveRecord::StatementInvalid => e
|
226
|
+
@logger.error "Error executing statement #{index + 1}: #{e.message}"
|
227
|
+
@logger.error "Statement: #{cleaned_statement[0..100]}..."
|
228
|
+
raise
|
229
229
|
end
|
230
|
-
else
|
231
|
-
current_value << char
|
232
230
|
end
|
233
|
-
end
|
234
231
|
|
235
|
-
|
236
|
-
|
232
|
+
@logger.info "Successfully imported all SQL statements"
|
233
|
+
rescue StandardError => e
|
234
|
+
@logger.error "Error during import: #{e.message}"
|
235
|
+
@logger.error e.backtrace.join("\n")
|
236
|
+
raise
|
237
|
+
ensure
|
238
|
+
# Re-enable foreign key checks and triggers
|
239
|
+
ActiveRecord::Base.connection.execute('SET session_replication_role = DEFAULT;')
|
240
|
+
end
|
237
241
|
end
|
238
242
|
end
|
239
243
|
end
|