Commit 89920e05 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

Fixed #2108 -- do not try to save an empty model.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 58ab678d
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ class Model(object):
                placeholders.append('(SELECT COUNT(*) FROM %s WHERE %s = %%s)' % \
                    (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.order_with_respect_to.column)))
                db_values.append(getattr(self, self._meta.order_with_respect_to.attname))
            if db_values:
                cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \
                    (backend.quote_name(self._meta.db_table), ','.join(field_names),
                    ','.join(placeholders)), db_values)
+0 −0

Empty file added.

+17 −0
Original line number Diff line number Diff line
"""
Empty model tests

These test that things behave sensibly for the rare corner-case of a model with
no fields.
"""

from django.db import models

class Empty(models.Model):
    pass

API_TESTS = """
>>> m = Empty()
>>> m.save()

"""