microsoft/mssql-django

Setting a default value for fields do not propagate to database

ArthurNRL opened this issue · 1 comments

There are some features which are not supported yet. Please check the Limitations first to see if your bug is listed.

Software versions

  • Django: 4.2.7
  • mssql-django: 1.4.2
  • python:3.11
  • SQL Server: 15.0.4198.2
  • OS: Windows 11

Table schema and Model

class Test(Model):
    boolean = BooleanField(default=True)

Database Connection Settings

    DATABASES = {
        "default": {
            "ENGINE": DB_ENGINE,
            "NAME": env("SQL_SERVER_DB_NAME"),
            "USER": env("SQL_SERVER_DB_USER"),
            "PASSWORD": env("SQL_SERVER_DB_PASSWORD"),
            "HOST": env("SQL_SERVER_DB_HOST"),
            "PORT": env("SQL_SERVER_DB_PORT"),
            "OPTIONS":  {
                "driver": "ODBC Driver 17 for SQL Server"
            }
        }
    }

Problem description and steps to reproduce
Run makemigrations and migrate the generated create table query is CREATE TABLE [app_test] ([id] bigint NOT NULL PRIMARY KEY IDENTITY (1, 1), [boolean] bit NOT NULL); args=None; alias=default
Default constraint does not get created

Expected behavior and actual behavior
Default Constraint gets created

Nevermind. I actually needed to use the new db_default param. Shame on me