mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
DROP VIEW quantity_unit_conversions_resolved;
|
||||
|
||||
CREATE VIEW quantity_unit_conversions_resolved
|
||||
AS
|
||||
|
||||
@@ -127,7 +126,7 @@ AS (
|
||||
ON s.to_qu_id = c.from_qu_id
|
||||
AND s.product_id IS NULL
|
||||
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id) -- Do this only, if there is no product_specific conversion between the units in s
|
||||
AND c.path NOT LIKE ('%/' || s.from_qu_id || '/%')
|
||||
AND c.path NOT LIKE ('%/' || s.from_qu_id || '/%')
|
||||
|
||||
UNION
|
||||
|
||||
@@ -144,13 +143,13 @@ AS (
|
||||
ON c.to_qu_id = s.from_qu_id
|
||||
AND s.product_id IS NULL
|
||||
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id) -- Do this only, if there is no product_specific conversion between the units in s
|
||||
AND c.path NOT LIKE ('%/' || s.to_qu_id || '/%')
|
||||
AND c.path NOT LIKE ('%/' || s.to_qu_id || '/%')
|
||||
|
||||
UNION
|
||||
|
||||
-- Fourth case: Add the default unit conversions that are reachable by a given product.
|
||||
-- We cannot start with them directly, as we only want to add default conversions,
|
||||
-- where at least one of the units is 'reachable' from the product's storage quantity unit.
|
||||
-- where at least one of the units is 'reachable' from the product's stock quantity unit.
|
||||
-- Thus we add these cases here.
|
||||
SELECT DISTINCT
|
||||
1, c.product_id,
|
||||
@@ -159,7 +158,7 @@ AS (
|
||||
s.factor
|
||||
FROM closure c, conversion_factors s
|
||||
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id)
|
||||
AND c.path LIKE ('%/' || s.from_qu_id || '/' || s.to_qu_id || '/%')
|
||||
AND c.path LIKE ('%/' || s.from_qu_id || '/' || s.to_qu_id || '/%')
|
||||
)
|
||||
|
||||
SELECT DISTINCT
|
||||
|
Reference in New Issue
Block a user