liquid_feedback_core

diff core.sql @ 517:e4f619e87664

Fixed accidental PostgreSQL 9.5 dependency (because of UPSERT aka ON CONFLICT clause)
author jbe
date Sat Apr 30 17:03:48 2016 +0200 (2016-04-30)
parents ab05fb3bf974
children 003b4cc8e9ef 053190248598
line diff
     1.1 --- a/core.sql	Sun Apr 24 21:30:22 2016 +0200
     1.2 +++ b/core.sql	Sat Apr 30 17:03:48 2016 +0200
     1.3 @@ -7,7 +7,7 @@
     1.4  BEGIN;
     1.5  
     1.6  CREATE VIEW "liquid_feedback_version" AS
     1.7 -  SELECT * FROM (VALUES ('3.2.0', 3, 2, 0))
     1.8 +  SELECT * FROM (VALUES ('3.2.1', 3, 2, 1))
     1.9    AS "subquery"("string", "major", "minor", "revision");
    1.10  
    1.11  
    1.12 @@ -3257,6 +3257,18 @@
    1.13          SELECT "id" INTO "last_suggestion_id_v" FROM "suggestion"
    1.14            WHERE "suggestion"."initiative_id" = "result_row"."initiative_id"
    1.15            ORDER BY "id" DESC LIMIT 1;
    1.16 +        /* compatibility with PostgreSQL 9.1 */
    1.17 +        DELETE FROM "notification_initiative_sent"
    1.18 +          WHERE "member_id" = "recipient_id_p"
    1.19 +          AND "initiative_id" = "result_row"."initiative_id";
    1.20 +        INSERT INTO "notification_initiative_sent"
    1.21 +          ("member_id", "initiative_id", "last_draft_id", "last_suggestion_id")
    1.22 +          VALUES (
    1.23 +            "recipient_id_p",
    1.24 +            "result_row"."initiative_id",
    1.25 +            "last_draft_id_v",
    1.26 +            "last_suggestion_id_v" );
    1.27 +        /* TODO: use alternative code below, requires PostgreSQL 9.5 or higher
    1.28          INSERT INTO "notification_initiative_sent"
    1.29            ("member_id", "initiative_id", "last_draft_id", "last_suggestion_id")
    1.30            VALUES (
    1.31 @@ -3265,16 +3277,9 @@
    1.32              "last_draft_id_v",
    1.33              "last_suggestion_id_v" )
    1.34            ON CONFLICT ("member_id", "initiative_id") DO UPDATE SET
    1.35 -            "last_draft_id" = CASE
    1.36 -              WHEN "notification_initiative_sent"."last_draft_id" > "last_draft_id_v"
    1.37 -              THEN "notification_initiative_sent"."last_draft_id"
    1.38 -              ELSE "last_draft_id_v"
    1.39 -            END,
    1.40 -            "last_suggestion_id" = CASE
    1.41 -              WHEN "notification_initiative_sent"."last_suggestion_id" > "last_suggestion_id_v"
    1.42 -              THEN "notification_initiative_sent"."last_suggestion_id"
    1.43 -              ELSE "last_suggestion_id_v"
    1.44 -            END;
    1.45 +            "last_draft_id" = "last_draft_id_v",
    1.46 +            "last_suggestion_id" = "last_suggestion_id_v";
    1.47 +        */
    1.48          RETURN NEXT "result_row";
    1.49        END LOOP;
    1.50        DELETE FROM "notification_initiative_sent"

Impressum / About Us