juanldslv

juanldslv

Hi guys, I hope that all are good, now, Im trying to make a query into a function but when I sent the query for repo.all, this is the answer is ‘=>’ that the repo give me. does anyone know about it ? :thinking:

defp historia_clinica_medico(paciente)do

IO.inspect(Repo.all(from h in Sim.HistorialHistoriaClinica, where: h.paciente_id == ^paciente
                                                                 and not is_nil(h.historiaclinicamedico_id), select: h.historiaclinicamedico_id))

end

thank you for all advices as much as code or my poor English language

Showing Posts 1 to 6

peerreynders

peerreynders

There really isn’t enough information to give an answer. For example:

iex(1)> alias MusicDB.Track
MusicDB.Track
iex(2)> import Ecto.Query
Ecto.Query
iex(3)> album_id = 5
5
iex(4)> IO.inspect(Repo.all(from t in Track, where: t.album_id == ^album_id and not is_nil(t.id), select: t.id))

20:04:17.914 [debug] QUERY OK source="tracks" db=2.0ms
SELECT t0."id" FROM "tracks" AS t0 WHERE ((t0."album_id" = $1) AND NOT (t0."id" IS NULL)) [5]
[33, 32, 31, 30]
[33, 32, 31, 30]
iex(5)>

=> typically appears in the representation of Elixir maps where the keys aren’t atoms.

iex(5)> IO.inspect(Map.new([{"a",1},{"b",2}]))
%{"a" => 1, "b" => 2}
%{"a" => 1, "b" => 2}
iex(6)> 

juanldslv

juanldslv OP

Peerreynders may you check the controller ?
https://gist.github.com/juanldslv/e03a05244f6dc1a2c86869331f844ff8

david_ex

david_ex

This looks suspiciously like iex displaying a list of integers as charlists. Can you try the following in iex?

result = Repo.all(from h in Sim.HistorialHistoriaClinica, where: h.paciente_id == ^paciente
        and not is_nil(h.historiaclinicamedico_id), select: h.historiaclinicamedico_id)

inspect result, char_lists: :as_lists

i result

Does the result make more sense to you? If yes, you can find more information about it in the charlists section of the guide, and this issue has helpful information also.

peerreynders

peerreynders

In particular:

iex(1)> list_of_ids = [61, 62]
'=>'
iex(2)> IO.inspect(list_of_ids)
'=>'
'=>'
iex(3)> IO.inspect(list_of_ids, [charlists: :as_lists]) 
[61, 62]
'=>'
iex(4)> to_string(list_of_ids)
"=>"
iex(5)>

i.e. the query returned a list of two historiaclinicamedico_id values, 61 and 62 respectively.

juanldslv

juanldslv OP

Thank you @david_ex, that works like a charm… best regards :robot: :+1:

juanldslv

juanldslv OP

Thank you @peerreynders , that works like a charm… best regards :robot: :+1:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews