Problem/Motivation
Static queries should have the field names bracket-encapsulated. In that way static queries cannot fail on a database, because a field name is a reserved keyword for the given database. For more info: https://www.drupal.org/node/2986894.
Proposed resolution
Bracket-encapsulated field names for all static queries located in the directory "core/tests/Drupal/KernelTests/Core/Database" and its sub-directories. Static queries can be found by doing a search for "->query(" and "->queryRange(" in the directory "core/tests/Drupal/KernelTests/Core/Database" and its sub-directories.
What needs to be changed:
From:
$connection->query('SELECT nid FROM {node} WHERE nid = :id', [':id' => 1']);
To:
$connection->query('SELECT [nid] FROM {node} WHERE [nid] = :id', [':id' => 1']);
Remaining tasks
TBD
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
TBD
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff_5-9.txt | 4.4 KB | Deepak Goyal |
#9 | 3152390-9.patch | 54.06 KB | Deepak Goyal |
Comments
Comment #2
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #3
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPlease review the patch as I have made changes in the
core/tests/Drupal/KernelTests/Core/Database
to make static queries field names bracket-encapsulated.Comment #5
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedFixed the test cases issue.
Comment #6
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #7
daffie CreditAttribution: daffie commentedPatch looks good.
The field "tid" also needs square brackets.
The field "age" also needs square brackets.
Comment #8
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedComment #9
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedHi @daffie
Made changes as you suggested please review.
Comment #10
daffie CreditAttribution: daffie commentedAll field names have now square brackets around them.
All code changes look good to me.
For me it is RTBC.
Thank you for working on this: @munish.kumar and @deepak_goyal.
Comment #11
daffie CreditAttribution: daffie commentedThe parent issue is a "bug report", therefore this issue is one too.
Comment #12
alexpottCommitted dbd9350 and pushed to 9.1.x. Thanks!
Will backport to 9.0.x once the branch is open again.
Comment #14
alexpottCherry-picked to 9.0.x