koudelka / honeydew

Job Queue for Elixir. Clustered or Local. Straight BEAM. Optional Ecto. 💪🍈
MIT License
724 stars 59 forks source link

Composite primary keys #79

Closed danschultzer closed 5 years ago

danschultzer commented 5 years ago

Honeydew expects just a single primary key, and it's not possible to use composite primary keys, like this:

defmodule HelloPhoenix.Player do
  use HelloPhoenix.Web, :model

  @primary_key false
  schema "players" do
    field :first_name, :string, primary_key: true
    field :last_name, :string, primary_key: true
    field :position, :string
    field :number, :integer
  . . .

I was going to take a stab at a PR, but the ecto integration test is also the example so not sure where to fit a test for composite primary keys.

It also looks like honeydew expects the primary key to be called :id rather than fetching the primary key column name here:

https://github.com/koudelka/honeydew/blob/37937231d9272d35a8bee6fe5676e49710de13fb/lib/honeydew/sources/ecto_source.ex#L194

koudelka commented 5 years ago

Hey @danschultzer,

I've implemented support for compound primary keys over in #80, wanna give it a spin and let me know how it goes?

The argument handed to your job's function is a keyword list of primary key name/value pairs suitable for passing directly to your repository's get_by/2 function. You can check that out here: https://github.com/koudelka/honeydew/pull/80/files#diff-cddf918b896c90d0060392b52f0edfa5R7

:)

danschultzer commented 5 years ago

Looks great! Thanks for the quick turnaround, it works flawlessly 😄

koudelka commented 5 years ago

v1.4.3 published to hex, let me know if you encounter any issues with it. :)