Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql_mode is always strict #3976

Closed
pbowyer opened this issue Jul 30, 2022 · 2 comments
Closed

sql_mode is always strict #3976

pbowyer opened this issue Jul 30, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@pbowyer
Copy link

pbowyer commented Jul 30, 2022

I have a query failing with ERROR 1105 (HY000): expression 'Policy.data' doesn't appear in the group by expressions. With legacy systems normally I relax sql_mode to TRADITIONAL or "" to get round this, which works perfectly on MySQL. With Dolt I can change the value of sql_mode but it doesn't have any effect on the way the queries run.

The erroring query:

SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data 
FROM `access_resource_groups` Acl 
LEFT JOIN `access_policies` Policy ON Policy.id = Acl.policy 
JOIN `document_groups` ResourceGroup ON Acl.principal_class = 'modUserGroup' 
AND (Acl.context_key = 'web' OR Acl.context_key IS NULL OR Acl.context_key = '') 
AND ResourceGroup.document = '26714' 
AND ResourceGroup.document_group = Acl.target 
GROUP BY Acl.target, Acl.principal, Acl.authority, Acl.policy

Sample session:

mysql> set sql_mode='';
Query OK, 1 row affected (0.01 sec)

mysql> select @@sql_mode;
+--------------------+
| @@SESSION.sql_mode |
+--------------------+
|                    |
+--------------------+
1 row in set (0.01 sec)

mysql> SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data FROM `access_resource_groups` Acl LEFT JOIN `access_policies` Policy ON Policy.id = Acl.policy JOIN `document_groups` ResourceGroup ON Acl.principal_class = 'modUserGroup' AND (Acl.context_key = 'web' OR Acl.context_key IS NULL OR Acl.context_key = '') AND ResourceGroup.document = '26714' AND ResourceGroup.document_group = Acl.target GROUP BY Acl.target, Acl.principal, Acl.authority, Acl.policy;
ERROR 1105 (HY000): expression 'Policy.data' doesn't appear in the group by expressions
mysql> set sql_mode='TRADITIONAL';
Query OK, 1 row affected (0.01 sec)

mysql> select @@sql_mode;
+--------------------+
| @@SESSION.sql_mode |
+--------------------+
| TRADITIONAL        |
+--------------------+
1 row in set (0.01 sec)

mysql> SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data FROM `access_resource_groups` Acl LEFT JOIN `access_policies` Policy ON Policy.id = Acl.policy JOIN `document_groups` ResourceGroup ON Acl.principal_class = 'modUserGroup' AND (Acl.context_key = 'web' OR Acl.context_key IS NULL OR Acl.context_key = '') AND ResourceGroup.document = '26714' AND ResourceGroup.document_group = Acl.target GROUP BY Acl.target, Acl.principal, Acl.authority, Acl.policy;
ERROR 1105 (HY000): expression 'Policy.data' doesn't appear in the group by expressions
@pbowyer
Copy link
Author

pbowyer commented Jul 30, 2022

Related: #2172

@fulghum fulghum added the enhancement New feature or request label Aug 1, 2022
@timsehn
Copy link
Sponsor Contributor

timsehn commented Aug 31, 2022

Closing in favor of #2172

@timsehn timsehn closed this as completed Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants