-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: base type wont work after ENUM model is synced (#8851)
- Loading branch information
1 parent
bf7a55b
commit d98d8bd
Showing
3 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'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; | ||
}); | ||
}); | ||
}); | ||
} |