- Issue created by @daffie
- Status changed to Needs review
about 1 year ago 3:39pm 2 November 2023 - last update
about 1 year ago 30,492 pass - last update
about 1 year ago 30,492 pass - last update
about 1 year ago 30,490 pass, 2 fail - last update
about 1 year ago 30,492 pass - last update
about 1 year ago 30,492 pass - Status changed to Needs work
about 1 year ago 8:37pm 2 November 2023 The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- last update
about 1 year ago 30,492 pass - Status changed to Needs review
about 1 year ago 7:58am 3 November 2023 - 🇮🇳India Nitin shrivastava
@daffie #2 patch applied succesfully on drupal 11.x
- Merge request !5242Make the conditions in joins in dynamic queries use Condition objects → (Open) created by daffie
- 🇮🇹Italy mondrake 🇮🇹
Big work, @daffie!
I put some comments so far; still trying to grasp the entire concept. I see views is impacted heavily, will need someone knowing it better to review it.
- 🇮🇹Italy mondrake 🇮🇹
If we are deprecating passing a string as $conditions to Select::addJoin(), I think also ::join(), ::leftJoin() and ::innerJoin() should do the same.
- 🇳🇱Netherlands daffie
If we are deprecating passing a string as $conditions to Select::addJoin(), I think also ::join(), ::leftJoin() and ::innerJoin() should do the same.
The methods ::join(), ::leftJoin() and ::innerJoin() are wrapper methods on top of Select::addJoin(). If you deprecate those on their own, you will get 2 deprecations. One from the wrapper method and one from Select::addJoin().
- Status changed to Needs work
about 1 year ago 2:16pm 4 November 2023 - 🇮🇹Italy mondrake 🇮🇹
- How about adding a helper method like this (untested) to the Select class:
public function joinCondition(array ...$joins): ConditionInterface { $condition = $this->connection->condition('AND'); foreach ($joins as $join) { assert(count($join) === 2 || count($join) === 3); $condition->compare($join[0], $join[1], $join[2] ?? '='); } return $condition; }
that would IMHO make DX better: instead of
$query->leftJoin($this->dataTable, 'data', $this->database->condition('AND')->compare("revision.$this->idKey", "data.$this->idKey")->compare("revision.$this->langcodeKey", "data.$this->langcodeKey"));
we would use
$query->leftJoin($this->dataTable, 'data', $query->joinCondition( ["revision.$this->idKey", "data.$this->idKey"], ["revision.$this->langcodeKey", "data.$this->langcodeKey"] ));
Also, the $operator argument of the compare() method can be made mandatory.
- Never mind the field vs column braindump. Still, I find the naming of
compare
too vague. How aboutcompareFields
? - I do not see a problem in getting 2 deprecation messages for #10, and really think we need to deprecate all the related methods.
- I think we likely need to split this MR in one adding the feature and one doing the conversions, to make reviewing more palatable. But let's do that later.
- How about adding a helper method like this (untested) to the Select class:
- Status changed to Needs review
about 1 year ago 8:12am 6 November 2023 - 🇳🇱Netherlands daffie
@mondrake: I like your idea and I have 2 variants I would like to propose.
We create a helper method that would return the Condition object:
public function joinCondition(string $conjunction = 'AND') { return $this->connection->condition($conjunction); }
The query before
$query->leftJoin($this->dataTable, 'data', $this->database->condition('AND')->compare("revision.$this->idKey", "data.$this->idKey")->compare("revision.$this->langcodeKey", "data.$this->langcodeKey"));
The query after
$query->leftJoin($this->dataTable, 'data', $query->joinCondition() ->compare("revision.$this->idKey", "data.$this->idKey") ->compare("revision.$this->langcodeKey", "data.$this->langcodeKey") );
We allow the join condition is an array of arrays with each inner array having two values that must be equal. When it is not a simple join than the Condition object must be used.
The query before
$query->leftJoin($this->dataTable, 'data', $this->database->condition('AND')->compare("revision.$this->idKey", "data.$this->idKey")->compare("revision.$this->langcodeKey", "data.$this->langcodeKey"));
The query after
$query->leftJoin($this->dataTable, 'data', [ ["revision.$this->idKey", "data.$this->idKey"], ["revision.$this->langcodeKey", "data.$this->langcodeKey"] ]);
For 11.2 I personally like
compare()
more, because it is closer tocondition()
. But I can live withcompareFields()
.For 11.3 If you think that is better, then lets do that.
@mondrake: Thank you for the reviewing and helping to get this issue to land.
- 🇮🇹Italy mondrake 🇮🇹
Hi @daffie
#12.1 - I like the first option! Keeps things open for uncommon join statements.
#12.2 - How about asking in Slack others' pov? So we don't go one way or another and then hit the wall later.
#12.3 - I do think that, but once again how about asking in Slack?
- 🇺🇸United States smustgrave
Is there a recommended way for testing this one?
- 🇺🇸United States smustgrave
Just following up if any recommended way of testing or if this needs any sign off?
- 🇸🇰Slovakia poker10
Adding a note here, that in this Slack thread https://drupal.slack.com/archives/C1BMUQ9U6/p1699266961237289, there were concerns raised about adding so much deprecations (especially for contrib modules). Proposed approach was to either separate deprecations into a follow-up issue, or make the first step without deprecations - just the new functionality. It would also make the reviews here easier.
- 🇳🇱Netherlands daffie
In the MR are the changes for the join and relationship plugins of the views module removed. I have created 📌 [PP-1] Make the conditions in joins in dynamic queries use Condition objects in the Views module Postponed as a followup to make the changes to the views module.
- 🇳🇱Netherlands daffie
The deprecation of the use of string conditions in joins in dynamic queries has been removed from the MR and a followup has been created for the deprecation ( 📌 [PP-2] Deprecate the use of string conditions in joins in dynamic queries Postponed ).
- 🇺🇸United States smustgrave
So wasn't 100% sure how to best review this one
And of course gitlab is freezing up but one nitpicky thing I saw was
public function compare(
could these new functions have a return typehintAs far as using the code I applied the patch for about an hour. Creating views with multiple relationships, created content and media, used layout builder and block layout. Just trying to make sure I touched as much as I could and nothing appeared to break.
I checked the CR and it reads well, the examples were extremely helpful so thank you for that!
For me I'm a +1 for giving this a shot but will leave in review for a bit longer for more eyes.
- Status changed to Needs work
10 months ago 1:57pm 22 February 2024 The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- Status changed to Needs review
10 months ago 3:31pm 22 February 2024 - 🇳🇱Netherlands daffie
@smustgrave: Thank for the review.
I have added the return type hint to the new method Condition::compare().
- Status changed to RTBC
10 months ago 4:45pm 22 February 2024 - 🇺🇸United States smustgrave
Thanks! Think I'm going to mark it so we can have it for 10.3 (not sure the cut off). But also see it's passing all database tests.
- Status changed to Needs work
9 months ago 5:00am 16 March 2024 The Needs Review Queue Bot → tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- Status changed to RTBC
3 months ago 6:54am 17 September 2024 The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- Status changed to Needs work
about 1 month ago 10:02pm 17 November 2024 The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.