Skip to content

Inconsistency with View Code editor vs Query #9720

@spageRDG

Description

@spageRDG

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';
Image
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;
Image

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

Image

Desktop (please complete the following information):

Image

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions