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

Calling phx.mix.gen without specifying attributes will succeed but create broken code #5870

Closed
ponychicken opened this issue Jul 17, 2024 · 1 comment

Comments

@ponychicken
Copy link
Contributor

Environment

  • Elixir version (elixir -v): 1.16
  • Phoenix version (mix deps): 1.7.14

Actual behavior

Call mix gen.live without adding attributes:

mix phx.gen.live FailingStuff Fail fails
Returns with 0

But the code will fail since in the table there are no columns added.

key :col not found in: %{
  id: "fails",
  rows: %Phoenix.LiveView.LiveStream{
    name: :fails,
    dom_id: #Function<3.112696910/1 in Phoenix.LiveView.LiveStream.new/4>,
    ref: "0",
    inserts: [],
    deletes: [],
    reset?: false,
    consumable?: false
  },
  action: [
    %{
      __slot__: :action,
      inner_block: #Function<5.105895959/2 in TestWeb.FailLive.Index.render/1>
    },
    %{
      __slot__: :action,
      inner_block: #Function<6.105895959/2 in TestWeb.FailLive.Index.render/1>
    }
  ],
  __changed__: nil,
  inner_block: [
    %{
      __slot__: :inner_block,
      inner_block: #Function<4.105895959/2 in TestWeb.FailLive.Index.render/1>
    }
  ],
  row_click: #Function<3.105895959/1 in TestWeb.FailLive.Index.render/1>,
  __given__: %{
    id: "fails",
    rows: %Phoenix.LiveView.LiveStream{
      name: :fails,
      dom_id: #Function<3.112696910/1 in Phoenix.LiveView.LiveStream.new/4>,
      ref: "0",
      inserts: [],
      deletes: [],
      reset?: false,
      consumable?: false
    },
    action: [
      %{
        __slot__: :action,
        inner_block: #Function<5.105895959/2 in TestWeb.FailLive.Index.render/1>
      },
      %{
        __slot__: :action,
        inner_block: #Function<6.105895959/2 in TestWeb.FailLive.Index.render/1>
      }
    ],
    __changed__: nil,
    inner_block: [
      %{
        __slot__: :inner_block,
        inner_block: #Function<4.105895959/2 in TestWeb.FailLive.Index.render/1>
      }
    ],
    row_click: #Function<3.105895959/1 in TestWeb.FailLive.Index.render/1>
  },
  row_id: #Function<20.21712682/1 in TestWeb.CoreComponents."table (overridable 1)"/1>,
  row_item: &Function.identity/1
}

Expected behavior

The invocation should fail.

@josevalim
Copy link
Member

Dupe of #5714.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants