Description:
Query:
SELECT
CASE
WHEN (NOT((`Ex`.`S` = 1) AND (`Ex`.`S` IS NOT NULL)))
THEN
('0X')
ELSE ('0X0X') END AS `C1`
From (SELECT 1) as `fake` LEFT OUTER JOIN (Select 1 AS `S` FROM `Companies` WHERE FALSE) AS `Ex` on 1 = 1;
Returns '0X' if use MySQL 5.6.
Returns '0X0X' if use MySQL 5.7.11
This is simplified query. Entity Framework use this in Table per Type hierarchy mapping for select proper child type.
Result should be '0X'.
I use AWS RDS instance.
mysql.exe:
C:\Users\vikto>"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe" -u ORDWEBPRODUSER -h orderica-web-prod-1.chvd5nghosll.us-west-2.rds.amazonaws.com --port 3307 -p
Enter password: ****************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20063
Server version: 5.7.11-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use orderica_jms_management_test
Database changed
mysql> SELECT CASE WHEN (NOT((`Ex`.`S` = 1) AND (`Ex`.`S` IS NOT NULL))) THEN('0X') ELSE ('0X0X') END AS `C1` From (SELECT 1) as `fake` LEFT OUTER JOIN (Select 1 AS `S` FROM `Companies` WHERE FALSE) AS `Ex` on 1 = 1;
+------+
| C1 |
+------+
| 0X0X |
+------+
1 row in set (0.20 sec)
MySQL 5.6 result (it is correct):
C:\Users\vikto>"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe" -u JU_User -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.6.32-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use orderica_jms_management_test
ERROR 1049 (42000): Unknown database 'orderica_jms_management_test'
mysql> use orderica_jms_management
Database changed
mysql> SELECT
-> CASE
-> WHEN (NOT((`Ex`.`S` = 1) AND (`Ex`.`S` IS NOT NULL)))
-> THEN
-> ('0X')
-> ELSE ('0X0X') END AS `C1`
-> From (SELECT 1) as `fake` LEFT OUTER JOIN (Select 1 AS `S` FROM `Companies` WHERE FALSE) AS `Ex` on 1 = 1;
+------+
| C1 |
+------+
| 0X |
+------+
1 row in set (0.01 sec)
mysql>
How to repeat:
SELECT
CASE
WHEN (NOT((`Ex`.`S` = 1) AND (`Ex`.`S` IS NOT NULL)))
THEN
('0X')
ELSE ('0X0X') END AS `C1`
From (SELECT 1) as `fake` LEFT OUTER JOIN (Select 1 AS `S` FROM `Companies` WHERE FALSE) AS `Ex` on 1 = 1;