Skip to content

Instantly share code, notes, and snippets.

@pschyska
Created February 17, 2012 19:21
Show Gist options
  • Save pschyska/1854992 to your computer and use it in GitHub Desktop.
Save pschyska/1854992 to your computer and use it in GitHub Desktop.
1.9.2 (main):0 > book1=Book.first
Book Load (0.5ms) SELECT `books`.* FROM `books` LIMIT 1
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| 4 | 32 | Journey to Ixtlan | 4 | | | | | 2012-02-03 23:22... | 2012-02-03 23:22:... | 2011-12-13 11:12... | 2011-12-13 |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
1 row in set
1.9.2 (main):0 > book2=Book.first
Book Load (0.6ms) SELECT `books`.* FROM `books` LIMIT 1
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| 4 | 32 | Journey to Ixtlan | 4 | | | | | 2012-02-03 23:22... | 2012-02-03 23:22:... | 2011-12-13 11:12... | 2011-12-13 |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
1 row in set
1.9.2 (main):0 > book1.title="changed"
=> "changed"
1.9.2 (main):0 > book1
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| 4 | 32 | changed | 4 | | | | | 2012-02-03 23:22:29... | 2012-02-03 23:22:29 UTC | 2011-12-13 11:12:13 UTC | 2011-12-13 |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
1 row in set
1.9.2 (main):0 > book2
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| 4 | 32 | Journey to Ixtlan | 4 | | | | | 2012-02-03 23:22... | 2012-02-03 23:22:... | 2011-12-13 11:12... | 2011-12-13 |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
1 row in set
1.9.2 (main):0 > book1.save
(0.3ms) BEGIN
(0.4ms) UPDATE `books` SET `title` = 'changed', `updated_at` = '2012-02-17 19:20:37' WHERE `books`.`id` = 4
(2.5ms) COMMIT
=> true
1.9.2 (main):0 > book2
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
| 4 | 32 | Journey to Ixtlan | 4 | | | | | 2012-02-03 23:22... | 2012-02-03 23:22:... | 2011-12-13 11:12... | 2011-12-13 |
+----+-----------+-------------------+-----------+-----------+-------+------+--------+---------------------+----------------------+---------------------+--------------+
1 row in set
1.9.2 (main):0 > b1=nil
=> nil
1.9.2 (main):0 > b2=nil
=> nil
1.9.2 (main):0 > Book.with_identity_map do
1.9.2 (main):0 * b1=Book.first
1.9.2 (main):0 * b2=Book.first
1.9.2 (main):0 * b1.title="changed"
1.9.2 (main):0 * end
(0.000661s) SELECT * FROM `books` LIMIT 1
(0.000282s) SELECT * FROM `books` LIMIT 1
=> "changed"
1.9.2 (main):0 > b1
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| 4 | 32 | changed | 4 | | | | | 2012-02-03 23:22:29... | 2012-02-17 19:20:37 ... | 2011-12-13 11:12:13 ... | 2011-12-13 |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
1 row in set
1.9.2 (main):0 > b2
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| id | author_id | title | exemplars | digitized | notes | tags | rating | created_at | updated_at | last_read_at | published_on |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
| 4 | 32 | changed | 4 | | | | | 2012-02-03 23:22:29... | 2012-02-17 19:20:37 ... | 2011-12-13 11:12:13 ... | 2011-12-13 |
+----+-----------+---------+-----------+-----------+-------+------+--------+------------------------+-------------------------+-------------------------+--------------+
1 row in set
1.9.2 (main):0 > b1==b2
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment