From bc6965485ad9d3f08e042fd714a720007661e129 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sat, 14 Dec 2019 20:41:53 -0500 Subject: [PATCH] more straightforward usage of array_replace --- lib/philomena/tags.ex | 3 ++- lib/philomena_web/controllers/image/comment_controller.ex | 2 +- lib/philomena_web/controllers/tag/alias_controller.ex | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/philomena/tags.ex b/lib/philomena/tags.ex index 76ef6976..be319349 100644 --- a/lib/philomena/tags.ex +++ b/lib/philomena/tags.ex @@ -241,10 +241,11 @@ defmodule Philomena.Tags do set: [ { ^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([]) end diff --git a/lib/philomena_web/controllers/image/comment_controller.ex b/lib/philomena_web/controllers/image/comment_controller.ex index 0dc6f46b..8180d3c8 100644 --- a/lib/philomena_web/controllers/image/comment_controller.ex +++ b/lib/philomena_web/controllers/image/comment_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.CommentController do plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true # 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 :authorize_resource, model: Comment, only: [:show, :edit, :update], preload: [:image, user: [awards: :badge]] diff --git a/lib/philomena_web/controllers/tag/alias_controller.ex b/lib/philomena_web/controllers/tag/alias_controller.ex index 6ad40b2c..a28c02ec 100644 --- a/lib/philomena_web/controllers/tag/alias_controller.ex +++ b/lib/philomena_web/controllers/tag/alias_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Tag.AliasController do conn |> 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 def delete(conn, _params) do