Automattic / HyperDB

HyperDB is an advanced database class that supports replication, failover, load balancing, and partitioning.
101 stars 22 forks source link

WordPress database error Expression #1 of ORDER BY clause is not in SELECT list #120

Open AlligatorNest opened 1 year ago

AlligatorNest commented 1 year ago

HyperDB files are causing the following errors on certain SELECT statements in WP. WP Version: 6.1.1

Error: WordPress database error Expression #1 of ORDER BY clause is not in SELECT list, references column 'phns17.wp_posts.post_date' which is not in SELECT list; this is incompatible with DISTINCT for query

This is caused by the MYSQL database sql_mode setting "only_full_group_by". It looks like WP has a built-in work around for this issue that HyperDB is overriding.

This prevents WP from retrieving Categories and tags so that posts appear to have no category. The category is being saved, but not retrieved in the select statement.

Removing HyperDB files fixes the issue.

AlligatorNest commented 1 year ago

I see this issue addressed in #104 but changing the SQL_MODE is not an option for us. If it makes any difference, the only feature we need in this script is failover if one of the servers in the cluster goes down. Not sure if that would make a work around easier.

Thank you.