Skip to content

Instantly share code, notes, and snippets.

@tcopeland
Created December 13, 2017 20:41
Show Gist options
  • Save tcopeland/d08d09d1f876d321ecf22743ecc78874 to your computer and use it in GitHub Desktop.
Save tcopeland/d08d09d1f876d321ecf22743ecc78874 to your computer and use it in GitHub Desktop.
>> Book.select(:author, :isbn).first
Book Load (0.4ms) SELECT "books"."author", "books"."isbn" FROM "books" ORDER BY "books"."id" ASC LIMIT $1 [["LIMIT", 1]]
=> #<Book id: nil, isbn: "0787967076", author: "Steven B. Sample">
>> Book.select(:id, :author, :isbn).first
Book Load (0.3ms) SELECT "books"."id", "books"."author", "books"."isbn" FROM "books" ORDER BY "books"."id" ASC LIMIT $1 [["LIMIT", 1]]
=> #<Book id: 5, isbn: "0787967076", author: "Steven B. Sample">
>> Book.find(5).update(isbn: nil, author: "heyo")
Book Load (0.5ms) SELECT "books".* FROM "books" WHERE "books"."id" = $1 LIMIT $2 [["id", 5], ["LIMIT", 1]]
(0.1ms) BEGIN
SQL (19.7ms) UPDATE "books" SET "isbn" = $1, "author" = $2, "escaped_author" = $3, "updated_at" = $4 WHERE "books"."id" = $5 [["isbn", nil], ["author", "heyo"], ["escaped_author", "heyo"], ["updated_at", 2017-12-13 20:40:57 UTC], ["id", 5]]
(0.6ms) COMMIT
=> true
>> Book.select(:id, :author, :isbn).first
Book Load (0.4ms) SELECT "books"."id", "books"."author", "books"."isbn" FROM "books" ORDER BY "books"."id" ASC LIMIT $1 [["LIMIT", 1]]
=> #<Book id: 5, isbn: nil, author: "heyo">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment