Author: jacob
Date: 2009-04-03 15:53:50 -0500 (Fri, 03 Apr 2009)
New Revision: 10380
Modified:
django/branches/releases/1.0.X/django/db/backends/postgresql/introspection.py
django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py
Log:
[1.0.X] Fixed #9991: correctly introspect PostgreSQL 'real' types. Backport of
r10379 from trunk.
Modified:
django/branches/releases/1.0.X/django/db/backends/postgresql/introspection.py
===================================================================
---
django/branches/releases/1.0.X/django/db/backends/postgresql/introspection.py
2009-04-03 20:52:54 UTC (rev 10379)
+++
django/branches/releases/1.0.X/django/db/backends/postgresql/introspection.py
2009-04-03 20:53:50 UTC (rev 10380)
@@ -7,6 +7,7 @@
21: 'SmallIntegerField',
23: 'IntegerField',
25: 'TextField',
+ 700: 'FloatField',
701: 'FloatField',
869: 'IPAddressField',
1043: 'CharField',
Modified:
django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py
===================================================================
--- django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py
2009-04-03 20:52:54 UTC (rev 10379)
+++ django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py
2009-04-03 20:53:50 UTC (rev 10380)
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.db import connection
from django.test import TestCase
from django.utils import functional
@@ -44,11 +45,11 @@
def test_django_table_names(self):
cursor = connection.cursor()
- cursor.execute('CREATE TABLE django_introspection_testcase_table (id
INTEGER);');
+ cursor.execute('CREATE TABLE django_introspection_test_table (id
INTEGER);');
tl = connection.introspection.django_table_names()
+ cursor.execute("DROP TABLE django_introspection_test_table;")
self.assert_('django_introspection_testcase_table' not in tl,
"django_table_names() returned a non-Django table")
- cursor.execute("DROP TABLE django_introspection_testcase_table;")
def test_installed_models(self):
tables = [Article._meta.db_table, Reporter._meta.db_table]
@@ -68,20 +69,20 @@
[f.column for f in Reporter._meta.fields])
def test_get_table_description_types(self):
- cursor = connection.cursor()
+ cursor = connection.cursor()
desc = connection.introspection.get_table_description(cursor,
Reporter._meta.db_table)
-
- # Convert the datatype into a string
- def datatype(dbtype):
- dt = connection.introspection.data_types_reverse[dbtype]
- if type(dt) is tuple:
- return dt[0]
- else:
- return dt
-
self.assertEqual([datatype(r[1]) for r in desc],
['IntegerField', 'CharField', 'CharField',
'CharField'])
+ # Regression test for #9991 - 'real' types in postgres
+ if settings.DATABASE_ENGINE.startswith('postgresql'):
+ def test_postgresql_real_type(self):
+ cursor = connection.cursor()
+ cursor.execute("CREATE TABLE django_introspection_real_test_table
(number REAL);")
+ desc = connection.introspection.get_table_description(cursor,
'django_introspection_real_test_table')
+ cursor.execute('DROP TABLE django_introspection_real_test_table;')
+ self.assertEqual(datatype(desc[0][1]), 'FloatField')
+
def test_get_relations(self):
cursor = connection.cursor()
relations = connection.introspection.get_relations(cursor,
Article._meta.db_table)
@@ -96,4 +97,12 @@
def test_get_indexes(self):
cursor = connection.cursor()
indexes = connection.introspection.get_indexes(cursor,
Article._meta.db_table)
- self.assertEqual(indexes['reporter_id'], {'unique': False,
'primary_key': False})
\ No newline at end of file
+ self.assertEqual(indexes['reporter_id'], {'unique': False,
'primary_key': False})
+
+def datatype(dbtype):
+ """Helper to convert a data type into a string."""
+ dt = connection.introspection.data_types_reverse[dbtype]
+ if type(dt) is tuple:
+ return dt[0]
+ else:
+ return dt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---