Skip to content
Snippets Groups Projects
Verified Commit f0e32bb3 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3415118 by ahmad.k, Lendude: Combine fields filter REGEXP causes PostgreSQL syntax error

(cherry picked from commit b3c74ca1)
parent 7afb8b28
Branches
Tags
8 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest
Pipeline #106779 passed with warnings
Pipeline: drupal

#106797

    Pipeline: drupal

    #106791

      Pipeline: drupal

      #106784

        ...@@ -210,7 +210,8 @@ protected function opNotLike($expression) { ...@@ -210,7 +210,8 @@ protected function opNotLike($expression) {
        protected function opRegex($expression) { protected function opRegex($expression) {
        $placeholder = $this->placeholder(); $placeholder = $this->placeholder();
        $this->query->addWhereExpression($this->options['group'], "$expression REGEXP $placeholder", [$placeholder => $this->value]); $operator = $this->getConditionOperator('REGEXP');
        $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]);
        } }
        protected function opEmpty($expression) { protected function opEmpty($expression) {
        ......
        ...@@ -98,6 +98,65 @@ public function testFilterCombineContains() { ...@@ -98,6 +98,65 @@ public function testFilterCombineContains() {
        $this->assertIdenticalResultset($view, $resultset, $this->columnMap); $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
        } }
        /**
        * Tests the Combine field filter with the 'regular_expression' operator.
        */
        public function testFilterCombineRegEx() {
        $view = Views::getView('test_view');
        $view->setDisplay();
        $fields = $view->displayHandlers->get('default')->getOption('fields');
        $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
        'job' => [
        'id' => 'job',
        'table' => 'views_test_data',
        'field' => 'job',
        'relationship' => 'none',
        ],
        ]);
        // Change the filtering.
        $view->displayHandlers->get('default')->overrideOption('filters', [
        'age' => [
        'id' => 'combine',
        'table' => 'views',
        'field' => 'combine',
        'relationship' => 'none',
        'operator' => 'regular_expression',
        'fields' => [
        'name',
        'job',
        ],
        'value' => '(ing|write)',
        ],
        ]);
        $this->executeView($view);
        $resultset = [
        [
        'name' => 'John',
        'job' => 'Singer',
        ],
        [
        'name' => 'George',
        'job' => 'Singer',
        ],
        [
        'name' => 'Ringo',
        'job' => 'Drummer',
        ],
        [
        'name' => 'Paul',
        'job' => 'Songwriter',
        ],
        [
        'name' => 'Ginger',
        'job' => NULL,
        ],
        ];
        $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
        }
        /** /**
        * Tests the Combine field filter with the 'word' operator. * Tests the Combine field filter with the 'word' operator.
        */ */
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment