Given the following code:

    $storage = $this->entityTypeManager->getStorage('group_type');
    $group_type_ids = $storage->getQuery()
      ->notExists('third_party_settings.subgroup')
      ->execute();

and there being a group type that does not have any third party settings, I'd expect to get said group type's ID from the query.

Instead, I receive nothing. This is because of the following lines in Condition::matchArray()

        if (is_array($data[$key])) {
          $new_parents = $parents;
          $new_parents[] = $key;
          if ($this->matchArray($condition, $data[$key], $needs_matching, $new_parents)) {
            return TRUE;
          }
        }
        // Failing the above block leads to FALSE return value.

So unless the full parent path to the property (in this case third_party_settings) is set, matchArray() will never get to call match() where it checks the IS NULL condition.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kristiaanvandeneynde created an issue. See original summary.

kristiaanvandeneynde’s picture

Status: Active » Needs review
FileSize
1.25 KB

Not sure where this is being tested, but here's what worked for me.

Status: Needs review » Needs work

The last submitted patch, 2: drupal-3154858-2.patch, failed testing. View results

kristiaanvandeneynde’s picture

Status: Needs work » Needs review
FileSize
1.18 KB
2.17 KB

Aha, now that we know where the tests are, we can create a test-only patch and one that proves this works.
I also put the original fix one level too deep when copying the code from my local.

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

alvar0hurtad0’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

The last submitted patch, 4: drupal-3154858-4-test-only.patch, failed testing. View results

  • catch committed 87468a5 on 9.1.x
    Issue #3154858 by kristiaanvandeneynde: Drupal\Core\Config\Entity\Query\...

  • catch committed 46d094a on 9.0.x
    Issue #3154858 by kristiaanvandeneynde: Drupal\Core\Config\Entity\Query\...

  • catch committed 44918b7 on 8.9.x
    Issue #3154858 by kristiaanvandeneynde: Drupal\Core\Config\Entity\Query\...
catch’s picture

Version: 9.0.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -606,6 +606,16 @@ public function testDotted() {
       ->execute();
     $this->assertResults([]);
+    // Make sure that "IS NULL" and "IS NOT NULL" work correctly when the dotted
+    // path cannot be fully follower.
+    $this->queryResults = $this->entityStorage->getQuery()
+      ->exists('does.not.exist')

s/follower/followed/ fixed on commit to 9.1.x, backported to 8.9.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.