Ticket #10906: 10906-r10633-detect-early-postgresql.diff
File 10906-r10633-detect-early-postgresql.diff, 2.6 KB (added by , 16 years ago) |
---|
-
django/db/backends/postgresql/operations.py
152 152 def check_aggregate_support(self, aggregate): 153 153 """Check that the backend fully supports the provided aggregate. 154 154 155 The population and sample statistics (STDDEV_POP, STDDEV_SAMP, 156 VAR_POP, VAR_SAMP) were first implemented in Postgres 8.2. 157 155 158 The implementation of population statistics (STDDEV_POP and VAR_POP) 156 159 under Postgres 8.2 - 8.2.4 is known to be faulty. Raise 157 160 NotImplementedError if this is the database in use. 158 161 """ 162 if aggregate.sql_function == 'STDDEV_POP' or aggregate.sql_function == 'STDDEV_SAMP' or aggregate.sql_function == 'VAR_POP' or aggregate.sql_function == 'VAR_SAMP': 163 if self.postgres_version[0] < 8 or (self.postgres_version[0] == 8 and self.postgres_version[1] < 2): 164 raise NotImplementedError('PostgreSQL does not support %s until version 8.2. Please upgrade your version of PostgreSQL.' % aggregate.sql_function) 165 159 166 if aggregate.sql_function == 'STDDEV_POP' or aggregate.sql_function == 'VAR_POP': 160 167 if self.postgres_version[0] == 8 and self.postgres_version[1] == 2 and self.postgres_version[2] <= 4: 161 168 raise NotImplementedError('PostgreSQL 8.2 to 8.2.4 is known to have a faulty implementation of %s. Please upgrade your version of PostgreSQL.' % aggregate.sql_function) -
tests/regressiontests/aggregation_regress/models.py
1 1 # coding: utf-8 2 2 import pickle 3 3 4 from django.db import models4 from django.db import connection, models 5 5 from django.conf import settings 6 6 7 7 try: … … 321 321 """ 322 322 } 323 323 324 if settings.DATABASE_ENGINE != 'sqlite3': 324 if not (settings.DATABASE_ENGINE == 'sqlite3' or 325 ((settings.DATABASE_ENGINE == 'postgresql' or settings.DATABASE_ENGINE == 'postgresql_psycopg2') and 326 (connection.ops.postgres_version[0] < 8 or (connection.ops.postgres_version[0] == 8 and connection.ops.postgres_version[1] < 2)))): 325 327 __test__['API_TESTS'] += """ 326 # Stddev and Variance are not guaranteed to be available for SQLite .328 # Stddev and Variance are not guaranteed to be available for SQLite or PostgreSQL before 8.2. 327 329 328 330 >>> Book.objects.aggregate(StdDev('pages')) 329 331 {'pages__stddev': 311.46...}