-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Flop.Phoenix.table
breaks with date filter and flop 0.21.0
#282
Comments
I changed the phoenix route helper to a path using Phoenix VerifiedRoutes and that seems to work 🤔. |
That's interesting. We've moved everything to verified routes a while ago, so I guess I didn't notice because of that. Does this fix the issue for you? If so, I'll keep the issue open, but regard it as low priority. |
In the two instances where it caused issues I now used the new verified routes. But since we still haven't migrated at all to the verified routes, it is currently a bit weird. The issue appeared also in other places where we would call I wonder if an easy fix would be to always call If you think that solution is viable then I can also prepare a PR :) |
I'm actually the same error with verified routes just with: ~p"/page?#{[d: ~D[2000-01-01]]}" So I don't know why the error disappeared for you after switching to verified routes. I'm not sure about converting everything into a string in defimpl Phoenix.Param, for: Date do
def to_param(%Date{} = d), do: to_string(d)
end
defimpl Phoenix.Param, for: DateTime do
def to_param(%DateTime{} = dt), do: to_string(dt)
end
defimpl Phoenix.Param, for: Time do
def to_param(%Time{} = t), do: to_string(t)
end I'll update the changelog accordingly and add a note somewhere in the docs. |
Hey @woylie,
I am trying to update our code to flop >= 0.21.0 and we have a simple date filter on a schema with a
date
column.As soon as I have a filter value for the date filter our
Flop.Phoenix.table/1
call breaks on thepath
helper when rendering thesorting column paths with errors like this:
The underlying
Flop
struct looks like described in the upgrade guide:But our Phoenix route helper breaks with the input it gets when building the path somewhere in build_path/3, since
Phoenix.Param
is not implemented by default onDate
s.From the description in the upgrade guide the requirement is just implementing
to_string
, which is implemented forDate
.What am I missing? Is it expected that we implement
Phoenix.Param
for things likeDate
andDateTime
?For reference the schema looks like this:
TY in advance 💚
Andi
The text was updated successfully, but these errors were encountered: