Loading django/contrib/gis/db/backends/base/operations.py +4 −4 Original line number Diff line number Diff line Loading @@ -98,12 +98,12 @@ class BaseSpatialOperations(object): """ raise NotImplementedError('subclasses of BaseSpatialOperations must provide a geo_db_placeholder() method') def check_aggregate_support(self, aggregate): if isinstance(aggregate, self.disallowed_aggregates): def check_expression_support(self, expression): if isinstance(expression, self.disallowed_aggregates): raise NotImplementedError( "%s spatial aggregation is not supported by this database backend." % aggregate.name "%s spatial aggregation is not supported by this database backend." % expression.name ) super(BaseSpatialOperations, self).check_aggregate_support(aggregate) super(BaseSpatialOperations, self).check_expression_support(expression) def spatial_aggregate_name(self, agg_name): raise NotImplementedError('Aggregate support not implemented for this spatial backend.') Loading django/contrib/gis/db/models/aggregates.py +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ class GeoAggregate(Aggregate): is_extent = False def as_sql(self, compiler, connection): # this will be called again in parent, but it's needed now - before # we get the spatial_aggregate_name connection.ops.check_expression_support(self) self.function = connection.ops.spatial_aggregate_name(self.name) return super(GeoAggregate, self).as_sql(compiler, connection) Loading django/db/backends/base/features.py +3 −5 Original line number Diff line number Diff line from django.db.models.aggregates import StdDev from django.db.models.expressions import Value from django.db.utils import ProgrammingError from django.utils.functional import cached_property Loading Loading @@ -226,12 +228,8 @@ class BaseDatabaseFeatures(object): @cached_property def supports_stddev(self): """Confirm support for STDDEV and related stats functions.""" class StdDevPop(object): contains_aggregate = True sql_function = 'STDDEV_POP' try: self.connection.ops.check_aggregate_support(StdDevPop()) self.connection.ops.check_expression_support(StdDev(Value(1))) return True except NotImplementedError: return False Loading django/db/backends/base/operations.py +15 −5 Original line number Diff line number Diff line import datetime import decimal from importlib import import_module import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.backends import utils from django.utils import six, timezone from django.utils.dateparse import parse_duration from django.utils.deprecation import RemovedInDjango21Warning from django.utils.encoding import force_text Loading Loading @@ -517,12 +519,20 @@ class BaseDatabaseOperations(object): return value def check_aggregate_support(self, aggregate_func): """Check that the backend supports the provided aggregate warnings.warn( "check_aggregate_support has been deprecated. Use " "check_expression_support instead.", RemovedInDjango21Warning, stacklevel=2) return self.check_expression_support(aggregate_func) This is used on specific backends to rule out known aggregates that are known to have faulty implementations. If the named aggregate function has a known problem, the backend should raise NotImplementedError. def check_expression_support(self, expression): """ Check that the backend supports the provided expression. This is used on specific backends to rule out known expressions that have problematic or nonexistent implementations. If the expression has a known problem, the backend should raise NotImplementedError. """ pass Loading django/db/backends/sqlite3/features.py +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): """Confirm support for STDDEV and related stats functions SQLite supports STDDEV as an extension package; so connection.ops.check_aggregate_support() can't unilaterally connection.ops.check_expression_support() can't unilaterally rule out support for STDDEV. We need to manually check whether the call works. """ Loading Loading
django/contrib/gis/db/backends/base/operations.py +4 −4 Original line number Diff line number Diff line Loading @@ -98,12 +98,12 @@ class BaseSpatialOperations(object): """ raise NotImplementedError('subclasses of BaseSpatialOperations must provide a geo_db_placeholder() method') def check_aggregate_support(self, aggregate): if isinstance(aggregate, self.disallowed_aggregates): def check_expression_support(self, expression): if isinstance(expression, self.disallowed_aggregates): raise NotImplementedError( "%s spatial aggregation is not supported by this database backend." % aggregate.name "%s spatial aggregation is not supported by this database backend." % expression.name ) super(BaseSpatialOperations, self).check_aggregate_support(aggregate) super(BaseSpatialOperations, self).check_expression_support(expression) def spatial_aggregate_name(self, agg_name): raise NotImplementedError('Aggregate support not implemented for this spatial backend.') Loading
django/contrib/gis/db/models/aggregates.py +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ class GeoAggregate(Aggregate): is_extent = False def as_sql(self, compiler, connection): # this will be called again in parent, but it's needed now - before # we get the spatial_aggregate_name connection.ops.check_expression_support(self) self.function = connection.ops.spatial_aggregate_name(self.name) return super(GeoAggregate, self).as_sql(compiler, connection) Loading
django/db/backends/base/features.py +3 −5 Original line number Diff line number Diff line from django.db.models.aggregates import StdDev from django.db.models.expressions import Value from django.db.utils import ProgrammingError from django.utils.functional import cached_property Loading Loading @@ -226,12 +228,8 @@ class BaseDatabaseFeatures(object): @cached_property def supports_stddev(self): """Confirm support for STDDEV and related stats functions.""" class StdDevPop(object): contains_aggregate = True sql_function = 'STDDEV_POP' try: self.connection.ops.check_aggregate_support(StdDevPop()) self.connection.ops.check_expression_support(StdDev(Value(1))) return True except NotImplementedError: return False Loading
django/db/backends/base/operations.py +15 −5 Original line number Diff line number Diff line import datetime import decimal from importlib import import_module import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.backends import utils from django.utils import six, timezone from django.utils.dateparse import parse_duration from django.utils.deprecation import RemovedInDjango21Warning from django.utils.encoding import force_text Loading Loading @@ -517,12 +519,20 @@ class BaseDatabaseOperations(object): return value def check_aggregate_support(self, aggregate_func): """Check that the backend supports the provided aggregate warnings.warn( "check_aggregate_support has been deprecated. Use " "check_expression_support instead.", RemovedInDjango21Warning, stacklevel=2) return self.check_expression_support(aggregate_func) This is used on specific backends to rule out known aggregates that are known to have faulty implementations. If the named aggregate function has a known problem, the backend should raise NotImplementedError. def check_expression_support(self, expression): """ Check that the backend supports the provided expression. This is used on specific backends to rule out known expressions that have problematic or nonexistent implementations. If the expression has a known problem, the backend should raise NotImplementedError. """ pass Loading
django/db/backends/sqlite3/features.py +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): """Confirm support for STDDEV and related stats functions SQLite supports STDDEV as an extension package; so connection.ops.check_aggregate_support() can't unilaterally connection.ops.check_expression_support() can't unilaterally rule out support for STDDEV. We need to manually check whether the call works. """ Loading