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!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Other popular topics
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
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
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
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









