aboutsummaryrefslogtreecommitdiffstats
path: root/ci/travis.rb
diff options
context:
space:
mode:
authorDan Fitch <dgfitch@gmail.com>2019-04-09 12:22:05 -0500
committerDan Fitch <dgfitch@gmail.com>2019-04-09 12:22:05 -0500
commit2e117c8a0b1220137d4a4cee577b4237aedf5c8b (patch)
treeb7e281ccd0ebe075edc38d5a0959d862bc88becd /ci/travis.rb
parentdd58d040b2b798105b95e21396e86266bfd40de9 (diff)
downloadrails-2e117c8a0b1220137d4a4cee577b4237aedf5c8b.tar.gz
rails-2e117c8a0b1220137d4a4cee577b4237aedf5c8b.tar.bz2
rails-2e117c8a0b1220137d4a4cee577b4237aedf5c8b.zip
Clarify exists check in logs
The default log messages for Model.exists?, when called from .save on an object which uses scoped uniqueness validation like: class Example < ApplicationRecord validates :field, uniqueness: {scope: parent_id} end can result in slightly misleading logs. An example case: ↳ app/controllers/example_controller.rb:23 (0.2ms) begin transaction ↳ app/controllers/example_controller.rb:39 Example Exists (0.2ms) SELECT 1 AS one FROM "examples" WHERE "examples"."field" IS NULL AND "examples"."parent_id" = ? LIMIT ? [["parent_id", 123], ["LIMIT", 1]] ↳ app/controllers/example_controller.rb:39 (0.1ms) rollback transaction To me, a Rails newbie, this parsed as the following: - started the transaction to create a thing - found that your object exists already! - so we rolled back the transaction (even though the actual cause of the transaction is something that happens after the Exists check.) All this does is add a question mark to the message, to make it clear in the log that this is a check, not a confirmation. This may be kind of silly, but it may save some future goofs by newbs like me.
Diffstat (limited to 'ci/travis.rb')
0 files changed, 0 insertions, 0 deletions