Hello everyone,
This past weekend we have released Ecto v2.1.0-rc.5, hopefully the last release candidate for Ecto v2.1: https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md
If you were using “or_where/or_having” from previous RCs, note “or_where: ^keywords” changed behaviour in this last RC.
We have also released Postgrex 0.13-rc which includes a new API for extensions that is about 40% faster when running Postgrex queries.
16 Likes
Thank you very much for this, @josevalim!
I’ve noticed that you haven’t got a git tag for this version, which breaks the links from hexdocs. Just a heads-up!
1 Like
Question regarding dynamic expressions, don’t get how they work nor why do we need them. from changelog:
dynamic = false
dynamic =
if params["is_public"] do
dynamic([p], p.is_public or ^dynamic)
else
dynamic
end
isn’t it means false([p], p.is_public or ^false)
. o_O
Regular non-dynamic code looks like
q = Post
q =
if params["is_public"] do
q |> where([p], p.is_public)
else
q
end
@thousandsofthem imagine you need to go through a bunch of parameters in no particular order. For such, you ned to start with an initial value (in this case, false) and compose them arbitrarily until it is interpolated. The Ecto book also contains examples of where to use dynamic.
Thanks.
Still, false(..)
looks counterintuitive, it feels wrong that i can apply ()
to boolean value
(i.e. dynamic = false; dynamic = dynamic(...)
)
Echoing @thousandsofthem, I’m inclined to think that there are two different semantics of dynamic
in that snippet: one is a value (initialized as false
and gets updated with the ifs) and another is a function/macro. Is that right?
Hrm, not quite. I will work on better examples.