I am having trouble updating an existing table using django on ms sql 
server. Here is the query I am using:

>>> c = Candidacy.objects.get(id_num=610020956, stage__in=('150  ', '350 
 '))
>>> c.enroll_dep_amt = 146
>>> c.save()

But the SQL query sent to the server does not look as it should. Instead, I 
get this (note especially the WHERE clause):

>>> print connection.queries[-1]
{'time': '0.079', 'sql': u'UPDATE [CANDIDACY] SET [CUR_CANDIDACY] = Y, 
[STAGE] =
 150  , [ENROLL_FEE_TYPE] = help?, [ENROLL_DEP_DTE] = 2013-07-15 13:12:01, 
[enro
ll_dep_amt] = 146 WHERE [CANDIDACY].[YR_CDE] = 2013 '}

Thus, instead of updating a single row, the sql updates over 1000 rows. 
Below is my model:

class Candidacy(models.Model):
    id_num = models.IntegerField(primary_key=True, db_column=u"ID_NUM")
    trm_cde = models.CharField(max_length=2, primary_key=True, 
                               db_column=u"TRM_CDE")
    yr_cde = models.CharField(max_length=4, primary_key=True, 
                              db_column=u"YR_CDE")
    cur_candidacy = models.CharField(max_length=1, 
db_column=u"CUR_CANDIDACY")
    stage = models.CharField(max_length=5, db_column=u"STAGE")
    enroll_fee_type = models.CharField(max_length=5, 
                                       db_column=u"ENROLL_FEE_TYPE")
    enroll_dep_dte = models.DateTimeField(db_column=u"ENROLL_DEP_DTE")
    enroll_dep_amt = models.DecimalField(max_digits=6, decimal_places=2)
    
    class Meta:
        db_table = u'CANDIDACY'

Thanks in advance to anyone who can point me in the right direction.

Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to