Skip to content

unable to get records if the table primary key is not id #9

@teknofire

Description

@teknofire

I'm unable to fetch records from my legacy database when the primary_key has been changed.

It looks like the default method for fetching the records when using ActiveRecord is hardcoded to with "id" as the primary key field, and will fail to fetch records even if the models primary_key attribute has been set.

Example:

class Site < ActiveRecord::Base
    self.primary_key = 'siteid'
end

response = Site.search('Test')
response.records.first
# Fails with the following error -> ERROR:  column sites.id does not exist
# should be trying to use sites.siteid

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions