Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."

This reverts commit 550cb3a365
because try/except performs better.
This commit is contained in:
Tim Graham 2017-09-07 08:16:21 -04:00 committed by GitHub
parent 8b2515a450
commit 6e4c6281db
66 changed files with 351 additions and 207 deletions

View file

@ -1,6 +1,5 @@
import copy
import datetime
from contextlib import suppress
from decimal import Decimal
from django.core.exceptions import EmptyResultSet, FieldError
@ -17,9 +16,11 @@ class SQLiteNumericMixin:
"""
def as_sqlite(self, compiler, connection, **extra_context):
sql, params = self.as_sql(compiler, connection, **extra_context)
with suppress(FieldError):
try:
if self.output_field.get_internal_type() == 'DecimalField':
sql = 'CAST(%s AS NUMERIC)' % sql
except FieldError:
pass
return sql, params