dbeaver / dbeaver

Free universal database tool and SQL client
https://dbeaver.io
Apache License 2.0
39.25k stars 3.4k forks source link

Double quoted identifiers are colored with wrong color (data type color) #35049

Open ask9 opened 1 month ago

ask9 commented 1 month ago

Description

Set color in Preferences to some noticeable, for example, pink.

изображение

Use this code:

-- DROP FUNCTION public.get_customer_balance(int4, timestamp);

CREATE OR REPLACE FUNCTION public."Get_customer_balance1"("P_customer_id" integer, "P_effective_date" timestamp without time zone)
 RETURNS numeric
 LANGUAGE plpgsql
AS $function$
       --#OK, WE NEED TO CALCULATE THE CURRENT BALANCE GIVEN A CUSTOMER_ID AND A DATE
       --#THAT WE WANT THE BALANCE TO BE EFFECTIVE FOR. THE BALANCE IS:
       --#   1) RENTAL FEES FOR ALL PREVIOUS RENTALS
       --#   2) ONE DOLLAR FOR EVERY DAY THE PREVIOUS RENTALS ARE OVERDUE
       --#   3) IF A FILM IS MORE THAN RENTAL_DURATION * 2 OVERDUE, CHARGE THE REPLACEMENT_COST
       --#   4) SUBTRACT ALL PAYMENTS MADE BEFORE THE DATE SPECIFIED
DECLARE
    "V_rentfees" DECIMAL(5,2); --#FEES PAID TO RENT THE VIDEOS INITIALLY
    "V_overfees" INTEGER;      --#LATE FEES FOR PRIOR RENTALS
    "V_payments" DECIMAL(5,2); --#SUM OF PAYMENTS MADE PREVIOUSLY
BEGIN
    SELECT COALESCE(SUM("Film"."Rental_rate"),0) INTO "V_rentfees"
    FROM "Film", "Inventory", "Rental"
    WHERE "Film"."Film_id" = "Inventory"."Film_id"
      AND "Inventory"."Inventory_id" = "Rental"."Inventory_id"
      AND "Rental"."Rental_date" <= "P_effective_date"
      AND "Rental"."Customer_id" = "P_customer_id";

    SELECT COALESCE(SUM(IF(("Rental"."Return_date" - "Rental"."Rental_date") > ("Film.Rental_duration" * '1 day'::interval),
        (("Rental"."Return_date" - "Rental"."Rental_date") - ("Film"."rental_duration" * '1 day'::interval)),0)),0) INTO "V_overfees"
    FROM "Rental", "Inventory", "Film"
    WHERE "Film"."Film_id" = "Inventory"."Film_id"
      AND "Inventory"."Inventory_id" = "Rental.Inventory_id"
      AND "Rental"."Rental_date" <= "P_effective_date"
      AND "Rental"."Customer_id" = "P_customer_id";

    SELECT COALESCE(SUM("Payment"."Amount"),0) INTO "V_payments"
    FROM "Payment"
    WHERE "Payment"."Payment_date" <= "P_effective_date"
    AND "Payment"."Customer_id" = "P_customer_id";

    RETURN "V_rentfees" + "V_overfees" - "V_payments";
END
$function$
;

Here is a result:

изображение

DBeaver Version

Community Edition 24.1.4.202407250946

Operating System

Windows 10

Database and driver

PostgreSQL 16 PostgreSQL JDBC Driver 42.7.2

Steps to reproduce

No response

Additional context

No response

uslss commented 1 month ago

thank you for the report

ask9 commented 3 weeks ago

please also check this weird behavior:

CREATE OR REPLACE VIEW public."HelloWorld"
AS SELECT 
    "Id",
    "Name",
    "Value",
    "Column2",
    "Column3",
    "Column4",
    "Column5",
    "Column6"
   FROM "SomeTable";

изображение