Commit 7e80e5b8 authored by catch's avatar catch

Issue #2621782 by amateescu: SQL::addWhere not defaulting to "IN" operator...

Issue #2621782 by amateescu: SQL::addWhere not defaulting to "IN" operator when using EntityReferenceView for multiple values
parent f730e579
......@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\EntityReference;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field_ui\Tests\FieldUiTestTrait;
use Drupal\node\Entity\Node;
use Drupal\simpletest\WebTestBase;
......@@ -235,7 +236,12 @@ public function testFieldAdminHandler() {
'field_name' => $field_name,
);
$this->drupalPostForm($bundle_path . '/fields/add-field', $edit, t('Save and continue'));
$this->drupalPostForm(NULL, array(), t('Save field settings'));
// Set to unlimited.
$edit = array(
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
);
$this->drupalPostForm(NULL, $edit, t('Save field settings'));
// Add the view to the test field.
$edit = array(
......@@ -268,6 +274,17 @@ public function testFieldAdminHandler() {
$this->assertRaw($node1->getTitle() . ' (' . $node1->id() . ')');
$this->assertRaw($node2->getTitle() . ' (' . $node2->id() . ')');
// Try to add a new node, fill the entity reference field and submit the
// form.
$this->drupalPostForm('node/add/' . $this->type, [], t('Add another item'));
$edit = array(
'title[0][value]' => 'Example',
'field_test_entity_ref_field[0][target_id]' => 'Foo Node (' . $node1->id() . ')',
'field_test_entity_ref_field[1][target_id]' => 'Foo Node (' . $node2->id() . ')',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
$edit = array(
'title[0][value]' => 'Example',
'field_test_entity_ref_field[0][target_id]' => 'Test'
......
......@@ -150,7 +150,7 @@ public function query() {
// Add an IN condition for validation.
if (!empty($options['ids'])) {
$this->view->query->addWhere(0, $id_field, $options['ids']);
$this->view->query->addWhere(0, $id_field, $options['ids'], 'IN');
}
$this->view->setItemsPerPage($options['limit']);
......
......@@ -805,9 +805,9 @@ public function clearFields() {
* complex options, it is an array. The meaning of each element in the array is
* dependent on the $operator.
* @param $operator
* The comparison operator, such as =, <, or >=. It also accepts more complex
* options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array
* = otherwise. If $field is a string you have to use 'formula' here.
* The comparison operator, such as =, <, or >=. It also accepts more
* complex options such as IN, LIKE, LIKE BINARY, or BETWEEN. Defaults to =.
* If $field is a string you have to use 'formula' here.
*
* The $field, $value and $operator arguments can also be passed in with a
* single DatabaseCondition object, like this:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment