question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NotNullViolationError: null value in column "id"

See original GitHub issue

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?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tomchristiecommented, Apr 17, 2019

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)

0reactions
HarrySkycommented, Jul 23, 2021

You are better off using maintained async ORM like ormar. This ORM does not seem to be maintained anymore

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails: PG::NotNullViolation: ERROR: null value in column "id ...
It seems that the id should be serial so it can auto-increment. If it is, then how to convert a id column to...
Read more >
NotNullViolation: ERROR: null value in column "id" violates ...
My normal tests all went fine and gitlab was working nice. But then I tested to create a new project: PG::NotNullViolation: ERROR: null...
Read more >
NotNullViolation: ERROR: null value in column "id" violates ...
I'm getting this error whenever I try to create a feature, add an actor to an existing feature, etc. Everything is still working...
Read more >
PG::NotNullViolation: ERROR: null value in column "root_id ...
I added a subscription manifest and tried to add repositories. when clicking on the + icon of any repository, the operation to add...
Read more >
PG::NotNullViolation error on id column in PostgreSQL
Faced with this error: PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found