tickets: 42
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
42 | 2005-07-17 05:47:13 | 2006-10-14 14:31:41 | 2022-03-06 03:19:33.463570 | Unreviewed | closed | Database layer (models, ORM) | defect | normal | fixed | OneToOneField missing from DATA_TYPES dict | 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. | adrian | nullstyle@gmail.com | 0 | 0 | 0 | 0 | 0 | 0 |