summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/base.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-07-01 01:17:51 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-07-01 01:17:51 +0000
commit6f4e933fcc78da11ec43214efd3472192030eced (patch)
treed92140118d3afa00bcd909f475dd1a694c15c08f /django/db/backends/postgresql/base.py
parent7a981380def046f753ff70a7c25efcd781ff6ac6 (diff)
newforms-admin: Merged to [5571]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5572 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r--django/db/backends/postgresql/base.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index fedbb6b7f1..611852e0dc 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -87,7 +87,7 @@ class DatabaseWrapper(local):
global postgres_version
if not postgres_version:
cursor.execute("SELECT version()")
- postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
+ postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
if settings.DEBUG:
return util.CursorDebugWrapper(cursor, self)
return cursor
@@ -105,7 +105,14 @@ class DatabaseWrapper(local):
self.connection.close()
self.connection = None
+allows_group_by_ordinal = True
+allows_unique_and_pk = True
+autoindexes_primary_keys = True
+needs_datetime_string_cast = True
+needs_upper_for_iops = False
supports_constraints = True
+supports_tablespaces = False
+uses_case_insensitive_names = False
def quote_name(name):
if name.startswith('"') and name.endswith('"'):
@@ -138,6 +145,9 @@ def get_date_trunc_sql(lookup_type, field_name):
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
+def get_datetime_cast_sql():
+ return None
+
def get_limit_offset_sql(limit, offset=None):
sql = "LIMIT %s" % limit
if offset and offset != 0:
@@ -149,7 +159,7 @@ def get_random_function_sql():
def get_deferrable_sql():
return " DEFERRABLE INITIALLY DEFERRED"
-
+
def get_fulltext_search_sql(field_name):
raise NotImplementedError
@@ -159,12 +169,21 @@ def get_drop_foreignkey_sql():
def get_pk_default_value():
return "DEFAULT"
+def get_max_name_length():
+ return None
+
+def get_start_transaction_sql():
+ return "BEGIN;"
+
+def get_autoinc_sql(table):
+ return None
+
def get_sql_flush(style, tables, sequences):
"""Return a list of SQL statements required to remove all data from
all tables in the database (without actually removing the tables
themselves) and put the database in an empty 'initial' state
-
- """
+
+ """
if tables:
if postgres_version[0] >= 8 and postgres_version[1] >= 1:
# Postgres 8.1+ can do 'TRUNCATE x, y, z...;'. In fact, it *has to* in order to be able to
@@ -175,7 +194,7 @@ def get_sql_flush(style, tables, sequences):
style.SQL_FIELD(', '.join([quote_name(table) for table in tables]))
)]
else:
- # Older versions of Postgres can't do TRUNCATE in a single call, so they must use
+ # Older versions of Postgres can't do TRUNCATE in a single call, so they must use
# a simple delete.
sql = ['%s %s %s;' % \
(style.SQL_KEYWORD('DELETE'),
@@ -243,7 +262,7 @@ def get_sql_sequence_reset(style, model_list):
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(f.m2m_db_table())))
return output
-
+
# Register these custom typecasts, because Django expects dates/times to be
# in Python's native (standard-library) datetime/time format, whereas psycopg
# use mx.DateTime by default.
@@ -261,6 +280,8 @@ OPERATOR_MAPPING = {
'iexact': 'ILIKE %s',
'contains': 'LIKE %s',
'icontains': 'ILIKE %s',
+ 'regex': '~ %s',
+ 'iregex': '~* %s',
'gt': '> %s',
'gte': '>= %s',
'lt': '< %s',