Even the latest versions of SQLite do not support RIGHT JOIN (changelog), so the query needs to be folded to a LEFT JOIN.
Otherwise we had to remove RIGHT JOIN support from our generic DB driver.
Currently doesn't seem to be used anywhere, otherwise we would have hit this already. IMHO, still a major bug needing backport.

CommentFileSizeAuthor
#14 2011500-14.patch951 bytesdaffie
#11 2011500-11.patch1.17 KBdaffie

Comments

pancho’s picture

[edited:] grep reveals that LEFT RIGHT JOIN is indeed not used in core, unlike RIGHT LEFT JOIN, but this can still break contrib code for SQLite.

dawehner’s picture

Are you sure about that? I have some places in mind where at list views uses a left join instead of an inner join.

pancho’s picture

You're absolutely right. Must have been tired when writing that - while the analysis was right, the wording wasn't.
Correct is: We're currently not using RIGHT JOINs in Core, but if we did, they would be broken in SQLite.
So we need to make sure, contrib doesn't use RIGHT JOINs or alternatively we need to rewrite them into a LEFT JOIN.

damien tournoud’s picture

I agree, the database system should just not support right joins. There are really only limited use-case for them anyway, so let's get rid of the support completely.

pancho’s picture

OK. Easy to remove RIGHT JOIN support in D8.
Now how about D7? Contrib and/or custom code may already use RIGHT JOINs not caring about SQLite compatibility.
To be on the secure side, we'd have to rewrite RIGHT JOINs to LEFT JOINs for D7, but if then we already have written and tested the rewriting code, then we can keep using it in D8 just as well. Or would we rather deprecate RIGHT JOINs anyway from a KISS point-of-view?

damien tournoud’s picture

Rewriting RIGHT JOIN into LEFT JOIN sounds hard, or else SQLite would just do that? Any idea how hard would it really be?

damien tournoud’s picture

Issue summary: View changes

fix typo

jhedstrom’s picture

Version: 8.0.x-dev » 9.x-dev
Issue summary: View changes
Status: Active » Postponed

I think removing this would be considered a pretty major API change at this point, even if it fixes a bug with SQLite?

dcrocks’s picture

I think the intent was to continue to support RIGHT JOIN from contrib by changing the drivers to convert them to LEFT JOIN, so it isn't an api change. There are no RIGHT JOIN's issued in core. And if issues for SQLite and Postgres continue to be pushed back, the harder it gets to fix them. Can the owner of this issue speak up?

jhedstrom’s picture

Version: 9.x-dev » 8.0.x-dev
Status: Postponed » Active

I think it could still be considered for 8.0 if it isn't actually a major API change as I assumed above.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

daffie’s picture

Status: Active » Needs review
StatusFileSize
new1.17 KB

A right join on drupal is a right outer join. So left test if it works on SQLite or not.

daffie’s picture

Priority: Major » Critical

The new testRightOuterJoin fails for SQLite with the following error: "SQLSTATE[HY000]: General error: 1 RIGHT and FULL OUTER JOINs are not currently supported".
This is not fixable and needs a management decision what to about it. I see two options:

  1. Make right joins deprecated as of Drupal 8 and removed it in Drupal 9.
  2. Remove right joins immediatly in Drupal 8. If you want to use a Drupal 8 site with a SQLite database and somewhere in the code is the right join used the site will be unusable and have no workaround.

I am setting the priority to critical because this bug will: "Render a site unusable and have no workaround."

catch’s picture

Priority: Critical » Major

This doesn't render a site unusable with no workaround - you'd need to actually 1. write a query using a right join (which requires a contrib or custom module) 2. have that query run on an site running sqlite 3. have the query run on every page so that it's not possible to uninstall the module.

That's not impossible, but it's very unlikely.

I agree we should deprecate it though, probably with an additional mention that it's broken on sqlite. Can open up a follow-up to try to convert to a left join if that's viable.

daffie’s picture

StatusFileSize
new951 bytes

Patch for deprecating the SelectInterface::rightJoin() method.

daffie’s picture

Added a change record: https://www.drupal.org/node/2765249.

daffie’s picture

Title: SQLite doesn't support RIGHT JOINs » Deprecate RIGHT JOINs, because SQLite doesn't support them.

Better title

daffie’s picture

Issue tags: +@deprecated
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

xjm’s picture

Version: 8.1.x-dev » 8.2.x-dev
Issue tags: +Needs framework manager review, +rc eligible

We generally deprecate code in minor versions, so moving to 8.2.x. (Documenting a deprecation is also RC-eligible.) I tweaked the CR a little bit.

Leaving this issue for a framework manager.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs framework manager review

Deprecating something that one of our supported dbs can't do just makes sense. Committed db9e719 and pushed to 8.2.x. Thanks!

I don't know how the deprecation should be ported to D7 so marking issue as closed.

  • alexpott committed db9e719 on 8.2.x
    Issue #2011500 by daffie, Pancho: Deprecate RIGHT JOINs, because SQLite...
David_Rothstein’s picture

I created #2775593: (D7 backport) Deprecate RIGHT JOINs, because SQLite doesn't support them for backporting this to Drupal 7. The "will be removed in Drupal 9.0.0" line is less necessary there perhaps, but otherwise I think the backport would basically be the same. The key point is to indicate that it should not be used for any code that needs to run on SQLite.

  • alexpott committed db9e719 on 8.3.x
    Issue #2011500 by daffie, Pancho: Deprecate RIGHT JOINs, because SQLite...

  • alexpott committed db9e719 on 8.3.x
    Issue #2011500 by daffie, Pancho: Deprecate RIGHT JOINs, because SQLite...

Status: Fixed » Closed (fixed)

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