script
Split output in multiple lines in doc test
I have read doc test documentation. And apply it in my project but I couldn’t figure this out.
If my output is very long like a query then How can i split it on multiple line .
iex> query_opts = %{
...> "$select" => %{"$fields" => ["name", "designation", "experience_years"]},
...> "$where" => %{"designation" => %{"$ilike" => "%surge %"}},
...> "$order" => %{"rating" => "$asc"}
...> }
iex> #{FatEcto.FatQuery}.build(FatEcto.FatDoctor, query_opts)
#Ecto.Query<from f in FatEcto.FatDoctor, where: ilike(fragment("(?)::TEXT", f.designation), ^"%surge %") and ^true, order_by: [asc: f.rating], select: map(f, [:name, :designation, :experience_years])>
this works and test passes but i would like the result like this:
#Ecto.Query<from f in FatEcto.FatDoctor, where: ilike(fragment("(?)::TEXT", f.designation), ^"%surge %")
and ^true,
order_by: [asc: f.rating],
select: map(f, [:name, :designation, :experience_years])>
It fails because I am using line break and the result of this function using spaces:
left: "#Ecto.Query<from f in FatEcto.FatDoctor, where: ilike(fragment(\"(?)::TEXT\", f.designation),
^\"%surge %\") and ^true, order_by: [asc: f.rating], select: map(f, [:name, :designation,
:experience_years])>"
right: "#Ecto.Query<from f in FatEcto.FatDoctor, where: ilike(fragment(\"(?)::TEXT\", f.designation),
^\"%surge %\")\nand ^true,\norder_by: [asc: f.rating],\nselect: map(f, [:name, :designation,
:experience_years])>"
Is there any workaround?
Thanks
Marked As Solved
josevalim
Creator of Elixir
Unfortunately that is not possible when you are matching on the printed value, which is exactly what you are doing by matching on #Ecto.Query. I don’t think there is a fix in this case, sorry! 
2
Popular in Questions
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Other popular topics
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New








