Skip to content

Instantly share code, notes, and snippets.

@Fryguy
Created December 5, 2014 21:33
Show Gist options
  • Save Fryguy/2d13e9fafc4a89862d68 to your computer and use it in GitHub Desktop.
Save Fryguy/2d13e9fafc4a89862d68 to your computer and use it in GitHub Desktop.
Unnecessary BEGIN/COMMIT happens when model save is a no-op
Loading development environment (Rails 4.1.8)
irb(main):001:0> u = User.first
User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> #<User id: 1, name: "Fryguy", created_at: "2014-12-05 21:18:18", updated_at: "2014-12-05 21:18:18">
irb(main):002:0> u.save!
(0.2ms) begin transaction
(0.1ms) commit transaction
=> true
irb(main):003:0> u.name = "Fryguy"
=> "Fryguy"
irb(main):004:0> u.save!
(0.1ms) begin transaction
(0.1ms) commit transaction
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment