News for hackers. Stuff that matters.
Re:Data denormalization is broken by icebraining on Saturday October 01, 2016 @04:49AM (#12617082)
I know it uses lazy results, but can you actually loop over the results without triggering a query? Could you write something like:

  records = ORM.search(type='X')
  for record in records:
    record.a = record.b + 30
and only trigger a single UPDATE query?
Re:Data denormalization is broken by collyw on Saturday October 01, 2016 @08:52AM (#12617642)
There is an update method that can be used with F expressions to achieve this.

This is the example in their docs:

    Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Re:Data denormalization is broken by combatentropy on Saturday October 01, 2016 @01:04PM (#12618750)
To write it in pure SQL would ensure the single query you're looking for and be less to type:

  update records
  set a = b + 30
  where type = 'X'