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

Commit ba4de68e by Mick Hansen

Merge pull request #2213 from javiercornejo/issue-2206

Resolves #2206: Error creating pg_temp.testfunc()
2 parents 58732576 2d0cc2bd
...@@ -185,7 +185,7 @@ module.exports = (function() { ...@@ -185,7 +185,7 @@ module.exports = (function() {
if (this._dialect.supports['EXCEPTION'] && options.exception) { if (this._dialect.supports['EXCEPTION'] && options.exception) {
// Mostly for internal use, so we expect the user to know what he's doing! // Mostly for internal use, so we expect the user to know what he's doing!
// pg_temp functions are private per connection, so we never risk this function interfering with another one. // pg_temp functions are private per connection, so we never risk this function interfering with another one.
valueQuery = 'CREATE OR REPLACE FUNCTION pg_temp.testfunc() RETURNS SETOF <%= table %> AS $body$ BEGIN RETURN QUERY ' + valueQuery + '; EXCEPTION ' + options.exception + ' END; $body$ LANGUAGE plpgsql; SELECT * FROM pg_temp.testfunc()'; valueQuery = 'CREATE OR REPLACE FUNCTION pg_temp.testfunc() RETURNS SETOF <%= table %> AS $body$ BEGIN RETURN QUERY ' + valueQuery + '; EXCEPTION ' + options.exception + ' END; $body$ LANGUAGE plpgsql; SELECT * FROM pg_temp.testfunc(); DROP FUNCTION IF EXISTS pg_temp.testfunc();';
} }
valueHash = Utils.removeNullValuesFromHash(valueHash, this.options.omitNull); valueHash = Utils.removeNullValuesFromHash(valueHash, this.options.omitNull);
......
...@@ -28,8 +28,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -28,8 +28,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
aBool: DataTypes.BOOLEAN, aBool: DataTypes.BOOLEAN,
uniqueName: { type: DataTypes.STRING, unique: true } uniqueName: { type: DataTypes.STRING, unique: true }
}) })
this.Account = this.sequelize.define('Account', {
accountName: DataTypes.STRING
});
return this.User.sync({ force: true }); return this.sequelize.sync({ force: true });
}); });
}); });
...@@ -51,6 +54,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -51,6 +54,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it("supports more than one models per transaction", function(done) {
var self = this;
this.sequelize.transaction().then(function(t) {
self.User.findOrCreate({ where: { username: 'Username'}, defaults: { data: 'some data' }}, { transaction: t }).then(function() {
self.Account.findOrCreate({ where: { accountName: 'accountName'}}, { transaction: t}).then(function(){
t.commit().success(function() {
done()
})
})
})
})
})
it("returns instance if already existent. Single find field.", function(done) { it("returns instance if already existent. Single find field.", function(done) {
var self = this, var self = this,
data = { data = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!