Sitelet https://github.com/jamis/bulk_insert/pull/60
Skip to content

Worker options ignore: false and update_duplicates: false cause an error when using postgresql_adapter. - #60

Merged
mberlanda merged 1 commit into
jamis:masterfrom
nlpgo:master
May 25, 2020
Merged

mberlanda merged 1 commit into
jamis:masterfrom
nlpgo:master

Conversation

@torce

@torce torce commented May 20, 2020 •

Copy link
Copy Markdown
Contributor

PostgreSQLAdapter#on_conflict_statement returns nil when both options are false, causing an error when this nil is appended to the SQL string.

Test included in the commit. Standalone script to reproduce the problem:

require 'active_record'
require 'bulk_insert'

ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(
  adapter: 'postgresql',
  database: 'problem',
)
unless ActiveRecord::Base.connection.table_exists?(:tests)
  ActiveRecord::Base.connection.create_table :tests do |t|
    t.text :body
  end
end

class Test < ActiveRecord::Base
end

Test.bulk_insert do |worker|
  %w[a b c d e].each do |body|
    worker.add(body: body)
  end
end

@mberlanda mberlanda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very good! Thank you for the PR.

I will release a minor version by the end of this week! Sounds good to you?

@mberlanda
mberlanda merged commit 8dd3eb7 into jamis:master May 25, 2020
@torce

torce commented May 25, 2020

Copy link
Copy Markdown
Contributor Author

It sounds wonderful. 😄

@mberlanda

Copy link
Copy Markdown
Collaborator

@torce I just released you contribution in v1.8.1! Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants