1

I have a site where multiple interfaces and its descriptions are listed, as seen here:

instances

Yesterday I changed the description texts from German to English using the PgAdmin Postgres console, everything worked fine and as you can see is displayed correctly.

However, as soon as I use a filter, lets say I want to filter for the "CTI-Schnittstelle" I get the right purple thing on the left saying "XY-Schnittstelle", but I always get the description of the "A1-Schnittstelle".

Here is my backend code for the filter:

 def handle_event("filter", interface, socket) do
    # i = Kernel.inspect(interface["interface"])
    i = "#{interface["interface"]}"
    IO.inspect(i)

    if String.equivalent?(i, "all") do
      data =
        from(
          c in OranAttack,
          order_by: ^sort(interface)
        )
        |> Repo.paginate()
        IO.inspect(data)

      {
        :noreply,
        assign(socket, data: data)
      }
    else
      data =
        from(
          c in OranAttack,
          where: c.interface == ^i
        )
        |> Repo.paginate()

      IO.inspect("##########")
      IO.inspect(data)

      {
        :noreply,
        assign(socket, data: data)
      }
    end

  end

As you can see I let it print the data to the console, and the weird thing is I get the correct data, so I get the correct description of the interface the user filtered for. This then also gets sent to the frontend, but there somehow the description of the alphabetical first interface appears.

Any help appreciated!

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
Frevelman
  • 338
  • 3
  • 11
  • Your question might yield better answers if you simplified it (and your code) -- as written, it's hard to follow. Can you restructure this so it deals with only the filtering or only the database query? Perhaps you can move the data-fetching component to its own private function. – Everett May 16 '22 at 11:52
  • So did you check the queries produced by Ecto? Are those what you'd expect? If yes, and you're still getting unexpected data back, the way that comparisons are made can be influenced by the underlying collation of your database (although a bit unlikely - most probably some parameter passed in the query has an unexpected value, or some logic in the presentation code misbehaves) – bottlenecked May 24 '22 at 09:29

0 Answers0