orm: NotNullViolationError: null value in column "id"

I just got an exception when tried to create new database entry via await SomeModel.objects.create(...):

asyncpg.exceptions.NotNullViolationError: null value in column "id" violates not-null constraint
DETAIL:  Failing row contains (null, John, Doe, a@b.c, 1997, M, null, f, null, f, 0, 0, null, 0, 0).

Model:

class SomeModel(Model):
    __tablename__ = DATABASE_TABLE
    __database__ = DATABASE
    __metadata__ = DATABASE_METADATA

    id = Integer(primary_key=True)
    # Some other fields

According to examples it should work without providing id field manually. Maybe I am missing something?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 23 (9 by maintainers)

Most upvoted comments

Use TEST_DATABASE_URLS to set one or more database URLs. We should ensure that the test runs across all configured engines in the same way as the existing test cases (so we can identify if it occurs in other cases, and confirm that any fix works correctly across all cases)