我收到“警告:没有正在进行的交易”错误,如here所述。当我查看日志时,我看到我的风帆水线ORM导致“声明”字出现在日志中如果我使用其Model.query方法并且“执行”字出现在通过其模型方法发出的查询前面比如.insert,.update等。它们之间在交易中的行为方式有什么区别吗?或者,日志中“声明”和“执行”之间的区别是什么?
2015-02-18 21:31:03 UTC [6810-35] vdsr@sails LOG: statement: start transaction
2015-02-18 21:31:03 UTC [6813-33] vdsr@sails LOG: execute <unnamed>: INSERT INTO "groups" ("name", "notes", "isCompany", "parentGroupRef", "companyRef", "createdAt", "updatedAt") values ($1, $2, $3, $4, $5, $6, $7) RETURNING *
2015-02-18 21:31:03 UTC [6813-34] vdsr@sails DETAIL: parameters: $1 = 'bbbb', $2 = 'fdf', $3 = 't', $4 = '1', $5 = '1', $6 = '2015-02-18 21:31:03+00', $7 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6814-33] vdsr@sails LOG: execute <unnamed>: INSERT INTO "users" ("firstName", "lastName", "email", "companyRef", "isMainUser", "password", "middleName", "createdAt", "updatedAt") values ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *
2015-02-18 21:31:03 UTC [6814-34] vdsr@sails DETAIL: parameters: $1 = 'ffff', $2 = 'ffdd', $3 = 'ffdfd@ds.com', $4 = '19', $5 = 't', $6 = 'cc5ce3a7addcb4512c7af12a6594af91', $7 = '', $8 = '2015-02-18 21:31:03+00', $9 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6805-53] vdsr@sails LOG: execute <unnamed>: INSERT INTO "roles" ("name", "companyRef", "createdAt", "updatedAt") values ($1, $2, $3, $4) RETURNING *
2015-02-18 21:31:03 UTC [6805-54] vdsr@sails DETAIL: parameters: $1 = 'Master', $2 = '19', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6809-37] vdsr@sails LOG: execute <unnamed>: INSERT INTO "userroles" ("roleRef", "userRef", "createdAt", "updatedAt") values ($1, $2, $3, $4) RETURNING *
2015-02-18 21:31:03 UTC [6809-38] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '16', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6808-37] vdsr@sails LOG: execute <unnamed>: INSERT INTO "rolepermissions" ("roleRef", "permissionRef", "createdAt", "updatedAt") values ($1, $2, $3, $4) RETURNING *
2015-02-18 21:31:03 UTC [6808-38] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '24', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6811-35] vdsr@sails LOG: execute <unnamed>: INSERT INTO "rolepermissions" ("roleRef", "permissionRef", "createdAt", "updatedAt") values ($1, $2, $3, $4) RETURNING *
2015-02-18 21:31:03 UTC [6811-36] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '22', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00'
2015-02-18 21:31:03 UTC [6806-41] vdsr@sails LOG: execute <unnamed>: SELECT "groups"."name", "groups"."notes", "groups"."parentGroupRef", "groups"."isCompany", "groups"."hierPos", "groups"."companyRef", "groups"."id", "groups"."createdAt", "groups"."updatedAt" FROM "groups" AS "groups" WHERE "groups"."companyRef" = $1
2015-02-18 21:31:03 UTC [6806-42] vdsr@sails DETAIL: parameters: $1 = '1'
2015-02-18 21:31:03 UTC [6807-41] vdsr@sails LOG: statement: update groups set "hierPos" = case id when 2 then '1' when 3 then '2' when 4 then '3' when 5 then '4' when 6 then '4.1' when 10 then '4.1.1' when 18 then '4.2' when 13 then '5' when 17 then '6' when 19 then '7' else "hierPos" end where id in (2,3,4,5,6,10,18,13,17,19)
2015-02-18 21:31:03 UTC [6812-35] vdsr@sails LOG: statement: commit
2015-02-18 21:31:03 UTC [6812-36] vdsr@sails WARNING: there is no transaction in progress
答案 0 :(得分:1)
您最有可能在自动提交模式下运行查询。在此模式下,每个语句都有自己的小事务。 WARNING
已发布,因为所有语句都已提交,commit
语句未“看到”它们。
至于“执行”与“语句”:其中一个似乎是带参数的预备语句。另一个只是一个没有附加参数的简单查询。