Skip to content

Compatibility issue with Django 5.1 #418

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

Open
bdr-sara opened this issue Oct 28, 2024 · 14 comments
Open

Compatibility issue with Django 5.1 #418

bdr-sara opened this issue Oct 28, 2024 · 14 comments

Comments

@bdr-sara
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:5.1.2
  • mssql-django:1.5
  • python:313
  • SQL Server:17
  • OS:windows11

Table schema and Model

class ComponentLinkType(models.Model):
id = models.AutoField(db_column='ID', primary_key=True) # Field name made lowercase.
name_type_link = models.CharField(db_column='Name_Type_Link', max_length=255, blank=True, null=True) # Field name made lowercase.
name_type_en_short = models.CharField(db_column='Name_Type_EN_Short', max_length=50, blank=True, null=True) # Field name made lowercase.
name_type_heb = models.CharField(db_column='Name_Type_HEB', max_length=50, blank=True, null=True) # Field name made lowercase.

class Meta:
    managed = False
    db_table = 'Component_Link_Type'

Database Connection Settings
'ENGINE': 'mssql',

Problem description and steps to reproduce
Updated pip install pyodbc==5.2.0
Updated Django to version 5.1.2.
Installed mssql-django version 1.5 as the database backend.
Ran pip install --upgrade django to update Django.
Encountered a dependency conflict error during the installation due to mssql-django requiring Django < 5.1.
Expected behavior and actual behavior
mssql-django should support Django 5.1 to be compatible with the latest features and security updates. Actual: The current version of mssql-django only supports up to Django 5.0.x, causing a dependency conflict with Django 5.1.x.

Error message/stack trace
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
mssql-django 1.5 requires django<5.1,>=3.2, but you have django 5.1.2 which is incompatible.

Any other details that can be helpful
It would be helpful to know if there are plans to support Django 5.1.x soon or if a workaround exists for users needing compatibility with this version.

@maclinbc
Copy link

This Pull Request solved alot of my issues
https://github.com/microsoft/mssql-django/pull/397/commits

@rjschave
Copy link

rjschave commented Dec 2, 2024

@David-Engel,

It seems you were involved in getting Microsoft to support the the mssql driver for Django back in 2021 (michiya/django-pyodbc-azure#190 and FlipperPA/django#8). The result is this project.

This project has supported Django through version 5.0. There was some effort to update this project to support Django 5.1, but it appears that effort stalled in May. There has been no activity in this repo for 3+ months.

This is a "Microsoft project", but it's not clear to me the maintainers work at/for Microsoft. I'm concerned they have moved on from Microsoft or have been reassigned. Do you have any contact with the folks that had been maintaining this project.

The lack of activity is making some of us nervous. I guess I'm looking for some indication on whether efforts will resume or if this project has been abandoned abandoned.

Thank you.

@maclinbc
Copy link

maclinbc commented Dec 2, 2024

@David-Engel,

It seems you were involved in getting Microsoft to support the the mssql driver for Django back in 2021 (michiya/django-pyodbc-azure#190 and FlipperPA/django#8). The result is this project.

This project has supported Django through version 5.0. There was some effort to update this project to support Django 5.1, but it appears that effort stalled in May. There has been no activity in this repo for 3+ months.

This is a "Microsoft project", but it's not clear to me the maintainers work at/for Microsoft. I'm concerned they have moved on from Microsoft or have been reassigned. Do you have any contact with the folks that had been maintaining this project.

The lack of activity is making some of us nervous. I guess I'm looking for some indication on whether efforts will resume or if this project has been abandoned abandoned.

Thank you.

Someone may have to Fork it and take over if MS for (whatever reason?) abandoned the support.

@rjschave
Copy link

rjschave commented Dec 2, 2024

Someone may have to Fork it and take over if MS for (whatever reason?) abandoned the support.

I thought I might be able to work at the 5.1 branch, but It appears we can't even see why the tests are failing. The test suite runs on Azure Pipelines and the results don't appear to be public. Before I work to get the tests set up on my own infra, I wanted to find out if this project has been abandoned.

The reality is I may not have the skillset or time to take this over.

@David-Engel
Copy link
Contributor

This project hasn't been abandoned. But we did lose some individual contributors. We have some resources that will be taking over this project, but they are currently focused on a different effort in the Python space. We do plan to loop back around to this one.

@ygorcf
Copy link

ygorcf commented Dec 10, 2024

Hello, im waiting for this feature by a month, and seeing the last comment, i cant only sit and wait, so i will try to continue the PR.

@spapas
Copy link

spapas commented Feb 7, 2025

It's like 6 months and we still don't have Django 5.1 compatibility. Any idea when the django51 branch will be merged? It seems to be working fine for me!

For people that need it:

pip install git+https://github.com/microsoft/mssql-django@django51

@ygorcf
Copy link

ygorcf commented Feb 28, 2025

I trying to continue the continue the #397 , I forked, prepared my environment, put everything up, tested manually using another Django app and every works fine, but when I try to run the unit tests, Im stuck on this error:
Creating test database for alias 'default'...
Traceback (most recent call last):
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
~~~~~~~~~~~~~~~~~~~^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/mssql/base.py", line 679, in execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There are no primary or candidate keys in the referenced table 'many_to_one_null_car' that match the referencing column list in the foreign key 'many_to_one_null_driver_car_id_56ac1372_fk_many_to_one_null_car_make'. (1776) (SQLExecDirectW)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/ygorfelix/git/mssql-django/django/tests/runtests.py", line 789, in
failures = django_tests(
options.verbosity,
...<16 lines>...
getattr(options, "durations", None),
)
File "/Users/ygorfelix/git/mssql-django/django/tests/runtests.py", line 427, in django_tests
failures = test_runner.run_tests(test_labels)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/test/runner.py", line 1066, in run_tests
old_config = self.setup_databases(
aliases=databases,
serialized_aliases=suite.serialized_aliases,
)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/test/runner.py", line 964, in setup_databases
return _setup_databases(
self.verbosity,
...<5 lines>...
**kwargs,
)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/test/utils.py", line 206, in setup_databases
connection.creation.create_test_db(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
verbosity=verbosity,
^^^^^^^^^^^^^^^^^^^^
...<2 lines>...
serialize=serialize_alias,
^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/base/creation.py", line 78, in create_test_db
call_command(
~~~~~~~~~~~~^
"migrate",
^^^^^^^^^^
...<3 lines>...
run_syncdb=True,
^^^^^^^^^^^^^^^^
)
^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/core/management/init.py", line 194, in call_command
return command.execute(*args, **defaults)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/core/management/commands/migrate.py", line 322, in handle
self.sync_apps(connection, executor.loader.unmigrated_apps)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/core/management/commands/migrate.py", line 469, in sync_apps
with connection.schema_editor() as editor:
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/base/schema.py", line 167, in exit
self.execute(sql, None)
~~~~~~~~~~~~^^^^^^^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/mssql/schema.py", line 1422, in execute
cursor.execute(sql, params)
~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
sql, params, many=False, executor=self._execute
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
~~~~~~~~~~~~~~~~~~~^^^^^
File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/mssql/base.py", line 679, in execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There are no primary or candidate keys in the referenced table 'many_to_one_null_car' that match the referencing column list in the foreign key 'many_to_one_null_driver_car_id_56ac1372_fk_many_to_one_null_car_make'. (1776) (SQLExecDirectW)")
py313-django51: exit 1 (12.69 seconds) /Users/ygorfelix/git/mssql-django> bash test.sh pid=44112
py313-django51: FAIL code 1 (16.07=setup[3.37]+cmd[12.69] seconds)
evaluation failed :( (16.12 seconds)

Does anyone in community can help with this?

@bmaclin58
Copy link

bmaclin58 commented Feb 28, 2025

I trying to continue the continue the #397 , I forked, prepared my environment, put everything up, tested manually using another Django app and every works fine, but when I try to run the unit tests, Im stuck on this error: Creating test database for alias 'default'... Traceback (most recent call last): File "/Users/ygorfelix/git/mssql-django/.tox/py313-django51/lib/python3.13/site-packages/django/db/backends/utils.py", line 103, in \

1.) Which version of Django are you using?
2.) There seems to be a many to one issue so the issue might be with the model, not with mssql
3.) When did this error occur? Has it worked before?

@JonnyWaffles
Copy link

Hi @David-Engel, it's been a hot minute. Any chance Microsoft would be willing to continue their stewardship? I would like to move a critical project to a modern LTS Django version like 5.2! As surely you know Django is one of the most widely used Python frameworks. Microsoft's MSSQL support is of paramount importance to a lot of MS shops. Thanks!

@Wedge009
Copy link

Wedge009 commented Mar 7, 2025

I flagged the lack of support in this project as a major risk in my organisation's work. We are only using this project specifically because of their pre-existing use of SQL Server, however, with composite primary key support scheduled for Django 5.2, being tied to Django 5.0 is a hindrance and a risk. I may have to advocate for an alternative database to use in our project.

@David-Engel
Copy link
Contributor

We have not abandoned this project. The team has just been busy trying to address other pain points around the Python + SQL experience. If you want a sneak peek, check out the new Python SQL driver (in alpha): microsoft/mssql-python

That team will be looping back to this Django connector as soon as they can to add support for Django 5.2 (LTS). But to be transparent, I don't think that will happen until Q3, at the earliest.

@hamzaalmali
Copy link

It has been 1 year since the last update of the library, I need to update my projects. But although I have been waiting for a long time, I can't see anything about the update. It is said that it will be updated in the 3rd quarter, will this really happen?

@WayneLambert
Copy link

Hi @David-Engel ,

Thank you for keeping us updated with the plans for the mssql-django package. I appreciate the transparency and the efforts to ensure that the package remains functional and up-to-date.

I note your comments that the intentions of the Microsoft team is to resume development with a view to including Django 5.2 support in Q3 at the earliest.

Does this mean that even if a PR for Django 5.1 compatibility is submitted and the tests for the package's testapp and the pre-selected tests for Django's test suite passes in Azure Pipelines, a maintainer from within Microsoft would not have the bandwidth to review, merge, and release to PyPI in any case since they would be engaged in the new mssql-python adapter that you've mentioned?

Also, can I assume that your approach would first be to release with Django 5.1 support and then follow on afterwards with a separate release for 5.2?

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

No branches or pull requests