Skip to content

MSSQL- set default value #12797

Closed
Closed

Description

@tonysader

Issue Description

When using mssql and set the default value to a column, it executes the wrong syntax query,

What do you expect to happen?

Modify the default query to alter defaults for mssql

What is actually happening?

Executing (default): ALTER TABLE [TABLENAME] ALTER COLUMN [COLUMNNAME] INTEGER NOT NULL DEFAULT 1;

Should be

ALTER TABLE [TABLENAME] ADD CONSTRAINT [INDEXNAME] DEFAULT 50 FOR [COLUMNNAME];

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens only for the following dialect(s): mssql

Would you be willing to resolve this issue by submitting a Pull Request?

  • No, I don't have the time, although I believe I could do it if I had the time...

Activity

  1. tayyabferozi commented on Sep 11, 2021

    @tayyabferozi

    How did you fix the issue? It seems like they didn't look at it and its been approximately a year

  2. github-actions commented on Oct 28, 2021

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

  3. timhaak commented on Mar 30, 2022

    @timhaak

    Bug is still there unfortunately

    Executing (default): ALTER TABLE [sms_test].[accounts] ALTER COLUMN [commodity_classification] BIT NOT NULL DEFAULT 0;
    ✖ Incorrect syntax near the keyword 'DEFAULT'.

    commodityClassification: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    },

  4. avalencia-vso commented on Aug 9, 2022

    @avalencia-vso

    I ran into the same issue. Can the official documentation at least be updated to say "defaultValue" does not work with MSSQL?

  5. gsbenjamin commented on Aug 30, 2022

    @gsbenjamin

    I have this same issue with the wrong SQL statement generated by sequeilize when adding a defaultvalue for an integer field in Microsoft SQL Server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions