Any better way to write the (fn).() thing?

All dynamic generated SQL, will not have that case.

1 Like

I suppose by dynamic generated SQL you mean generated by Ecto?

He didn’t say that his sql parameters is generated from a dynamic generated SQL. So in the general case can be any SQL. Even if it is generated by Ecto it could contain other syntax types, as this is an implementation detail of the Ecto adapter used.

On the other hand, if the sql param is generated by Ecto, then maybe there is a better way to check if it is a select rather than an update, insert, etc., by using Ecto itself, before it is transformed into an SQL statement.

Never know this usage, thanks.

I plan to use Ecto, could you advise the better way?

Yes!

This message by @josevalim on the elixir-core mailing list:

As explained in the many others pipe proposals sent to this mailing list, we don’t plan to add more complexity to the pipe operator.

Despite the suggestions of many, anonymous functions are not the solution when you can’t pipe. Well named and defined private functions are. Elixir is a functional language. So create small named functions to improve code readability.

1 Like