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

Default values need a protocol #86

Closed
zachdaniel opened this issue Apr 16, 2022 · 0 comments · Fixed by #87
Closed

Default values need a protocol #86

zachdaniel opened this issue Apr 16, 2022 · 0 comments · Fixed by #87
Labels
bug Something isn't working needs review

Comments

@zachdaniel
Copy link
Contributor

As noted in this issue: ash-project/ash#310

Our default value handling is rudimentary. What we do currently:

defp default(%{default: value, type: type}, _) do
    case Ash.Type.dump_to_native(type, value) do
      {:ok, value} when is_struct(value) ->
        to_string(value)

      {:ok, value} ->
        inspect(value)

      _ ->
        "nil"
    end
  rescue
    _ ->
      "nil"
  end

But what we need to do is add a protocol like AshPostgres.ToSql that can be implemented for various types and structs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant