Sha256: 6b3c9947975f3aca343fae277899c65321fa4e718e549fc549131454e2737627

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

require 'upsert/merge_function/postgresql'

class Upsert
  class MergeFunction
    # @private
    class Java_OrgPostgresqlJdbc4_Jdbc4Connection < MergeFunction
      include Postgresql

      def execute(row)
        first_try = true
        bind_selector_values = row.selector.values.map { |v| connection.bind_value v }
        bind_setter_values = row.setter.values.map { |v| connection.bind_value v }
        begin
          connection.execute sql, (bind_selector_values + bind_setter_values)
        rescue org.postgresql.util.PSQLException => pg_error
          if pg_error.message =~ /function #{name}.* does not exist/i
            if first_try
              Upsert.logger.info %{[upsert] Function #{name.inspect} went missing, trying to recreate}
              first_try = false
              create!
              retry
            else
              Upsert.logger.info %{[upsert] Failed to create function #{name.inspect} for some reason}
              raise pg_error
            end
          else
            raise pg_error
          end
        end
      end


    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
upsert-1.2.0 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.7 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.6 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.5 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.4 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.3 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.1 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb
upsert-1.1.0 lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb