﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
42	OneToOneField missing from DATA_TYPES dict	nullstyle@…	Adrian Holovaty	"revision 138 on trunk is missing entries for OneToOneField fields, and so sql generation fails if you have such a field in one of your models.  below is a simple patch to add it to the backends.

{{{
Index: django/core/db/backends/postgresql.py
===================================================================
--- django/core/db/backends/postgresql.py	(revision 134)
+++ django/core/db/backends/postgresql.py	(working copy)
@@ -105,6 +105,7 @@
     'IPAddressField':    'inet',
     'ManyToManyField':   None,
     'NullBooleanField':  'boolean',
+    'OneToOneField':   None,
     'PhoneNumberField':  'varchar(20)',
     'PositiveIntegerField': 'integer CHECK (%(name)s >= 0)',
     'PositiveSmallIntegerField': 'smallint CHECK (%(name)s >= 0)',
Index: django/core/db/backends/mysql.py
===================================================================
--- django/core/db/backends/mysql.py	(revision 134)
+++ django/core/db/backends/mysql.py	(working copy)
@@ -95,6 +95,7 @@
     'IPAddressField':    'char(15)',
     'ManyToManyField':   None,
     'NullBooleanField':  'bool',
+    'OneToOneField':   None,
     'PhoneNumberField':  'varchar(20)',
     'PositiveIntegerField': 'integer UNSIGNED',
     'PositiveSmallIntegerField': 'smallint UNSIGNED',

}}}

the patch fixes sql generation for simple cases such as:

{{{
class Piece(meta.Model):
	fields = (
		meta.CharField('title', 'title', maxlength=256),
		meta.DateTimeField('publishDate', 'date published'),
		meta.ManyToManyField(Category),
	)

class ImagePiece(meta.Model):
	fields = (
		meta.OneToOneField(Piece),		
		meta.FileField('data', 'data', upload_to='pieces'),
	)

}}}

but more complicated models haven't been tested.
"	defect	closed	Database layer (models, ORM)		normal	fixed			Unreviewed	0	0	0	0	0	0
