mirror of
https://github.com/django/django.git
synced 2025-08-31 07:47:37 +00:00
Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365
because try/except performs better.
This commit is contained in:
parent
8b2515a450
commit
6e4c6281db
66 changed files with 351 additions and 207 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue