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

Compilation warnings if Permit.Phoenix.LiveView is used with permit_ecto #20

Open
dgigafox opened this issue Sep 24, 2024 · 0 comments · May be fixed by #21
Open

Compilation warnings if Permit.Phoenix.LiveView is used with permit_ecto #20

dgigafox opened this issue Sep 24, 2024 · 0 comments · May be fixed by #21

Comments

@dgigafox
Copy link

dgigafox commented Sep 24, 2024

Getting these 2 warnings when using Permit.Phoenix.LiveView with permit_ecto
warning: got "@impl true" for function base_query/1 but no behaviour specifies such callback
warning: got "@impl true" for function finalize_query/2 but no behaviour specifies such callback

The probable cause is that these callbacks aren't inserted during compile time because they're not wrapped in a quote function

if :ok == Application.ensure_loaded(:permit_ecto) do
    @callback base_query(Types.resolution_context()) :: Ecto.Query.t()
    @callback finalize_query(Ecto.Query.t(), Types.resolution_context()) :: Ecto.Query.t()
  end

and these optional callbacks as well

@optional_callbacks [
                        if(:ok == Application.ensure_loaded(:permit_ecto),
                          do: {:base_query, 1}
                        ),
                        if(:ok == Application.ensure_loaded(:permit_ecto),
                          do: {:finalize_query, 2}
                        ),
                        handle_unauthorized: 2,
                        preload_actions: 0,
                        fallback_path: 2,
                        resource_module: 0,
                        except: 0,
                        loader: 1,
                        id_param_name: 2,
                        id_struct_field_name: 2,
                        handle_not_found: 1,
                        unauthorized_message: 2
                      ]
                      |> Enum.filter(& &1)

Which can be checked when running behaviour_info/1 after compilation.

iex(1)> Permit.Phoenix.LiveView.behaviour_info(:callbacks)
[
  unauthorized_message: 2,
  resource_module: 0,
  preload_actions: 0,
  loader: 1,
  id_struct_field_name: 2,
  id_param_name: 2,
  handle_unauthorized: 2,
  handle_not_found: 1,
  fetch_subject: 2,
  fallback_path: 2,
  except: 0,
  event_mapping: 0,
  authorization_module: 0
]
iex(2)> Permit.Phoenix.LiveView.behaviour_info(:optional_callbacks)
[
  unauthorized_message: 2,
  resource_module: 0,
  preload_actions: 0,
  loader: 1,
  id_struct_field_name: 2,
  id_param_name: 2,
  handle_unauthorized: 2,
  handle_not_found: 1,
  fallback_path: 2,
  except: 0
]
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

Successfully merging a pull request may close this issue.

1 participant