ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 5.13.0
    • Affects Version/s: None
    • None
    • 3
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      That {{ whereHas }} queries are now supported on embedded relations. Add a disclaimer that this does not include hybrid relations.

      2. Would you like the user to see examples of the syntax and/or executable code and its output?

      Yes please. There's test cases included in the PR that can work.

      3. Which versions of the driver/connector does this apply to?

      >= 5.13.0

      Show
      1. What would you like to communicate to the user about this feature? That {{ whereHas }} queries are now supported on embedded relations. Add a disclaimer that this does not include hybrid relations. 2. Would you like the user to see examples of the syntax and/or executable code and its output? Yes please. There's test cases included in the PR that can work. 3. Which versions of the driver/connector does this apply to? >= 5.13.0
    • None
    • None
    • None
    • None
    • None
    • None

      GitHub issues:

      has(), whereHas(), doesntHave() and whereDoesntHave() have never worked on embedsOne and embedsMany relations. Every document model is routed to addHybridHas(), which queries the related collection; embedded documents have none, and assertHybridRelationSupported() now rejects them with a misleading "not supported for hybrid query constraints" error. #1430 was closed as won't fix in 2018, while the docs' Feature Compatibility page marks "Querying Relations" as supported.

      Fix (branch embedded-where-has): match the embedded documents inside the parent document.

      • EmbedsMany: $elemMatch with the compiled constraints, or field.0 $exists without constraints.
      • EmbedsOne: the constraints prefixed with the field name, with $and/$or/$nor handled recursively, combined with $type: object. Other top-level operators such as $expr throw.
      • Counts (has('addresses', '>=', 2)) on EmbedsMany without constraints use $expr with $size.

      Remaining limitation: a count with constraints throws, as find syntax cannot drive the $filter expression it needs. It can be supported with a RelationLookup self-lookup once the Filament bridge (#3663) lands.

              Assignee:
              Pauline Vos
              Reporter:
              Pauline Vos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: