From 11e235b429f65a07f5b67013ea95bda7159c0658 Mon Sep 17 00:00:00 2001 From: "hello@lv" <2256334253@qq.com> Date: Wed, 8 May 2024 23:08:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=87=BA=E5=85=A5=E5=BA=93=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=A7=86=E5=9B=BE=20(#936)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lyx <2027667395@qq.com> Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/936 Reviewed-by: sealday Co-authored-by: hello@lv <2256334253@qq.com> Co-committed-by: hello@lv <2256334253@qq.com> --- .../src/server/sqls/view_records_contracts.sql | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/plugins/@hera/plugin-rental/src/server/sqls/view_records_contracts.sql b/packages/plugins/@hera/plugin-rental/src/server/sqls/view_records_contracts.sql index 81d130b77..baa7e400b 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/sqls/view_records_contracts.sql +++ b/packages/plugins/@hera/plugin-rental/src/server/sqls/view_records_contracts.sql @@ -24,13 +24,15 @@ FROM ELSE r.in_stock_id END ) +WHERE + r.direct_record_id IS NULL UNION ALL SELECT NULL AS contract_id, r.id AS record_id, r."createdAt", r."updatedAt", - CAST('r_' || r.id AS VARCHAR) AS id, + CAST('r_' || r.id || '_' || c.id AS VARCHAR) AS id, NULL AS rc_id, ( CASE @@ -49,12 +51,17 @@ FROM JOIN project p ON p.id = r.in_stock_id JOIN project p2 ON p2.id = r.out_stock_id JOIN company c ON c.roles @> '["associated"]' - AND c.id = p.company_id - OR c.id = p2.company_id + AND ( + c.id = p.company_id + OR c.id = p2.company_id + ) JOIN project p3 ON p3.company_id = c.id - AND p3.id = p.id - OR p3.id = p2.id + AND ( + p3.id = p.id + OR p3.id = p2.id + ) WHERE rc.id IS NULL AND r.in_stock_id IS NOT NULL AND r.out_stock_id IS NOT NULL + AND r.direct_record_id IS NULL