real_data_tests 0.3.13 → 0.3.14
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 +6 -13
- 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: e7e142b478391e00c15f51378e09dd2b7e1429f8c7d1bdd2bb5d059ae8a968fb
         | 
| 4 | 
            +
              data.tar.gz: a4464de621782aebfa90bac25e90458e4feca5c1007898d3537d44866a937c7b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: '078fcfb22739b26714d756e10afc54ce10a15b947706f1f8eccee31f65384695b770ea546e69a889c033378fff79d314b1b66c4d86b29b3eab2dbb62e6b93231'
         | 
| 7 | 
            +
              data.tar.gz: c02a03e895d13a78e75adcf5c8ff5c6d9ea920d91dbaf463dad5e344bbe890e5877cb42385a65aa1f2df5c57b94cb595c96b78279cb9f1f66616e44e9a50a927
         | 
| @@ -29,26 +29,19 @@ module RealDataTests | |
| 29 29 | 
             
                    connection.execute('SET session_replication_role = replica;')
         | 
| 30 30 |  | 
| 31 31 | 
             
                    begin
         | 
| 32 | 
            -
                      # Read the SQL file content
         | 
| 33 32 | 
             
                      sql_content = File.read(dump_path)
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                      # Split the file into individual statements
         | 
| 36 33 | 
             
                      statements = split_sql_statements(sql_content)
         | 
| 37 34 |  | 
| 38 | 
            -
                       | 
| 39 | 
            -
                      statements.each do |statement|
         | 
| 40 | 
            -
                        next if statement.strip.empty?
         | 
| 35 | 
            +
                      statements.each_with_index do |statement, index|
         | 
| 41 36 | 
             
                        begin
         | 
| 42 | 
            -
                          # Clean up any formatting issues that might cause syntax errors
         | 
| 43 37 | 
             
                          cleaned_statement = clean_sql_statement(statement)
         | 
| 38 | 
            +
                          puts "Executing Statement ##{index + 1}: #{cleaned_statement}" # Debug log
         | 
| 44 39 | 
             
                          connection.execute(cleaned_statement)
         | 
| 45 40 | 
             
                        rescue ActiveRecord::StatementInvalid => e
         | 
| 46 | 
            -
                           | 
| 47 | 
            -
                          raise Error, "Failed to execute SQL statement: #{e.message}\nStatement: #{cleaned_statement}"
         | 
| 41 | 
            +
                          raise Error, "Error executing statement ##{index + 1}: #{e.message}\nSQL: #{cleaned_statement}"
         | 
| 48 42 | 
             
                        end
         | 
| 49 43 | 
             
                      end
         | 
| 50 44 | 
             
                    ensure
         | 
| 51 | 
            -
                      # Re-enable foreign key checks
         | 
| 52 45 | 
             
                      connection.execute('SET session_replication_role = DEFAULT;')
         | 
| 53 46 | 
             
                    end
         | 
| 54 47 | 
             
                  end
         | 
| @@ -95,7 +88,7 @@ module RealDataTests | |
| 95 88 | 
             
                  # Add the last statement if it exists
         | 
| 96 89 | 
             
                  statements << current_statement.strip unless current_statement.strip.empty?
         | 
| 97 90 |  | 
| 98 | 
            -
                  #  | 
| 91 | 
            +
                  # Normalize `ON CONFLICT` clauses
         | 
| 99 92 | 
             
                  statements = statements.each_with_object([]) do |stmt, result|
         | 
| 100 93 | 
             
                    if stmt.strip.upcase.start_with?('ON CONFLICT')
         | 
| 101 94 | 
             
                      result[-1] = "#{result.last.strip} #{stmt.strip}"
         | 
| @@ -104,10 +97,10 @@ module RealDataTests | |
| 104 97 | 
             
                    end
         | 
| 105 98 | 
             
                  end
         | 
| 106 99 |  | 
| 107 | 
            -
                  #  | 
| 100 | 
            +
                  # Ensure semicolons and spacing
         | 
| 108 101 | 
             
                  statements.map! do |stmt|
         | 
| 109 102 | 
             
                    stmt = stmt.gsub(/\)\s*ON CONFLICT/, ') ON CONFLICT') # Normalize spacing
         | 
| 110 | 
            -
                    stmt.strip.end_with?(';') ? stmt.strip : "#{stmt.strip};" | 
| 103 | 
            +
                    stmt.strip.end_with?(';') ? stmt.strip : "#{stmt.strip};"
         | 
| 111 104 | 
             
                  end
         | 
| 112 105 |  | 
| 113 106 | 
             
                  statements
         |