Thanks, Tom. I overlooked the primary keys.

Justin

On Tuesday, July 16, 2013 9:44:04 AM UTC-6, Tom Evans wrote:
>
> On Mon, Jul 15, 2013 at 3:05 PM, J. Barber <[email protected] <javascript:>> 
> wrote: 
> > 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, 
>
>         ^^^^^^^^^^^ 
>
> Don't have multiple primary keys. 
>
> Cheers 
>
> Tom 
>

-- 
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