Aidbox/Issues

Support for debugging dsql queries

Opened this issue · 2 comments

Problem I need to solve

We can't debug dsql queries through the Aidbox console. We are working on zen project where we write a lot of dsql queries.

Solution I see

Add an option in the Aidbox console to allow the user to debug dsql queries.

Urgency: urgent

Example:

(lisp/sql {:select [:#>> :resource [:id]]
            :from :CareTeam
            :where [:and
                    [:=
                     [:#>> :resource [:subject :id]]
                     (lisp/sql
                      {:select [:#>> :resource [:subject :id]]
                       :from :Encounter
                       :where [:= :id (lisp/get-in [:params :encounter-id])]})]
                    [:=
                     [:#>> :resource [:status]]
                     "active"]]})

I see warning:
Screenshot 2022-10-14 at 15 07 35

And I can't understand what should I fix to make this request work.
I would like to be able to execute this expression step by step to trace the error.

Screenshot 2022-10-14 at 15 09 38

qdzo commented

You are stying to use lisp/sql in DB console. But it only appropriate for using SQL/PLSQL code

Try using our RPC to call lisp/sql (in REST console)

POST /rpc
content-type: application/yaml

method: lisp/eval-lisp
params:
  data: <put your launch-ctx here as json/yaml obj>
  expr: '(lisp/sql {:select [:#>> :resource [:id]]
            :from :CareTeam
            :where [:and
                    [:=
                     [:#>> :resource [:subject :id]]
                     (lisp/sql
                      {:select [:#>> :resource [:subject :id]]
                       :from :Encounter
                       :where [:= :id (lisp/get-in [:params :encounter-id])]})]
                    [:=
                     [:#>> :resource [:status]]
                     "active"]]})'

Don't forget to wrap expression in quotes