From 0df69dc59cc64f1823c7f8f297173a8e7811a69f Mon Sep 17 00:00:00 2001 From: Valentin Kuznetsov Date: Sun, 2 Jun 2024 08:11:16 -0400 Subject: [PATCH] Fix child look-up --- dbs/children.go | 5 +++++ static/sql/select_child.sql | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 static/sql/select_child.sql diff --git a/dbs/children.go b/dbs/children.go index 6b47079..2431495 100644 --- a/dbs/children.go +++ b/dbs/children.go @@ -19,6 +19,11 @@ func (a *API) GetChild() error { if err != nil { return Error(err, LoadErrorCode, "", "dbs.children.GetChild") } + if val, ok := a.Params["did"]; ok { + if val != "" { + conds, args = AddParam("did", "PDS.did", a.Params, conds, args) + } + } stm = WhereClause(stm, conds) diff --git a/static/sql/select_child.sql b/static/sql/select_child.sql new file mode 100644 index 0000000..5ee3dab --- /dev/null +++ b/static/sql/select_child.sql @@ -0,0 +1,6 @@ +SELECT + D.did CHILD_DID, + PDS.did +FROM DATASETS D +LEFT OUTER JOIN PARENTS DSP ON DSP.DATASET_ID = D.DATASET_ID +LEFT OUTER JOIN DATASETS PDS ON PDS.DATASET_ID = DSP.PARENT_ID