Database Failures in Subpanels throughout SuiteCRM (MySQL Error) #4870

Open
opened 2026-02-20 16:25:22 -05:00 by deekerman · 41 comments
Owner

Originally created by @pstevens71 on GitHub (Oct 12, 2022).

Issue

Database error in subpanels with the error: ERROR 1250 (42000): Table ‘…’ from one of the SELECTs cannot be used in global ORDER clause. The issue pertains to use the Table name in the sort clause. This seemed to work fine until today (Oct. 10. 2022). So must have been a recent update in mySQL that no longer permits this syntax. I was able to get the subpanel to display contacts again by sorting on a different column. Example below (screenshots) is in the Cases module and Contacts Subpanel. However, this issue is throughout SuiteCRM and not just this module, and not just contacts.
sort problem
When I sort on "Accounts" it works:
working sort problem

Expected Behavior

The contact in the subpanel should display without error.

Actual Behavior

Contacts in subpanel display with database error.

```Wed Oct 12 14:08:16 2022 [16187][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='9e5568fd-3fd7-5130-0a83-6345f29aafeb' AND contacts_cases.deleted=0

where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause ```

Possible Fix

As a work around, I can sort by another column to avoid the error.

The fix is to remove the table name from "sort by" I think, but this is throughout all the subpanels not sure where to start. the ORDERBY contacts.last_name I think is what's causing the problem and should be just ORDERBY last_name.

Steps to Reproduce

  1. Go into any module that has Contacts subpanel, see it doesn't work. Also Project Tasks have same issue so its more than just contacts. See screen shots provided.

Context

This is a huge issue, I imagine affects every installation on MySQL 8.0.31

Your Environment

  • SuiteCRM Version used: 7.12.7
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome
  • Environment name and version (e.g. MySQL, PHP 7): MySQL 8.0.31
  • Operating System and version (e.g Ubuntu 16.04): WHM/Cpanel, Centoi v7.9.2009
Originally created by @pstevens71 on GitHub (Oct 12, 2022). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> <!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x. New issues referring to 7.10.x will only be valid if applicable to 7.12.x and above. If your issue is still applicable in 7.12.x, please create the issue following the template below --> #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> Database error in subpanels with the error: ERROR 1250 (42000): Table ‘…’ from one of the SELECTs cannot be used in global ORDER clause. The issue pertains to use the Table name in the sort clause. This seemed to work fine until today (Oct. 10. 2022). So must have been a recent update in mySQL that no longer permits this syntax. I was able to get the subpanel to display contacts again by sorting on a different column. Example below (screenshots) is in the Cases module and Contacts Subpanel. However, this issue is throughout SuiteCRM and not just this module, and not just contacts. ![sort problem](https://user-images.githubusercontent.com/29544935/195383235-d940e040-4b12-495b-8b7f-bb7f0afa4496.png) When I sort on "Accounts" it works: ![working sort problem](https://user-images.githubusercontent.com/29544935/195383318-aff4c101-e63a-44e1-8fd7-2713a6eb00e2.png) <!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines --> #### Expected Behavior <!--- Tell us what should happen --> The contact in the subpanel should display without error. #### Actual Behavior <!--- Tell us what happens instead --> Contacts in subpanel display with database error. <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) -->```Wed Oct 12 14:08:16 2022 [16187][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='9e5568fd-3fd7-5130-0a83-6345f29aafeb' AND contacts_cases.deleted=0 where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause ``` #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> As a work around, I can sort by another column to avoid the error. The fix is to remove the table name from "sort by" I think, but this is throughout all the subpanels not sure where to start. the ORDERBY contacts.last_name I think is what's causing the problem and should be just ORDERBY last_name. #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Go into any module that has Contacts subpanel, see it doesn't work. Also Project Tasks have same issue so its more than just contacts. See screen shots provided. #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> This is a huge issue, I imagine affects every installation on MySQL 8.0.31 #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.12.7 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome * Environment name and version (e.g. MySQL, PHP 7): MySQL 8.0.31 * Operating System and version (e.g Ubuntu 16.04): WHM/Cpanel, Centoi v7.9.2009
Author
Owner

@SuiteBot commented on GitHub (Oct 12, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/mysql-error-1250-table-contacts-from-one-of-the-selects-cannot-be-used-in-global-order-clause/86551/12

@SuiteBot commented on GitHub (Oct 12, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/mysql-error-1250-table-contacts-from-one-of-the-selects-cannot-be-used-in-global-order-clause/86551/12
Author
Owner

@SuiteBot commented on GitHub (Oct 12, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/weird-behavior-sorting-on-subpanels/86554/5

@SuiteBot commented on GitHub (Oct 12, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/weird-behavior-sorting-on-subpanels/86554/5
Author
Owner

@lefred commented on GitHub (Oct 13, 2022):

Hello,

I am working for MySQL, with 8.0.31, we have made some changes in the optimizer for a better handling of parenthesis to follow even better the SQL standards.

So in case of the following query:

(SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 inner join table2 using (id) ) 
ORDER BY table1.LastInvoiceDate ;
ERROR: 1250 (42000): Table 'table1' from one of the SELECTs cannot be used in global ORDER clause

Now the ORDER BY is related to the content of the query in the parenthesis and this can be used:

if the order by field is unique in the query, we just remove the table name reference like this:

SELECT table1.LastInvoiceDate, table2.id from table1 inner join table2 using (id)) ORDER BY id ;
+-----------------+----+
| LastInvoiceDate | id |
+-----------------+----+
| 2020-01-01      |  1 |
| 2021-04-21      |  2 |
| 2022-03-02      |  3 |
+-----------------+----+

if the column name is identical but from 2 different tables (like my first query), then you need to alias it or use the column's number like this :

(SELECT table1.LastInvoiceDate tb1LastInvoiceDate, table2.LastInvoiceDate tbl2LastInvoiceDate 
from table1 inner join table2 using (id)) ORDER BY tb1LastInvoiceDate;
+--------------------+---------------------+
| tb1LastInvoiceDate | tbl2LastInvoiceDate |
+--------------------+---------------------+
| 2020-01-01         | 2022-05-01          |
| 2021-04-21         | 2022-05-21          |
| 2022-03-02         | 2022-05-02          |
+--------------------+---------------------+

or

(SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 inner join table2 using (id)) ORDER BY 1 ;
+-----------------+-----------------+
| LastInvoiceDate | LastInvoiceDate |
+-----------------+-----------------+
| 2020-01-01      | 2022-05-01      |
| 2021-04-21      | 2022-05-21      |
| 2022-03-02      | 2022-05-02      |
+-----------------+-----------------+

Without the parenthesis it works as previously:

 SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 
inner join table2 using (id) ORDER BY table1.LastInvoiceDate ;
+-----------------+-----------------+
| LastInvoiceDate | LastInvoiceDate |
+-----------------+-----------------+
| 2020-01-01      | 2022-05-01      |
| 2021-04-21      | 2022-05-21      |
| 2022-03-02      | 2022-05-02      |
+-----------------+-----------------+

Cheers,

@lefred commented on GitHub (Oct 13, 2022): Hello, I am working for MySQL, with 8.0.31, we have made some changes in the optimizer for a better handling of parenthesis to follow even better the SQL standards. So in case of the following query: ``` (SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 inner join table2 using (id) ) ORDER BY table1.LastInvoiceDate ; ERROR: 1250 (42000): Table 'table1' from one of the SELECTs cannot be used in global ORDER clause ``` Now the ORDER BY is related to the content of the query in the parenthesis and this can be used: if the order by field is unique in the query, we just remove the table name reference like this: ``` SELECT table1.LastInvoiceDate, table2.id from table1 inner join table2 using (id)) ORDER BY id ; +-----------------+----+ | LastInvoiceDate | id | +-----------------+----+ | 2020-01-01 | 1 | | 2021-04-21 | 2 | | 2022-03-02 | 3 | +-----------------+----+ ``` if the column name is identical but from 2 different tables (like my first query), then you need to alias it or use the column's number like this : ``` (SELECT table1.LastInvoiceDate tb1LastInvoiceDate, table2.LastInvoiceDate tbl2LastInvoiceDate from table1 inner join table2 using (id)) ORDER BY tb1LastInvoiceDate; +--------------------+---------------------+ | tb1LastInvoiceDate | tbl2LastInvoiceDate | +--------------------+---------------------+ | 2020-01-01 | 2022-05-01 | | 2021-04-21 | 2022-05-21 | | 2022-03-02 | 2022-05-02 | +--------------------+---------------------+ ``` or ``` (SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 inner join table2 using (id)) ORDER BY 1 ; +-----------------+-----------------+ | LastInvoiceDate | LastInvoiceDate | +-----------------+-----------------+ | 2020-01-01 | 2022-05-01 | | 2021-04-21 | 2022-05-21 | | 2022-03-02 | 2022-05-02 | +-----------------+-----------------+ ``` Without the parenthesis it works as previously: ``` SELECT table1.LastInvoiceDate, table2.LastInvoiceDate from table1 inner join table2 using (id) ORDER BY table1.LastInvoiceDate ; +-----------------+-----------------+ | LastInvoiceDate | LastInvoiceDate | +-----------------+-----------------+ | 2020-01-01 | 2022-05-01 | | 2021-04-21 | 2022-05-21 | | 2022-03-02 | 2022-05-02 | +-----------------+-----------------+ ``` Cheers,
Author
Owner

@lowbouncerate commented on GitHub (Oct 13, 2022):

Hi,
Where I can update the Query - I am not a Pro User of SuiteCRM

@lowbouncerate commented on GitHub (Oct 13, 2022): Hi, Where I can update the Query - I am not a Pro User of SuiteCRM
Author
Owner

@lefred commented on GitHub (Oct 13, 2022):

I've submitted a bug in our system too.

@lefred commented on GitHub (Oct 13, 2022): I've submitted a bug in our system too.
Author
Owner

@lowbouncerate commented on GitHub (Oct 13, 2022):

you can try to set both values as
'sort_order' => false,
'sort_by' => false,

it is working for me.

@lowbouncerate commented on GitHub (Oct 13, 2022): you can try to set both values as 'sort_order' => false, 'sort_by' => false, it is working for me.
Author
Owner

@iias12 commented on GitHub (Oct 13, 2022):

you can try to set both values as 'sort_order' => false, 'sort_by' => false,

it is working for me.

Where did you change these settings?

@iias12 commented on GitHub (Oct 13, 2022): > you can try to set both values as 'sort_order' => false, 'sort_by' => false, > > it is working for me. Where did you change these settings?
Author
Owner

@lowbouncerate commented on GitHub (Oct 14, 2022):

I am using 7.10.x and we are using custom panels
custom/modules/Leads/Ext/Layoutdefs

@lowbouncerate commented on GitHub (Oct 14, 2022): I am using 7.10.x and we are using custom panels custom/modules/Leads/Ext/Layoutdefs
Author
Owner

@hbartel commented on GitHub (Oct 19, 2022):

Has anyone been able to trace down what file is building this SQL query?
The fix should be as simple as removing the outer ( ) from the query:
(SELECT ... contacts.deleted=0) ORDER BY ...

But I have not been able to determine what file is building the query.

@hbartel commented on GitHub (Oct 19, 2022): Has anyone been able to trace down what file is building this SQL query? The fix should be as simple as removing the outer ( ) from the query: (SELECT ... contacts.deleted=0) ORDER BY ... But I have not been able to determine what file is building the query.
Author
Owner

@pgorod commented on GitHub (Oct 20, 2022):

You can ask PHP to give you a full stack trace on that error, this should be enough to determine where it's coming from.

@pgorod commented on GitHub (Oct 20, 2022): You can ask PHP to give you a full stack trace on that error, this should be enough to determine where it's coming from.
Author
Owner

@pstevens71 commented on GitHub (Oct 20, 2022):

I set level to ERROR and Enable stack trace to checked and it doesn't give me any further info. This is the output.....

Thu Oct 20 14:12:58 2022 [20457][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='6a66b4d6-34a3-ef97-0de0-634878effa1e' AND contacts_cases.deleted=0

where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause
Thu Oct 20 14:12:58 2022 [20457][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details.
Thu Oct 20 14:12:59 2022 [20457][1][ERROR] Unable to find relationship emails_email_templates
Thu Oct 20 14:12:59 2022 [20457][1][ERROR] Unable to find relationship emails_email_templates
Thu Oct 20 14:13:54 2022 [20629][1][FATAL] Mysqli_query failed.
Thu Oct 20 14:13:54 2022 [20629][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='6a66b4d6-34a3-ef97-0de0-634878effa1e' AND contacts_cases.deleted=0

where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause
Thu Oct 20 14:13:54 2022 [20629][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details.

There's nothing in the suitecrm.log

@pstevens71 commented on GitHub (Oct 20, 2022): I set level to ERROR and Enable stack trace to checked and it doesn't give me any further info. This is the output..... Thu Oct 20 14:12:58 2022 [20457][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='6a66b4d6-34a3-ef97-0de0-634878effa1e' AND contacts_cases.deleted=0 where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause Thu Oct 20 14:12:58 2022 [20457][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details. Thu Oct 20 14:12:59 2022 [20457][1][ERROR] Unable to find relationship emails_email_templates Thu Oct 20 14:12:59 2022 [20457][1][ERROR] Unable to find relationship emails_email_templates Thu Oct 20 14:13:54 2022 [20629][1][FATAL] Mysqli_query failed. Thu Oct 20 14:13:54 2022 [20629][1][FATAL] Error retrieving Case list: Query Failed: (SELECT contacts.id , contacts.first_name , contacts.last_name , contacts.salutation , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name, ' ' account_name , ' ' account_id , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name FROM contacts LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c INNER JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND contacts_cases.case_id='6a66b4d6-34a3-ef97-0de0-634878effa1e' AND contacts_cases.deleted=0 where contacts.deleted=0) ORDER BY contacts.last_name, contacts.first_name asc LIMIT 0,10: MySQL error 1250: Table 'contacts' from one of the SELECTs cannot be used in global ORDER clause Thu Oct 20 14:13:54 2022 [20629][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details. There's nothing in the suitecrm.log
Author
Owner

@lefred commented on GitHub (Oct 20, 2022):

I'm not a SuiteCRM developer (or even user), but to me it seems the stack trace is clear a refers to github.com/salesagility/SuiteCRM@d57e91389d/include/ListView/ListView.php (L1077)

@lefred commented on GitHub (Oct 20, 2022): I'm not a SuiteCRM developer (or even user), but to me it seems the stack trace is clear a refers to https://github.com/salesagility/SuiteCRM/blob/d57e91389d97791fe621d811f03fe05f8f5a7f78/include/ListView/ListView.php#L1077
Author
Owner

@hbartel commented on GitHub (Oct 20, 2022):

Found it!
github.com/salesagility/SuiteCRM@7b6ac1bb78/data/SugarBean.php (L930)

To fix comment out the line:
//$query = '(' . $query . ')';

@hbartel commented on GitHub (Oct 20, 2022): Found it! https://github.com/salesagility/SuiteCRM/blob/7b6ac1bb788bf0904e05cea6d9069a5feeaab52f/data/SugarBean.php#L930 To fix comment out the line: //$query = '(' . $query . ')';
Author
Owner

@pstevens71 commented on GitHub (Oct 20, 2022):

Nice, I was trying to track that down too. I was in SugarBean.php too, didn't see that one. Great, I'm going to test!

@pstevens71 commented on GitHub (Oct 20, 2022): Nice, I was trying to track that down too. I was in SugarBean.php too, didn't see that one. Great, I'm going to test!
Author
Owner

@pstevens71 commented on GitHub (Oct 20, 2022):

I've tested and it seems to have fixed the issue in all modules.

@pstevens71 commented on GitHub (Oct 20, 2022): I've tested and it seems to have fixed the issue in all modules.
Author
Owner

@pstevens71 commented on GitHub (Oct 21, 2022):

After more testing, the fix above works except for "Products" It' s the same function in the error output. I'll have a look and see if I can find it related to products. Here's the error output for Products.

Fri Oct 21 14:00:26 2022 [8356][1][FATAL] Mysqli_query failed.
Fri Oct 21 14:00:26 2022 [8356][1][FATAL] Error retrieving AOS_Products list: Query Failed: (
SELECT * FROM (
SELECT
aos_quotes.*,
accounts.id AS account_id,
accounts.name AS billing_account,

				opportunity_id AS opportunity,
				billing_contact_id AS billing_contact,
				'' AS created_by_name,
				'' AS modified_by_name,
				'' AS assigned_user_name
			FROM
				aos_products

			JOIN aos_products_quotes ON aos_products_quotes.product_id = aos_products.id AND aos_products.id = 'b4be7061-d6f5-3d37-945f-58082df30257' AND aos_products_quotes.deleted = 0 AND aos_products.deleted = 0
			JOIN aos_quotes ON aos_quotes.id = aos_products_quotes.parent_id AND aos_quotes.stage = 'Closed Accepted' AND aos_quotes.deleted = 0
			JOIN accounts ON accounts.id = aos_quotes.billing_account_id -- AND accounts.deleted = 0

			GROUP BY aos_quotes.id
		) AS aos_quotes

	) ORDER BY aos_quotes.id asc LIMIT 0,10: MySQL error 1250: Table 'aos_quotes' from one of the SELECTs cannot be used in global ORDER clause

Fri Oct 21 14:00:26 2022 [8356][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details.

@pstevens71 commented on GitHub (Oct 21, 2022): After more testing, the fix above works except for "Products" It' s the same function in the error output. I'll have a look and see if I can find it related to products. Here's the error output for Products. Fri Oct 21 14:00:26 2022 [8356][1][FATAL] Mysqli_query failed. Fri Oct 21 14:00:26 2022 [8356][1][FATAL] Error retrieving AOS_Products list: Query Failed: ( SELECT * FROM ( SELECT aos_quotes.*, accounts.id AS account_id, accounts.name AS billing_account, opportunity_id AS opportunity, billing_contact_id AS billing_contact, '' AS created_by_name, '' AS modified_by_name, '' AS assigned_user_name FROM aos_products JOIN aos_products_quotes ON aos_products_quotes.product_id = aos_products.id AND aos_products.id = 'b4be7061-d6f5-3d37-945f-58082df30257' AND aos_products_quotes.deleted = 0 AND aos_products.deleted = 0 JOIN aos_quotes ON aos_quotes.id = aos_products_quotes.parent_id AND aos_quotes.stage = 'Closed Accepted' AND aos_quotes.deleted = 0 JOIN accounts ON accounts.id = aos_quotes.billing_account_id -- AND accounts.deleted = 0 GROUP BY aos_quotes.id ) AS aos_quotes ) ORDER BY aos_quotes.id asc LIMIT 0,10: MySQL error 1250: Table 'aos_quotes' from one of the SELECTs cannot be used in global ORDER clause Fri Oct 21 14:00:26 2022 [8356][1][FATAL] [ListView::processUnionBeans] . Database failure. Please refer to suitecrm.log for details.
Author
Owner

@PepeImpulso commented on GitHub (Oct 21, 2022):

Found it!

github.com/salesagility/SuiteCRM@7b6ac1bb78/data/SugarBean.php (L930)

To fix comment out the line: //$query = '(' . $query . ')';

Works for me! I was starting to get desperate!

@PepeImpulso commented on GitHub (Oct 21, 2022): > Found it! > > https://github.com/salesagility/SuiteCRM/blob/7b6ac1bb788bf0904e05cea6d9069a5feeaab52f/data/SugarBean.php#L930 > > To fix comment out the line: //$query = '(' . $query . ')'; Works for me! I was starting to get desperate!
Author
Owner

@SuiteBot commented on GitHub (Oct 27, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/upgrade-from-7-12-4-to-7-12-7-database-failure/86735/3

@SuiteBot commented on GitHub (Oct 27, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/upgrade-from-7-12-4-to-7-12-7-database-failure/86735/3
Author
Owner

@gunnicom commented on GitHub (Oct 27, 2022):

Commenting the line seems more like a workaround than a fix to me. Just saying.

@gunnicom commented on GitHub (Oct 27, 2022): Commenting the line seems more like a workaround than a fix to me. Just saying.
Author
Owner

@hah100 commented on GitHub (Oct 27, 2022):

Products still gives the same error

@hah100 commented on GitHub (Oct 27, 2022): Products still gives the same error
Author
Owner

@hbartel commented on GitHub (Oct 27, 2022):

Commenting the line seems more like a workaround than a fix to me. Just saying.

The issue is that the SQL query is formatted incorrectly for MySQL 8.0.31. Removing the extra () in the query by commenting out the line directly fixes the issue. It is not a work around, it is a direct fix for the Contacts, Opportunities and Leads subpannels.

The products subpannel has the same issue, that the SQL query is formatted incorrectly for MySQL 8.0.31, but the query is being built by a different bit of code. For products we need to find where that query is being built and apply a similar fix.

@hbartel commented on GitHub (Oct 27, 2022): > Commenting the line seems more like a workaround than a fix to me. Just saying. The issue is that the SQL query is formatted incorrectly for MySQL 8.0.31. Removing the extra () in the query by commenting out the line directly fixes the issue. It is not a work around, it is a direct fix for the Contacts, Opportunities and Leads subpannels. The products subpannel has the same issue, that the SQL query is formatted incorrectly for MySQL 8.0.31, but the query is being built by a different bit of code. For products we need to find where that query is being built and apply a similar fix.
Author
Owner

@gunnicom commented on GitHub (Oct 27, 2022):

@hbartel Sorry I did not look correctly. You are right commenting this line would fix it. Just wonder what is the reason the braces are there initially?

@gunnicom commented on GitHub (Oct 27, 2022): @hbartel Sorry I did not look correctly. You are right commenting this line would fix it. Just wonder what is the reason the braces are there initially?
Author
Owner

@hbartel commented on GitHub (Oct 27, 2022):

I did more testing but I am not able to reproduce the issue that Hah100 and Pstevens71 are seeing with the products subpannel when line 930 is commented out.

One possibility is:
github.com/salesagility/SuiteCRM@7b6ac1bb78/data/SugarBean.php (L876)

@hbartel commented on GitHub (Oct 27, 2022): I did more testing but I am not able to reproduce the issue that Hah100 and Pstevens71 are seeing with the products subpannel when line 930 is commented out. One possibility is: https://github.com/salesagility/SuiteCRM/blob/7b6ac1bb788bf0904e05cea6d9069a5feeaab52f/data/SugarBean.php#L876
Author
Owner

@pstevens71 commented on GitHub (Oct 27, 2022):

Nice! That solves my problem. I was all over that function and didn't see that line. I did this to test if that fixes it and it does...

image

@pstevens71 commented on GitHub (Oct 27, 2022): Nice! That solves my problem. I was all over that function and didn't see that line. I did this to test if that fixes it and it does... ![image](https://user-images.githubusercontent.com/29544935/198376178-485dcf48-770a-4529-8381-dfe006f200e6.png)
Author
Owner

@hah100 commented on GitHub (Oct 27, 2022):

Yess, great. Fixed. Thanks a lot for that!

@hah100 commented on GitHub (Oct 27, 2022): Yess, great. Fixed. Thanks a lot for that!
Author
Owner

@pstevens71 commented on GitHub (Oct 27, 2022):

OK so who knows how to setup a request to have these changes added to the code?

@pstevens71 commented on GitHub (Oct 27, 2022): OK so who knows how to setup a request to have these changes added to the code?
Author
Owner

@hah100 commented on GitHub (Oct 27, 2022):

I guess the developers read this too?

@hah100 commented on GitHub (Oct 27, 2022): I guess the developers read this too?
Author
Owner

@hbartel commented on GitHub (Oct 27, 2022):

I created a pull request for the proposed changes so that they can be reviewed.

@hbartel commented on GitHub (Oct 27, 2022): I created a pull request for the proposed changes so that they can be reviewed.
Author
Owner

@pstevens71 commented on GitHub (Oct 27, 2022):

Thanks @hbartel that's awesome. One of these days I have to learn how to do that!

@pstevens71 commented on GitHub (Oct 27, 2022): Thanks @hbartel that's awesome. One of these days I have to learn how to do that!
Author
Owner

@SuiteBot commented on GitHub (Nov 2, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/suitecrm-database-failure-after-assigning-role-management/86814/2

@SuiteBot commented on GitHub (Nov 2, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/suitecrm-database-failure-after-assigning-role-management/86814/2
Author
Owner

@SuiteBot commented on GitHub (Dec 6, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/target-list-error-message/42001/3

@SuiteBot commented on GitHub (Dec 6, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/target-list-error-message/42001/3
Author
Owner

@SuiteBot commented on GitHub (Dec 14, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/after-moving-to-new-server-i-get-error/87287/6

@SuiteBot commented on GitHub (Dec 14, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/after-moving-to-new-server-i-get-error/87287/6
Author
Owner

@SuiteBot commented on GitHub (Dec 23, 2022):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/contact-database-failure-please-refer-to-suitecrm-log-for-details/87401/3

@SuiteBot commented on GitHub (Dec 23, 2022): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/contact-database-failure-please-refer-to-suitecrm-log-for-details/87401/3
Author
Owner

@pstevens71 commented on GitHub (Jan 10, 2023):

Also on line 930

comment out:

$query = '(' . $query . ')';

AND

line: 876 remove the brackets and quotations:

$final_query = '(' . $tmp_final_query . ')';

to

$final_query = $tmp_final_query;

Both changes are required to fix this issue.

@pstevens71 commented on GitHub (Jan 10, 2023): Also on line 930 comment out: $query = '(' . $query . ')'; AND line: 876 remove the brackets and quotations: $final_query = '(' . $tmp_final_query . ')'; to $final_query = $tmp_final_query; Both changes are required to fix this issue.
Author
Owner

@SuiteBot commented on GitHub (Jan 10, 2023):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/error-with-mssql-database/17514/4

@SuiteBot commented on GitHub (Jan 10, 2023): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/error-with-mssql-database/17514/4
Author
Owner

@SuiteBot commented on GitHub (Apr 19, 2023):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/probleme-beim-einstellen-sicherheitsgruppen/88798/5

@SuiteBot commented on GitHub (Apr 19, 2023): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/probleme-beim-einstellen-sicherheitsgruppen/88798/5
Author
Owner

@chris001 commented on GitHub (Oct 27, 2023):

Fix not present in 7.14.1 or 8.4...

@chris001 commented on GitHub (Oct 27, 2023): Fix not present in `7.14.1` or `8.4`...
Author
Owner

@aurelien1980 commented on GitHub (Dec 6, 2023):

This fixes the error with mysql 8.
How come it is not released in SuiteCRM yet ?

@aurelien1980 commented on GitHub (Dec 6, 2023): This fixes the error with mysql 8. How come it is not released in SuiteCRM yet ?
Author
Owner

@pgorod commented on GitHub (Dec 7, 2023):

The fix is in #9843

@pgorod commented on GitHub (Dec 7, 2023): The fix is in #9843
Author
Owner

@SuiteBot commented on GitHub (Jan 7, 2024):

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/suitecrm-8-5-sql-errors-and-access-authorisation-errors/91456/2

@SuiteBot commented on GitHub (Jan 7, 2024): This issue has been mentioned on **SuiteCRM**. There might be relevant details there: https://community.suitecrm.com/t/suitecrm-8-5-sql-errors-and-access-authorisation-errors/91456/2
Author
Owner

@aurelien1980 commented on GitHub (Sep 6, 2024):

Problem remains in Suitecrm 7.14.5 and MySQL 8.0.35
Fix is working well:
line 878: $final_query = '(' . $tmp_final_query . ')'; change to $final_query = $tmp_final_query;
line 933: $query = '(' . $query . ')'; comment this line

@aurelien1980 commented on GitHub (Sep 6, 2024): Problem remains in Suitecrm 7.14.5 and MySQL 8.0.35 Fix is working well: line 878: $final_query = '(' . $tmp_final_query . ')'; **change to** $final_query = $tmp_final_query; line 933: $query = '(' . $query . ')'; **comment this line**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4870
No description provided.