Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler error for integer_primary_key with Ets #1500

Open
brianhv opened this issue Oct 5, 2024 · 0 comments
Open

Add compiler error for integer_primary_key with Ets #1500

brianhv opened this issue Oct 5, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@brianhv
Copy link

brianhv commented Oct 5, 2024

Following up on this message in discord.

When using the ETS data layer and an integer_primary_key, rows get inserted with id: nil, and rows after the first will clobber the previous rows. In Discord it was suggested that this situation ought to be a compile time error.

Example of code with which I observed the issue:

defmodule Campdbash.Camper do
  use Ash.Resource,
    domain: Campdbash,
    data_layer: Ash.DataLayer.Ets

  actions do
    defaults [:read]

    create :register do
      accept [:first_name, :last_name]
    end
  end

  attributes do
    uuid_primary_key :id

    attribute :first_name, :string do
      allow_nil? false
    end

    attribute :last_name, :string do
      allow_nil? false
    end

  end
end

Inserted with

Campdbash.Camper |> Ash.Changeset.for_create(:register, %{first_name: "fname", last_name: "lname"}) |> Ash.create!()

Result

#Campdbash.Camper<
  __meta__: #Ecto.Schema.Metadata<:loaded>,
  id: nil,
  first_name: "fname",
  last_name: "lname",
  aggregates: %{},
  calculations: %{},
  ...
>
@brianhv brianhv added enhancement New feature or request needs review labels Oct 5, 2024
@zachdaniel zachdaniel added the good first issue Good for newcomers label Oct 6, 2024
@zachdaniel zachdaniel moved this to Someday in Ash Framework Roadmap Oct 6, 2024
@zachdaniel zachdaniel moved this from Someday to Soon in Ash Framework Roadmap Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Development

No branches or pull requests

2 participants