more straightforward usage of array_replace

This commit is contained in:
byte[] 2019-12-14 20:41:53 -05:00
parent b62a723efe
commit bc6965485a
3 changed files with 4 additions and 3 deletions

View file

@ -241,10 +241,11 @@ defmodule Philomena.Tags do
set: [ set: [
{ {
^column, ^column,
fragment("ARRAY(SELECT DISTINCT unnest(array_replace(?, ?, ?)) ORDER BY 1)", field(q, ^column), ^old_value, ^new_value) fragment("array_replace(?, ?, ?)", field(q, ^column), ^old_value, ^new_value)
} }
] ]
) )
|> IO.inspect()
|> Repo.update_all([]) |> Repo.update_all([])
end end

View file

@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.CommentController do
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
# Undo the previous private parameter screwery # Undo the previous private parameter screwery
plug PhilomenaWeb.LoadCommentPlug, [param: "id"] when action in [:edit, :update] plug PhilomenaWeb.LoadCommentPlug, [param: "id"] when action in [:show, :edit, :update]
plug PhilomenaWeb.CanaryMapPlug, create: :create, edit: :edit, update: :edit plug PhilomenaWeb.CanaryMapPlug, create: :create, edit: :edit, update: :edit
plug :authorize_resource, model: Comment, only: [:show, :edit, :update], preload: [:image, user: [awards: :badge]] plug :authorize_resource, model: Comment, only: [:show, :edit, :update], preload: [:image, user: [awards: :badge]]

View file

@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Tag.AliasController do
conn conn
|> put_flash(:info, "Tag alias queued.") |> put_flash(:info, "Tag alias queued.")
|> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag)) |> redirect(to: Routes.tag_alias_path(conn, :edit, conn.assigns.tag))
end end
def delete(conn, _params) do def delete(conn, _params) do