不要怂,就是干,撸起袖子干!

Commit f78c4baa by Jan Aagaard Meier

Merge pull request #4140 from fintura/fix-transactions

Do not add a transaction in findOrCreate if there is none. Fixes #4133
2 parents a27de748 b864736f
# NEXT
- [FIXED] Fix findOrCreate regression trying to add a transaction even if there is none
# 3.4.1
- [FIXED] Fix belongs-to-many ambigious id when through model has id
# 3.4.0 # 3.4.0
- [ADDED] `countAssociations` for hasMany and belongsToMany - [ADDED] `countAssociations` for hasMany and belongsToMany
- [ADDED] Geometry support for postgres - [ADDED] Geometry support for postgres
......
...@@ -1651,7 +1651,10 @@ Model.prototype.findOrCreate = function(options) { ...@@ -1651,7 +1651,10 @@ Model.prototype.findOrCreate = function(options) {
} }
if (options.transaction === undefined && this.sequelize.constructor.cls) { if (options.transaction === undefined && this.sequelize.constructor.cls) {
options.transaction = this.sequelize.constructor.cls.get('transaction'); var t = this.sequelize.constructor.cls.get('transaction');
if (t) {
options.transaction = t;
}
} }
var self = this var self = this
......
...@@ -118,6 +118,11 @@ if (current.dialect.supports.transactions) { ...@@ -118,6 +118,11 @@ if (current.dialect.supports.transactions) {
return this.User.findOrCreate({ return this.User.findOrCreate({
where: { where: {
name: 'Kafka' name: 'Kafka'
},
logging: function (sql) {
if (/default/.test(sql)) {
throw new Error('The transaction was not properly assigned');
}
} }
}).then(function () { }).then(function () {
return self.User.findAll(); return self.User.findAll();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!