Opened 19 years ago
Closed 17 years ago
#1412 closed defect (invalid)
[patch] ado_mssql queries broken
Reported by: | Owned by: | Adam Vandenberg | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I am new to Django and building a model to show an existing MS SQL
Server database using ado_mssql and adodbapi on Windows.
I have a simple 'courses' model working and I can call
courses.get_list() and get the full list of courses. When I try to do a
query such as courses.get_list(codeexact='HR5166') I get a
DatabaseError. The error is the same one shown here:
http://code.djangoproject.com/ticket/644
The problem is that the %s parameters are never getting converted to ?
style - the patched Cursor and Connection code in ado_mssql.py is never
executed.
The reason the patch code is never executed is because the Connection
class is actually defined and accessed in adodbapi.adodbapi (the
adodbapi module of the adodbapi package). The current patch only
changes the package-level reference to Connection created in
adodbapi.init, it doesn't change the class actually used in
adodbapi.connect()
The fix is to patch in both places - the public reference in adodbapi
and the module-level reference in adodbapi.adodbapi. Attached is a diff,
with this fix I can query my database correctly.
Attachments (1)
Change History (7)
by , 19 years ago
Attachment: | ado_mssql.diff added |
---|
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
Triage Stage: | Design decision needed → Accepted |
---|
If somebody other than the original reporter can confirm this works as advertised, we can commit it. I'm wondering how version sensitive it is (MS SQL Server underwent a few radical changes in recent years).
comment:3 by , 18 years ago
This patch shouldn't be sensitive to MS SQL version at all. ado_mssql is monkey-patching adodbapi incorrectly. This patch makes the monkey-patch actually work as intended. This patch might be sensitive to adodbapi version but that project seems to be dead.
comment:4 by , 17 years ago
I can confirm that the fix works on MSSQL Server 2000. I just ran into the same issue, found this bug and applied the patch and now it's working. This is my test:
from django.db import models class OrderExecution(models.Model): transaction_id = models.IntegerField(primary_key=True) competition_id = models.IntegerField() symbol = models.CharField(maxlength=10) tx_date = models.DateTimeField() trader = models.CharField(maxlength=50) quantity = models.IntegerField() price = models.FloatField() amount = models.FloatField() commission = models.FloatField() code = models.CharField(maxlength=10) class Meta: db_table = 'view_order_executions' class Admin: pass print OrderExecution.objects.filter(competition_id=176)
comment:5 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
This patch also works against MS SQL Server 2005, against adodbapi 2.0.1 and 2.1.
If the ado_mssql backend is going to be kept in core, this patch should be committed to trunk.
Otherwise, if MS SQL support is moving external, this case can be closed as duplicate or invalid vs. case 5947.
comment:6 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
This should become part of an external backend as discussed in #2358.
Patch