Optimized barcode concatenation handling

This commit is contained in:
Bernd Bestel
2020-12-20 16:00:14 +01:00
parent 3fb55b706b
commit df7653f4e5
3 changed files with 25 additions and 18 deletions

View File

@@ -1,6 +1,18 @@
ALTER TABLE product_barcodes
ADD note TEXT;
CREATE VIEW product_barcodes_comma_separated
AS
SELECT
pb.id, -- Dummy, LessQL needs an id column
pb.product_id,
GROUP_CONCAT(pb.barcode) AS barcodes
FROM product_barcodes pb
JOIN products p
ON pb.product_id = p.id
WHERE p.active = 1
GROUP BY pb.product_id;
CREATE VIEW uihelper_shopping_list
AS
SELECT
@@ -11,7 +23,8 @@ SELECT
st.name AS default_shopping_location_name,
qu.name AS qu_name,
qu.name_plural AS qu_name_plural,
pg.name AS product_group_name
pg.name AS product_group_name,
pbcs.barcodes AS product_barcodes
FROM shopping_list sl
LEFT JOIN products p
ON sl.product_id = p.id
@@ -26,4 +39,6 @@ LEFT JOIN shopping_locations st
LEFT JOIN quantity_units qu
ON sl.qu_id = qu.id
LEFT JOIN product_groups pg
ON p.product_group_id = pg.id;
ON p.product_group_id = pg.id
LEFT JOIN product_barcodes_comma_separated pbcs
ON sl.product_id = pbcs.product_id;