Ticket #12192: 12192-patch1.diff

File 12192-patch1.diff, 687 bytes (added by Ramiro Morales, 15 years ago)

Don't query the DB when we know it's going to have LIMIT 0

  • django/db/models/sql/query.py

    diff -r 1fe026327305 django/db/models/sql/query.py
    a b  
    455455
    456456        if with_limits:
    457457            if self.high_mark is not None:
    458                 result.append('LIMIT %d' % (self.high_mark - self.low_mark))
     458                if self.high_mark != self.low_mark:
     459                    result.append('LIMIT %d' % (self.high_mark - self.low_mark))
     460                else:
     461                    return '', ()
    459462            if self.low_mark:
    460463                if self.high_mark is None:
    461464                    val = self.connection.ops.no_limit_value()
Back to Top