Commit f65bccd4 authored by catch's avatar catch
Browse files

Revert "fix: #2735997 Decimal separator and precision settings unavailable...

Revert "fix: #2735997 Decimal separator and precision settings unavailable when aggregating decimal fields"

This reverts commit cf863a1d.

(cherry picked from commit 9f774618)
parent 331057c9
Loading
Loading
Loading
Loading
Loading
+6 −11
Changes for core/modules/views/src/EntityViewsData.php: 6 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -527,8 +527,6 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co
      default:
        // For most fields, the field type is generic enough to just use
        // the column type to determine the filters etc.
        $views_field['field']['id'] = 'field';
        $views_field['sort']['id'] = 'standard';
        switch ($column_type) {

          case 'int':
@@ -536,20 +534,13 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co
          case 'smallint':
          case 'tinyint':
          case 'mediumint':
            $views_field['argument']['id'] = 'numeric';
            $views_field['filter']['id'] = 'numeric';
            break;

          case 'float':
          case 'double':
          case 'decimal':
          case 'numeric':
            // Flag decimal values so that the numeric field handler, used
            // when aggregation is enabled, offers precision and decimal point
            // settings.
            $views_field['field']['float'] = TRUE;
            $views_field['field']['id'] = 'field';
            $views_field['argument']['id'] = 'numeric';
            $views_field['filter']['id'] = 'numeric';
            $views_field['sort']['id'] = 'standard';
            break;

          case 'char':
@@ -560,13 +551,17 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co
          case 'text':
          case 'mediumtext':
          case 'longtext':
            $views_field['field']['id'] = 'field';
            $views_field['argument']['id'] = 'string';
            $views_field['filter']['id'] = 'string';
            $views_field['sort']['id'] = 'standard';
            break;

          default:
            $views_field['field']['id'] = 'field';
            $views_field['argument']['id'] = 'standard';
            $views_field['filter']['id'] = 'standard';
            $views_field['sort']['id'] = 'standard';
        }
    }

−6
Changes for core/modules/views/src/FieldViewsDataProvider.php: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -327,12 +327,6 @@ public function defaultFieldImplementation(FieldStorageConfigInterface $field_st
        'element type' => 'div',
        'is revision' => $type == EntityStorageInterface::FIELD_LOAD_REVISION,
      ];
      // The decimal field type uses the numeric schema column type.
      // Set the float flag for float and numeric columns. The numeric field
      // handler uses the flag to show precision and decimal point settings.
      if (in_array($field_columns[$real_field]['type'], ['float', 'numeric'], TRUE)) {
        $data[$table_alias][$field_alias]['field']['float'] = TRUE;
      }
    }

    // Expose data for each field property individually.
−22
Changes for core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php: 0 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -438,28 +438,6 @@ public function testBaseTableFields(): void {
    $this->assertArrayNotHasKey('allow empty', $data['entity_test']['name']['filter']);
  }

  /**
   * Tests decimal and float fields on the base table.
   */
  public function testBaseTableDecimalFields(): void {
    $this->commonBaseFields['decimal'] = BaseFieldDefinition::create('decimal')
      ->setLabel('Decimal');
    $this->commonBaseFields['float'] = BaseFieldDefinition::create('float')
      ->setLabel('Float');
    $this->setUpEntityType($this->baseEntityType, $this->commonBaseFields);

    $data = $this->entityTypeManager->getHandler('entity_test', 'views_data')->getViewsData();

    foreach (['decimal', 'float'] as $field_name) {
      $this->assertNumericField($data['entity_test'][$field_name]);
      // Decimal values are flagged so that the numeric field handler, used
      // when aggregation is enabled, offers precision and decimal point
      // settings.
      $this->assertTrue($data['entity_test'][$field_name]['field']['float']);
    }
    $this->assertArrayNotHasKey('float', $data['entity_test']['id']['field']);
  }

  /**
   * Tests fields on the data table.
   */
−37
Changes for core/modules/views/tests/src/Kernel/FieldApiDataTest.php: 0 added lines, 37 removed lines.
Original line number Diff line number Diff line
@@ -185,43 +185,6 @@ public function testViewsData(): void {
    $this->assertEquals('Appears in: article, page, news. Also known as: Content: GiraffeA" label', $data[$current_table][$field_storage_string->getName()]['help']);
  }

  /**
   * Tests the float flag for decimal and integer fields.
   */
  public function testViewsDataFloatFlag(): void {
    NodeType::create([
      'type' => 'page',
      'name' => 'Page',
    ])->save();

    $table_mapping = $this->container->get('entity_type.manager')
      ->getStorage('node')
      ->getTableMapping();

    foreach (['decimal' => TRUE, 'float' => TRUE, 'integer' => FALSE] as $type => $float) {
      $field_storage = FieldStorageConfig::create([
        'field_name' => 'field_' . $type,
        'entity_type' => 'node',
        'type' => $type,
      ]);
      $field_storage->save();
      FieldConfig::create([
        'field_name' => 'field_' . $type,
        'entity_type' => 'node',
        'bundle' => 'page',
      ])->save();

      $table = $table_mapping->getDedicatedDataTableName($field_storage);
      $data = $this->container->get('views.views_data')->get($table);
      if ($float) {
        $this->assertTrue($data['field_' . $type]['field']['float'], "The $type field is flagged as float.");
      }
      else {
        $this->assertArrayNotHasKey('float', $data['field_' . $type]['field'], "The $type field is not flagged as float.");
      }
    }
  }

  /**
   * Gets the views data for the field created in setUp().
   *
Loading