Skip to content

Conversation

laurenceisla
Copy link
Member

@laurenceisla laurenceisla commented Apr 13, 2025

Implement related AND/OR according to #2563 (comment)

  • Related conditions as query parameters embed(col)=eq.val.
  • Related conditions inside OR/AND or=(embed1(col1).eq.val1,embed2(col2).eq.val2)
  • Tests
  • Docs
  • Refactor

Comment on lines 382 to 451
context "related conditions using the embed(column) syntax" $ do
it "can do an or across embeds" $
get "/client?select=*,clientinfo(),contact()&or=(clientinfo(other).like.*Main*,contact(name).like.*Tabby*)" `shouldRespondWith`
[json|[
{"id":1,"name":"Walmart"},
{"id":2,"name":"Target"}
]|]
{ matchStatus = 200
, matchHeaders = [matchContentTypeJson]
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently working for the simplest case, e.g. (didn't use empty embeds to illustrate):

curl 'localhost:3000/client?select=*,clientinfo(other),contact(name)&or=(clie
ntinfo(other).like.*Main*,contact(name).like.*Tabby*)'

Gives the same result as:

curl 'localhost:3000/client?select=*,clientinfo(other),contact(name)&clientin
fo.other=like.*Main*&contact.name=like.*Tabby*&or=(clientinfo.not.is.null,contact.not.is.null)'
[
 {"id":1, "name":"Walmart", "clientinfo":[{"other": "123 Main St"}], "contact":[]},
 {"id":2, "name":"Target", "clientinfo":[], "contact":[{"name": "Tabby Targo"}]}
]

There are other possible cases that need to be considered. One of those is how to use this syntax to filter nested relationships #3726 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant