Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!.Any() regression #3439

Open
AlexSikilinda opened this issue Sep 24, 2024 · 1 comment
Open

!.Any() regression #3439

AlexSikilinda opened this issue Sep 24, 2024 · 1 comment

Comments

@AlexSikilinda
Copy link

It seems like Marten is generating an incorrect SQL for scenarios when we want to check if a nested collection is empty, e.g.:

session.Query<MyDocument>().Where(doc => !doc.NestedCollection.Any());

will produce something like

  select d.id, d.data, d.mt_version 
  from public.mt_doc_mydocument as d 
  where d.data @? '$ ? (@.NestedCollection[*] == null || @.NestedCollection[*].size() == 0)' 

If the collection is empty ("NestedCollection":[]), the second part will be always false which is caused by applying [*] to the collection, so
@.NestedCollection[*].size() == 0 is false, but @.NestedCollection.size() == 0 seems to work fine.

I believe the issue was introduced with this change in CollectionIsEmpty:
image

@jeremydmiller
Copy link
Member

@AlexSikilinda Since you're already deep into that, would you mind just doing the pull request to address it?

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

No branches or pull requests

2 participants