Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294747

Change static queries to dynamic queries in core/tests/Drupal

$
0
0

Problem/Motivation

We should be using static queries as little as possible, because they can result into problems for a some databases. A static query may work on a number of databases, but not on an other one. Dynamic queries are a little bit slower then static queries and for use in tests that is not a problem.

Proposed resolution

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".

What needs to be changed:

From:
$connection->query('SELECT nid FROM {node} WHERE nid = :id', [':id' => 1']);

To:
$connection->select('node')
  ->fields('node', ['nid'])
  ->condition('nid', 1)
  ->execute();

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 294747

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>