Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data types suffixes are not being added when creating an auto increment field #282

Closed
MarvinRucinski opened this issue Jul 5, 2023 · 2 comments · Fixed by #357
Closed

Comments

@MarvinRucinski
Copy link

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.3
  • mssql-django: 1.3
  • python: 3.11
  • OS: Windows 10

Problem description and steps to reproduce
When adding an AutoField or BigAutoField to a model the 'IDENTITY (1, 1)' suffix is not being added to the sql code of the migration.

This is the migration:

migrations.AddField(
          model_name='arkusz1',
          name='id',
          field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
          preserve_default=False,
      ),

The sql code generated with the python3 manage.py sqlmigrate command:

BEGIN TRANSACTION
--
-- Add field id to arkusz1
--
ALTER TABLE [Arkusz1$] ADD [id] bigint NOT NULL PRIMARY KEY;
COMMIT;

The expected sql code:

BEGIN TRANSACTION
--
-- Add field id to arkusz1
--
ALTER TABLE [Arkusz1$] ADD [id] bigint IDENTITY (1, 1) NOT NULL PRIMARY KEY;
COMMIT;

Any other details that can be helpful
I see the suffixes are defined in base.py but they are not being used:

data_types_suffix = {
        'AutoField': 'IDENTITY (1, 1)',
        'BigAutoField': 'IDENTITY (1, 1)',
        'SmallAutoField': 'IDENTITY (1, 1)',
    }
@mShan0
Copy link
Contributor

mShan0 commented Jul 6, 2023

Thanks for the report. We do have some AutoField features that are not fully implemented yet (you can see the list here https://github.com/microsoft/mssql-django#limitations) but we'll take a look into this.

@dauinsight
Copy link
Contributor

Hi @MervinDelfin ,we'll have a fix for this in our next release.

@dauinsight dauinsight linked a pull request Mar 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants