Skip to content

Getting primary key with RETURNING INTO doesn't work in Rails 7 and later #2468

@cmcfadden

Description

@cmcfadden

We're updating a Rails 6.1 application to 7.1. We're running into an issue with a table that has a trigger to generate a primary key on insert, which should be populated back into the model using RETURNING INTO.

We're finding that that's not working, due to the checks for the primary key type in sql_for_insert.

Our model defines primary key as:
self.primary_key = :rid

By the time the sql_for_insert method is invoked though, pk is of type String, so this code never inserts the RETURNING INTO sql.

It seems like this was a change (the check for pk being a string) introduced with the move to 7, but I can't find incidents of other people encountering an issue here. Anyone have thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions