[TASK] Remove method deleteConstraint from QueryBuilder 38/47638/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Tue, 12 Apr 2016 21:34:21 +0000 (23:34 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 13 Apr 2016 10:30:15 +0000 (12:30 +0200)
This method was an early helper for the QueryBuilder to replace
BEenableFields in a database agnostic way. Since the query restrictions
are now built using the QueryRestrictionBuilder and QueryContext this
method needs to be removed before it becomes part of the public API.

Resolves: #75562
Releases: master
Change-Id: I8428a43ed020ecbac722edba5e245d206158ac40
Reviewed-on: https://review.typo3.org/47638
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/core/Classes/Database/Query/QueryBuilder.php
typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php

index 09105bc..6189ce1 100644 (file)
@@ -862,26 +862,6 @@ class QueryBuilder
     }
 
     /**
-     * Returns the WHERE clause "[tablename].[deleted-field] = 0" if a deleted-field
-     * is configured in $GLOBALS['TCA'] for the tablename $table
-     * This function should ALWAYS be called in the backend for selection on tables which
-     * are configured in $GLOBALS['TCA'] since it will ensure consistent selection of records,
-     * even if they are marked deleted (in which case the system must always treat them as non-existent!)
-     *
-     * @param string $table Table name present in $GLOBALS['TCA']
-     * @param string $tableAlias Table alias if any
-     * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0
-     */
-    public function deleteConstraint(string $table, string $tableAlias = null): string
-    {
-        if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) {
-            return '';
-        }
-
-        return $this->quoteIdentifier(($tableAlias ?? $table) . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete']) . '=0';
-    }
-
-    /**
      * Quotes a given input parameter.
      *
      * @param mixed $input The parameter to be quoted.
index d1419bb..80c8db3 100644 (file)
@@ -728,45 +728,6 @@ class QueryBuilderTest extends UnitTestCase
     }
 
     /**
-     * @return array
-     */
-    public function deleteConstraintProvider()
-    {
-        return [
-            'no delete field' => [
-                ['aTable'],
-                '',
-                ''
-            ],
-            'without alias' => [
-                ['aTable'],
-                'deleted',
-                'aTable.deleted=0'
-            ],
-            'with alias' => [
-                ['aTable', 'a'],
-                'deleted',
-                'a.deleted=0'
-            ]
-        ];
-    }
-
-    /**
-     * @test
-     * @dataProvider deleteConstraintProvider
-     * @param array $args
-     * @param string $deleteField
-     * @param string $expected
-     */
-    public function deleteConstraint(array $args, string $deleteField, string $expected)
-    {
-        $this->connection->quoteIdentifier(Argument::cetera())->willReturnArgument(0);
-        $GLOBALS['TCA'][$args[0]]['ctrl']['delete'] = $deleteField;
-
-        $this->assertSame($expected, $this->subject->deleteConstraint(...$args));
-    }
-
-    /**
      * @test
      */
     public function queryRestrictionsAreAddedForSelectOnExecute()