Skip to content

ON CONFLICT DO NOTHING behaviour assumes existence of an 'id' field #40

@PeterJCLaw

Description

@PeterJCLaw

Thanks for this package, it looks like it could be very useful!

I've hit an issue with the DO NOTHING handling -- it assumes that a field called id exists on the model, though this isn't always the case.

class Foo(PostgresModel):
    user = models.OneToOneField(User, primary_key=True)

This results in a table with a primary key field called user_id,

It looks like the error stems from the way that the returning data is captured in the compilers' _rewrite_insert_nothing method which uses a literal id in the query construction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions