-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Field with default value not saved on create when using the "fields" option. #3458
Copy link
Copy link
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Description
Hello, as described in the title:
If i define a model with a default value for example in my case a UUID
var Media = sequelize.define('Media', {
uuid: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false
},
someValue: DataTypes.STRING
});Then, if i create my entity using the fields option
Media.create({someValue: 'some value'}, {
fields: ['someValue']
});The field uuid is not "inserted"
INSERT INTO `Media` (`someValue`,`updatedAt`,`createdAt`) VALUES ('some value','2015-04-04 05:41:14','2015-04-04 05:41:14');But if i set my "defaultValue" field into the fields option
Media.create({someValue: 'some value'}, {
fields: ['uuid', 'someValue']
});Everything "works fine"
INSERT INTO `Media` (`uuid`,`someValue`,`updatedAt`,`createdAt`) VALUES ('711544ee-691e-4f73-a9d5-9ef11273fa65','some value','2015-04-04 05:41:14','2015-04-04 05:41:14');Using Sequelize 2.0.5 with MariaDB.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type