reifyhealth / specmonstah

Specmonstah will eat the face off your test fixtures
MIT License
359 stars 18 forks source link

Idea for collection iteration in queries #78

Open cldwalker opened 3 years ago

cldwalker commented 3 years ago

We've had a number of repetitive queries that just iterate over one attribute e.g.

{:site-trial-patient [[1 {:refs {:site-patient-id :sp0
                                 :site-trial-id :st0
                                 :patient-source-id :ps1}}]
                      [1 {:refs {:site-patient-id :sp1
                                 :site-trial-id :st0
                                 :patient-source-id :ps1}}]
                      [1 {:refs {:site-patient-id :sp2
                                 :site-trial-id :st0
                                 :patient-source-id :ps1}}]]}

We can make these more readable with for e.g.

(vec
  (for [id [:sp0 :sp1 :sp2]]
    [1 {:refs {:site-patient-id id
        :site-trial-id :st0
        :patient-source-id :ps1}}]))

It would be helpful for this to be supported in specmonstah as it would make this easy and would allow iteration to be done in contexts where we only want to interact with specmonstah queries as edn. One idea:

[3 {:refs {:site-patient-id [:for [:sp0 :sp1 :sp2]]
           :site-trial-id :st0
           :patient-source-id :ps1}}]