Skip to content

Instantly share code, notes, and snippets.

@pathsny
Created April 29, 2010 11:17
Show Gist options
  • Save pathsny/383457 to your computer and use it in GitHub Desktop.
Save pathsny/383457 to your computer and use it in GitHub Desktop.
class Foo
include DataMapper::Resource
property :id, Serial
property :foo, Integer, :unique => true
property :desc, String
end
Foo.auto_migrate!
Foo.create(:desc => "first", :foo => 1)
f = Foo.first
# SELECT "id", "foo", "desc" FROM "foos" ORDER BY "id" LIMIT 1
f.desc = "second"
f.save
# SELECT "id" FROM "foos" WHERE "foo" = 1 ORDER BY "id" LIMIT 1 <--- unnecessary check
# UPDATE "foos" SET "desc" = 'lol' WHERE "id" = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment