很少Rails 5 update_attributes没有在Postgres的SQL中运行UPDATE

时间:2016-12-15 21:04:51

标签: ruby-on-rails postgresql

使用Postgres 9.5.2

在过去的两天里它只发生了两次,而且我一直在做与正常测试条纹的webhook相同的事情,所以我一直在重置用户很多次通过我的向导运行它们干净。但这意味着我一遍又一遍地采取同样的行动,我无法真正思考这些时代与其他时代的区别。

> u.update_attributes role: :customer, stripe_account_id: nil
   (0.1ms)  BEGIN
  User Exists (6.7ms)  SELECT  1 AS one FROM "users" WHERE LOWER("users"."name") = LOWER($1) AND ("users"."id" != $2) LIMIT $3  [["name", "Conan"], ["id", 1], ["LIMIT", 1]]
  User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE LOWER("users"."username") = LOWER($1) AND ("users"."id" != $2) LIMIT $3  [["username", "mcb"], ["id", 1], ["LIMIT", 1]]
  FriendlyId::Slug Load (17.7ms)  SELECT  "friendly_id_slugs".* FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."sluggable_id" = $1 AND "friendly_id_slugs"."sluggable_type" = $2 ORDER BY "friendly_id_slugs".id DESC LIMIT $3  [["sluggable_id", 1], ["sluggable_type", "User"], ["LIMIT", 1]]
----> # NO UPDATE RUN!!!!!!
   (0.2ms)  COMMIT
=> true
[74] pry(main)> u.reload
  User Load (17.9ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
=> #<User id: 1, email: "mcb@email.com", name: "Conan", username: "mcb",
     created_at: "2016-12-02 02:37:43", updated_at: "2016-12-15 20:30:39",
     slug: "mcb", role: "pending_id",
     ..., stripe_customer_id: nil, acts_as_deleted: false,
     stripe_account_id: "acct_0000", first_name: "Joey", last_name: "JoeJoe", ...>

> u.update_attributes role: :customer, stripe_account_id: nil
   (0.2ms)  BEGIN
  User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE LOWER("users"."name") = LOWER($1) AND ("users"."id" != $2) LIMIT $3  [["name", "Conan"], ["id", 1], ["LIMIT", 1]]
  User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE LOWER("users"."username") = LOWER($1) AND ("users"."id" != $2) LIMIT $3  [["username", "mcb"], ["id", 1], ["LIMIT", 1]]
---> (now runs??) SQL (6.2ms)  UPDATE "users" SET "updated_at" = $1, "role" = $2, "stripe_account_id" = $3 WHERE "users"."id" = $4  [["updated_at", 2016-12-15 20:37:07 UTC], ["role", 0], ["stripe_account_id", nil], ["id", 1]]
=> u.reload #=> reloads with `role` as `customer` and `stripe_account_id` `nil`

0 个答案:

没有答案