Repository navigation
Open
Labels
dialect: mssqlFor issues and PRs. Things that involve MSSQL (and do not involve all dialects).
Description
Issue Creation Checklist
- [ x] I have read the contribution guidelines
Bug Description
const { Model } = require('@sequelize/core');
module.exports = (sequelize, DataTypes) => {
class SmsAccounts extends Model {
static associate(models) {
}
}
SmsAccounts.init(
{
expiresOn: {
type: DataTypes.DATE,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
portalId: {
type: DataTypes.INTEGER,
allowNull: false,
},
commodityClassification: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
parentId: {
type: DataTypes.INTEGER,
allowNull: false,
},
},
{
sequelize,
tableName: 'accounts',
schema: process.env.SMS_SCHEMA,
underscored: true,
},
);
return SmsAccounts;
};await sequelize.sync({ alter: true });What do you expect to happen?
Update/create a table in mssql setting default values
What is actually happening?
Failing to set default value due to incorrect syntax.
Executing (default): ALTER TABLE [sms_test].[accounts] ALTER COLUMN [commodity_classification] BIT NOT NULL DEFAULT 0;
✖ Incorrect syntax near the keyword 'DEFAULT'.
✖ Error
Additional context
It should be doing something similar to the following
ALTER TABLE [sms_test].[accounts] ADD DEFAULT 0 FOR commodity_classification;Environment
- Sequelize version: @sequelize/[email protected] (Same is happening on [email protected])
- Node.js version: v17.8.0
- If TypeScript related: TypeScript version: N/A
- Database & Version: MSSQL (Microsoft SQL Azure (RTM) - 12.0.2000.8 )
- Connector library & Version: tedious (14.4.0)
Would you be willing to resolve this issue by submitting a Pull Request?
- [x ] No, I don't have the time, although I believe I could do it if I had the time...
(Will try possibly next month once I've put out some fires.)
Reacted by mbingel
Metadata
Metadata
Assignees
Labels
dialect: mssqlFor issues and PRs. Things that involve MSSQL (and do not involve all dialects).
Activity
[-]MSSQL- set default value[/-][+]`alter` doesn't change the default value correctly with MSSQL[/+]ephys commentedon Mar 30, 2022
I've taken the liberty of updating the title for easier search queries
I'll also link this closed but unresolved issue to redirect users here if they find the other one #12797
Unfortunately
sync({ alter })has a large number of bugs, but fixing them is low on our priority list.If you do end up having the time to resolve this issue, a PR would be fantastic :)
timhaak commentedon Mar 30, 2022
Thanks for the reply :)
Not a problem. I'm most likely going to try to solve this by just doing migrations for now :).
More that the bug is logged and if I do find some free time I'll try to sort it out.
Though from the quick look into MSSQL default think it's going to be tougher than it should.
Thanks for the library and work put into it :).