Problem/Motivation

The test Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTest has a database driver specific testing in it and those test should extend Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase.

Proposed resolution

Make SchemaUniquePrefixedKeysIndexTest to extend DriverSpecificDatabaseTestBase.

Remaining tasks

Make the patch and review it.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

Comments

daffie created an issue. See original summary.

arantxio’s picture

Status: Active » Needs review
StatusFileSize
new4.05 KB

I've created the patch so instead of relying on a extra function we now set the value depending on the driver class.

Status: Needs review » Needs work

The last submitted patch, 2: 3351886-2.patch, failed testing. View results

arantxio’s picture

Status: Needs work » Needs review
StatusFileSize
new5.25 KB
new3.56 KB

So the naming had to be TestBase instead of Test, so the testbot does not run it. This way it should work.

daffie credited mondrake.

daffie’s picture

Giving @mondrake issue credits for his remark in #1148856-85: Postgres schema doesn't support keylength on a unique index.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
For me it is RTBC.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/mysql/tests/src/Kernel/mysql/SchemaUniquePrefixedKeysIndexTest.php
@@ -0,0 +1,19 @@
+use Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase as CoreSchemaUniquePrefixedKeysIndexTest;

+++ b/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaUniquePrefixedKeysIndexTest.php
@@ -0,0 +1,19 @@
+use Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase as CoreSchemaUniquePrefixedKeysIndexTest;

+++ b/core/modules/sqlite/tests/src/Kernel/sqlite/SchemaUniquePrefixedKeysIndexTest.php
@@ -0,0 +1,19 @@
+use Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase as CoreSchemaUniquePrefixedKeysIndexTest;

I don't think an alias is needed, here just extend SchemaUniquePrefixedKeysIndexTestBase ?

arantxio’s picture

StatusFileSize
new5.13 KB
new2.61 KB

@mondrake that's true, changed the naming so we don't have the alias anymore.

arantxio’s picture

Status: Needs work » Needs review
mondrake’s picture

+++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php
@@ -7,16 +7,19 @@
+  protected $columnValue;

you can typehint the property directly in PHP 8.1, and skip the annotation

protected string $columnValue;

arantxio’s picture

StatusFileSize
new5.06 KB
new631 bytes

Added the change suggested by @mondrake.

mondrake’s picture

I am afraid you need to do the same on the extending classes...

arantxio’s picture

StatusFileSize
new5.08 KB

@mondrake That's true my bad. added the string typehint to the other classes.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All points of @mondrake have been addressed.
Back to RTBC.

longwave’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php
    @@ -7,16 +7,17 @@
    +   * Set the value used to test the Schema unique prefixed keys index.
    

    Schema -> schema

  2. +++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php
    @@ -109,27 +104,11 @@ protected function checkUniqueConstraintException(string $table, string $column)
    -   * The basic syntax of passing an array (field, prefix length) as a key column
    -   * specifier must always be accepted by the driver. However, due to technical
    -   * limitations, some drivers may choose to ignore them.
    -   *
    -   * @return bool
    -   *   TRUE if the current database (driver) will conform to the prefix length
    -   *   specified as part of a key column specifier, FALSE if it will be ignored.
    

    We are losing this comment, and without it it is not at all obvious why Postgres/SQLite are different to MySQL. I think it would be good to move some of this explanation to the property declaration in the base class?

arantxio’s picture

Status: Needs work » Needs review
StatusFileSize
new5.55 KB
new1.07 KB

I've adjusted the comments based on the feedback from @longwave.

I adjusted the "lost" comment to what I think is a better description of the current situation.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All remarks of @longwave have been addressed.
Back to RTBC.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 224543f183 to 11.x (10.2.x). Thanks!

  • longwave committed 224543f1 on 11.x
    Issue #3351886 by Arantxio, daffie, mondrake, longwave: Change...

Status: Fixed » Closed (fixed)

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