Skip to content

Ability to set primary key for associations #86

@wGEric

Description

@wGEric

From the rails api:

:primary_key
Specify the name of the column to use as the primary key for the association. By default this is id.

Right now the primary key is hard coded to id so I can't use a different column for associations. I would like to be able to do something like:

case class Group(name: String) extends ActiveRecord {
  lazy val users = hasMany[User](primaryKey = "name", foreignKey = "group_name")
}

new Group("my group name").users
// SELECT * FROM users WHERE users.group_name = 'my group name'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions