Created
May 31, 2017 01:14
-
-
Save madlep/274fce37e0e8acd683c2b1d3e92b9edc to your computer and use it in GitHub Desktop.
#insert_conflict with empty update hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sequel" | |
DB = Sequel.postgres("sequel_test") | |
DB.create_table? :items do | |
primary_key :id | |
String :name | |
Float :price | |
end | |
update_payload = {} # imagine logic here that might result in empty hash | |
DB[:items] | |
.insert_conflict(target: :id, update: update_payload) | |
.insert(id: 1, name: "my item", price: 123.45) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:195:in `async_exec': PG::SyntaxError: ERROR: syntax error at or near "RETURNING" (Sequel::DatabaseError) | |
LINE 1: ... item', 123.45) ON CONFLICT ("id") DO UPDATE SET RETURNING ... | |
^ | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:195:in `block in execute_query' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/database/logging.rb:45:in `log_connection_yield' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:195:in `execute_query' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:182:in `block in execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:158:in `check_disconnect_errors' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:182:in `execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:535:in `_execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:351:in `block (2 levels) in execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:557:in `check_database_errors' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:351:in `block in execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/database/connecting.rb:301:in `block in synchronize' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/connection_pool/threaded.rb:107:in `hold' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/database/connecting.rb:301:in `synchronize' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:351:in `execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/dataset/actions.rb:1073:in `execute' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/postgres.rb:693:in `fetch_rows' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/dataset/actions.rb:1176:in `returning_fetch_rows' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/dataset/actions.rb:399:in `insert' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/shared/postgres.rb:1437:in `insert' | |
from /Users/madlep/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sequel-4.46.0/lib/sequel/adapters/shared/postgres.rb:1446:in `insert' | |
from insert_conflict_test.rb:15:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment