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

Commit d98d8bd8 by Sushant Committed by GitHub

fix: base type wont work after ENUM model is synced (#8851)

1 parent bf7a55ba
......@@ -255,10 +255,7 @@ class QueryInterface {
.tap(() => {
// If ENUM processed, then refresh OIDs
if (promises.length) {
return this.sequelize.dialect.connectionManager._refreshDynamicOIDs()
.then(() => {
return this.sequelize.refreshTypes(DataTypes.postgres);
});
return this.sequelize.dialect.connectionManager._refreshDynamicOIDs();
}
})
.then(() => {
......
......@@ -87,8 +87,6 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return Sequelize.ABSTRACT.prototype.stringify.apply(this, arguments);
});
current.refreshTypes();
const User = current.define('user', {
field: Type
}, {
......@@ -96,6 +94,9 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
});
return current.sync({ force: true }).then(() => {
current.refreshTypes();
return User.create({
field: value
});
......
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require(__dirname + '/../../support'),
Sequelize = Support.Sequelize,
dialect = Support.getTestDialect();
if (dialect.match(/^postgres/)) {
describe('[POSTGRES Specific] Regressions', () => {
it('properly fetch OIDs after sync, #8749', function() {
const User = this.sequelize.define('User', {
active: Sequelize.BOOLEAN
});
/**
* This Model is important, sync will try to fetch OIDs after each ENUM model sync
* Having ENUM in this model will force OIDs re-fetch
* We are testing that OID refresh keep base type intact
*/
const Media = this.sequelize.define('Media', {
type: Sequelize.ENUM([
'image', 'video', 'audio'
])
});
User.hasMany(Media);
Media.belongsTo(User);
return this.sequelize
.sync({ force: true })
.then(() => User.create({ active: true }))
.then(user => {
expect(user.active).to.be.true;
expect(user.get('active')).to.be.true;
return User.findOne();
})
.then(user => {
expect(user.active).to.be.true;
expect(user.get('active')).to.be.true;
return User.findOne({ raw: true });
})
.then(user => {
expect(user.active).to.be.true;
});
});
});
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!