Last active
December 15, 2015 02:19
-
-
Save rintaun/5186914 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
DB.transaction do # BEGIN; | |
User.new do |user| | |
user.name = 'rintaun' | |
user.password = 'somebullshit' # I use this for all my passwords. Oh no! Now you know! D: | |
user.save # INSERT; | |
end | |
User.new do |user| | |
user.name = 'rintaun' # this is a unique column, so this whole thing will obviously fail! | |
user.password = 'areallysecurepassword' | |
user.save # INSERT; -- Error | |
end | |
end # ROLLBACK; | |
# SELECT COUNT(*) FROM users; -- 0 |
This file contains hidden or 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
DB.transaction do # BEGIN; | |
User.new do |user| | |
user.name = 'rintaun' | |
user.password = 'somebullshit' # I use this for all my passwords. Oh no! Now you know! D: | |
user.save # INSERT; COMMIT; -- LOLOL | |
end | |
User.new do |user| | |
user.name = 'rintaun' # this is a unique column, so this whole thing will obviously fail! | |
user.password = 'areallysecurepassword' | |
user.save # INSERT; -- Error | |
end | |
end # ROLLBACK; -- No transaction | |
# SELECT COUNT(*) FROM users; -- 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment