In core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php file change static queries to dynamic queries in testDefaultInsert(), testDefaultEmptyInsert() and testDefaultInsertWithFields() methods.

Problem/Motivation

As per title

Proposed resolution

$num_records_before = (int) $this->connection->query('SELECT COUNT(*) FROM {test}')->fetchField();
-
+    $num_records_before = $this->connection->select('test')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
-    $job = $this->connection->query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField();
+    $job = $this->connection->select('test', 't')
+      ->fields('t', ['job'])
+      ->condition('id', $id)
+      ->execute()
+      ->fetchField();

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD

CommentFileSizeAuthor
#2 3156349-2.patch2.31 KBhardik_patel_12

Comments

Hardik_Patel_12 created an issue. See original summary.

hardik_patel_12’s picture

Status: Active » Needs review
StatusFileSize
new2.31 KB

Kindly review the patch.

siddhant.bhosale’s picture

Hi @hardik_patel_12, The patch looks good and applies cleanly, but please refer to the issue https://www.drupal.org/project/drupal/issues/3152398.
It mentions not to change the static queries in the directory core/tests/Drupal/KernelTests/Core/Database.
Please let me know if I am missing anything or we can close the issue.

avpaderno’s picture

Status: Needs review » Closed (won't fix)

@sdiddhant-bhosale Yes, that is correct.

Change the static queries in the directory "core/tests/Drupal/FunctionalTests" and its sub-directories. Also do the same when in the directory "core/tests/Drupal/KernelTests" and its sub-directories, but not in the directory "core/tests/Drupal/KernelTests/Core/Database".

core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php is in that directory.

I am closing this issue.