Problem/Motivation

The documentation for \Drupal\Core\Database\Query\ConditionInterface::condition seems to be incorrect especially for EXISTS queries

Proposed resolution

Fix documentation

Remaining tasks

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin created an issue. See original summary.

pwolanin’s picture

Priority: Normal » Minor
Status: Active » Needs review
FileSize
1.39 KB

Based on reading the code, I think this makes it more accurate.

Chi’s picture

Status: Needs review » Reviewed & tested by the community

Seems like the parameters should be ignored in a different way. $value parameter expects NULL value while $field accepts empty string. Is there something special about this?

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...

/**
 * {@inheritdoc}
 */
public function isNull($field) {
  return $this->condition($field, NULL, 'IS NULL');
}

/**
 * {@inheritdoc}
 */
public function isNotNull($field) {
  return $this->condition($field, NULL, 'IS NOT NULL');
}

/**
 * {@inheritdoc}
 */
public function exists(SelectInterface $select) {
  return $this->condition('', $select, 'EXISTS');
}

/**
 * {@inheritdoc}
 */
public function notExists(SelectInterface $select) {
  return $this->condition('', $select, 'NOT EXISTS');
}

Anyway this documentation edition is correct.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php
    @@ -49,7 +49,9 @@
    +   *   and the value should be a SelectInterface object.
    

    $value I think?

  2. +++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php
    @@ -59,6 +61,9 @@
    +   * @throws \Drupal\Core\Database\InvalidQueryException
    +   *   If passed invalid arguments.
    

    This doesn't really provide that much info. The exception seems to be thrown when $value is an empty array. It is a bit of a funny exception...

Lal_’s picture

Status: Needs work » Needs review
FileSize
1.39 KB
797 bytes

I was able complete #4-1 part, hope this works.

cilefen’s picture

Status: Needs review » Needs work

Nice work! I mentored @AbhishekLal on IRC with this one. I am setting this back to Needs work for #4-2.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.42 KB
655 bytes

I'm not sure we can really enumerate the things that cause the exception since they depend on the concrete class, but we can mention that one example since it's pretty much always invalid I think.

Or do you think we just should have the @throws line and no other details?

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me and all of @alexpott issues are fixed.

  • catch committed 1240a17 on 8.3.x
    Issue #2833292 by pwolanin, AbhishekLal, alexpott: Inaccurate doxygen...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x, thanks!

  • catch committed 1240a17 on 8.4.x
    Issue #2833292 by pwolanin, AbhishekLal, alexpott: Inaccurate doxygen...

  • catch committed 1240a17 on 8.4.x
    Issue #2833292 by pwolanin, AbhishekLal, alexpott: Inaccurate doxygen...

Status: Fixed » Closed (fixed)

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