mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
fix: cast parent ID to bigint in SQL queries for consistency
This commit is contained in:
parent
ac32394959
commit
1585839c1e
@ -4444,7 +4444,7 @@ func (r *ProductRepository) ListGroupNodes(ctx context.Context, filter GroupList
|
||||
FROM product.catalog_category AS c
|
||||
WHERE c.node_type = 2 AND c.store_id = $1 AND c.deleted_at IS NULL
|
||||
AND ($2 = false OR c.status = 1)
|
||||
AND (($6 = 0 AND c.level = 1 AND c.parent_id IS NULL
|
||||
AND (($6::bigint = 0 AND c.level = 1 AND c.parent_id IS NULL
|
||||
AND ($3 = '' OR CASE WHEN $5 THEN LOWER(c.name) = LOWER($3)
|
||||
ELSE c.name ILIKE ('%' || $3 || '%') ESCAPE '\' END)
|
||||
AND ($4 = '' OR EXISTS (
|
||||
@ -4455,7 +4455,7 @@ WHERE c.node_type = 2 AND c.store_id = $1 AND c.deleted_at IS NULL
|
||||
AND (CASE WHEN $5 THEN LOWER(match_child.name) = LOWER($4)
|
||||
ELSE match_child.name ILIKE ('%' || $4 || '%') ESCAPE '\' END)
|
||||
)))
|
||||
OR ($6 <> 0 AND c.parent_id = $6 AND c.level = 2))`
|
||||
OR ($6::bigint <> 0 AND c.parent_id = $6::bigint AND c.level = 2))`
|
||||
args := []any{scope.StoreID, filter.OnlyVisible, firstLevelName, secondLevelName, filter.ExactMatch, parentID}
|
||||
var total int64
|
||||
if err := r.db.QueryRowContext(ctx, `SELECT COUNT(*) `+fromWhere, args...).Scan(&total); err != nil {
|
||||
@ -4511,7 +4511,7 @@ LEFT JOIN product.products AS p ON p.id = b.product_id
|
||||
AND p.deleted_at IS NULL
|
||||
WHERE c.node_type = 2 AND c.store_id = $1 AND c.deleted_at IS NULL
|
||||
AND ($2 = false OR c.status = 1)
|
||||
AND (($6 = 0 AND c.level = 1 AND c.parent_id IS NULL
|
||||
AND (($6::bigint = 0 AND c.level = 1 AND c.parent_id IS NULL
|
||||
AND ($3 = '' OR CASE WHEN $5 THEN LOWER(c.name) = LOWER($3)
|
||||
ELSE c.name ILIKE ('%' || $3 || '%') ESCAPE '\' END)
|
||||
AND ($4 = '' OR EXISTS (
|
||||
@ -4522,9 +4522,9 @@ WHERE c.node_type = 2 AND c.store_id = $1 AND c.deleted_at IS NULL
|
||||
AND (CASE WHEN $5 THEN LOWER(match_child.name) = LOWER($4)
|
||||
ELSE match_child.name ILIKE ('%' || $4 || '%') ESCAPE '\' END)
|
||||
)))
|
||||
OR ($6 <> 0 AND c.parent_id = $6 AND c.level = 2))
|
||||
OR ($6::bigint <> 0 AND c.parent_id = $6::bigint AND c.level = 2))
|
||||
GROUP BY c.id
|
||||
ORDER BY CASE WHEN $6 = 0 THEN GREATEST(c.updated_at, COALESCE((
|
||||
ORDER BY CASE WHEN $6::bigint = 0 THEN GREATEST(c.updated_at, COALESCE((
|
||||
SELECT MAX(child.updated_at) FROM product.catalog_category AS child
|
||||
WHERE child.parent_id = c.id AND child.store_id = c.store_id
|
||||
AND child.node_type = 2 AND child.level = 2 AND child.deleted_at IS NULL
|
||||
|
||||
Loading…
Reference in New Issue
Block a user