-
Notifications
You must be signed in to change notification settings - Fork 834
Description
Describe the bug
Trying to modify the view in the Code Editor and the editor will not allow the view update to happen, however placing the exact same code in a query window will allow the view to be updated.
To Reproduce
Old View:
COALESCE((pr.sell_price - pr.base_price) / pr.sell_price * pr.quantity * 100::numeric, 0::numeric) AS extended_margin
New View:
COALESCE((pr.sell_price - pr.base_price)::numeric / NULLIF(pr.sell_price::numeric,0) * pr.quantity * 100::numeric, 0::numeric)::numeric AS extended_margin
I thought it was perhaps a data type issue, however PG is reporting the same types:
SELECT
column_name,
data_type,
numeric_precision,
numeric_scale
FROM information_schema.columns
WHERE table_schema = 'procurement'
AND table_name = 'view_products'
AND column_name = 'extended_margin';
SELECT pg_typeof(
COALESCE(
(pr.sell_price - pr.base_price)::numeric
/ NULLIF(pr.sell_price::numeric, 0)
* pr.quantity
* 100::numeric,
0::numeric
)::numeric
)
FROM schema.products pr
LIMIT 1;
Also the column is the last column on the view.
Expected behavior
The View editor would allow the change just the same as the 'CREATE OR REPLACE VIEW' used in the query editor would.
Error message
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.