--- a/web/lib/django/db/backends/postgresql/operations.py Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/db/backends/postgresql/operations.py Tue May 25 02:43:45 2010 +0200
@@ -6,14 +6,15 @@
# used by both the 'postgresql' and 'postgresql_psycopg2' backends.
class DatabaseOperations(BaseDatabaseOperations):
- def __init__(self):
+ def __init__(self, connection):
+ super(DatabaseOperations, self).__init__()
self._postgres_version = None
+ self.connection = connection
def _get_postgres_version(self):
if self._postgres_version is None:
- from django.db import connection
from django.db.backends.postgresql.version import get_version
- cursor = connection.cursor()
+ cursor = self.connection.cursor()
self._postgres_version = get_version(cursor)
return self._postgres_version
postgres_version = property(_get_postgres_version)
@@ -162,3 +163,17 @@
if self.postgres_version[0:2] == (8,2):
if self.postgres_version[2] is None or self.postgres_version[2] <= 4:
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)
+
+ def max_name_length(self):
+ """
+ Returns the maximum length of an identifier.
+
+ Note that the maximum length of an identifier is 63 by default, but can
+ be changed by recompiling PostgreSQL after editing the NAMEDATALEN
+ macro in src/include/pg_config_manual.h .
+
+ This implementation simply returns 63, but can easily be overridden by a
+ custom database backend that inherits most of its behavior from this one.
+ """
+
+ return 63