{"action":"closed","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/15822","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/15822/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/15822/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/15822/events","html_url":"https://github.com/magento/magento2/issues/15822","id":329352667,"node_id":"MDU6SXNzdWUzMjkzNTI2Njc=","number":15822,"title":"SQL Error: ambiguous column 'customer_group_id' in 'All customers' page in admin when extension attribute table is joined","user":{"login":"Radio","id":196559,"node_id":"MDQ6VXNlcjE5NjU1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/196559?v=4","gravatar_id":"","url":"https://api.github.com/users/Radio","html_url":"https://github.com/Radio","followers_url":"https://api.github.com/users/Radio/followers","following_url":"https://api.github.com/users/Radio/following{/other_user}","gists_url":"https://api.github.com/users/Radio/gists{/gist_id}","starred_url":"https://api.github.com/users/Radio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Radio/subscriptions","organizations_url":"https://api.github.com/users/Radio/orgs","repos_url":"https://api.github.com/users/Radio/repos","events_url":"https://api.github.com/users/Radio/events{/privacy}","received_events_url":"https://api.github.com/users/Radio/received_events","type":"User","site_admin":false},"labels":[{"id":686477444,"node_id":"MDU6TGFiZWw2ODY0Nzc0NDQ=","url":"https://api.github.com/repos/magento/magento2/labels/Fixed%20in%202.2.x","name":"Fixed in 2.2.x","color":"0e8a16","default":false},{"id":688811200,"node_id":"MDU6TGFiZWw2ODg4MTEyMDA=","url":"https://api.github.com/repos/magento/magento2/labels/G1%20Passed","name":"G1 Passed","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-05T08:31:57Z","updated_at":"2018-06-07T07:30:35Z","closed_at":"2018-06-07T07:30:35Z","author_association":"NONE","body":"<!---\r\n    Thank you for contributing to Magento.\r\n    To help us process this issue we recommend that you add the following information:\r\n     - Summary of the issue,\r\n     - Information on your environment,\r\n     - Steps to reproduce,\r\n     - Expected and actual results,\r\n\r\n    Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines\r\n-->\r\n\r\n### Preconditions\r\n<!---\r\n    Please provide as detailed information about your environment as possible.\r\n    For example Magento version, tag, HEAD, PHP & MySQL version, etc..\r\n-->\r\n1. Magento CE 2.2.4 without sample data is installed.\r\n\r\n### Steps to reproduce\r\n<!---\r\n    It is important to provide a set of clear steps to reproduce this bug.\r\n    If relevant please include code samples\r\n-->\r\n1. In a custom module add the following mysql table for storing customer group preferences with one-to-one relation to customer group:\r\n\r\n```\r\nCREATE TABLE `my_customer_group_preference` (\r\n  `customer_group_id` int(10) unsigned NOT NULL,\r\n  `my_attribute` int(10) unsigned NOT NULL,\r\n  PRIMARY KEY (`customer_group_id`),\r\n  CONSTRAINT `FK_CUSTOMER_GROUP_ID` FOREIGN KEY (`customer_group_id`)\r\n        REFERENCES `customer_group` (`customer_group_id`) ON DELETE CASCADE\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer Group Preferences';\r\n```\r\n\r\n2. In a custom module add the following extension attribute to customer group:\r\n\r\n```\r\n<extension_attributes for=\"Magento\\Customer\\Api\\Data\\GroupInterface\">\r\n    <attribute code=\"my_attribute\" type=\"My\\Module\\Api\\Data\\GroupPreferenceDataInterface\">\r\n        <join reference_table=\"my_customer_group_preference\"\r\n              reference_field=\"customer_group_id\"\r\n              join_on_field=\"customer_group_id\">\r\n            <field column=\"my_attribute\">my_attribute</field>\r\n        </join>\r\n    </attribute>\r\n</extension_attributes>\r\n```\r\n\r\n3. Refresh caches\r\n4. Go to `Admin -> Customers -> All Customers` page.\r\n\r\n### Expected result\r\n<!--- Tell us what should happen -->\r\n1. A page is opened normally\r\n\r\n### Actual result\r\n<!--- Tell us what happens instead -->\r\n1. SQL Error happens:\r\n\r\n```\r\nException #0 (Zend_Db_Statement_Exception): SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'customer_group_id' in where clause is ambiguous, query was: SELECT `main_table`.*, `extension_attribute_my_attribute`.`my_attribute` AS `extension_attribute_my_attribute_my_attribute`, `tax_class_table`.* FROM `customer_group` AS `main_table`\r\n LEFT JOIN `my_customer_group_preference` AS `extension_attribute_my_attribute` ON main_table.customer_group_id = extension_attribute_my_attribute.customer_group_id\r\n LEFT JOIN `tax_class` AS `tax_class_table` ON main_table.tax_class_id = tax_class_table.class_id WHERE ((`customer_group_id` != 0)) AND ((`customer_group_id` != 32000)) ORDER BY customer_group_id ASC\r\n```\r\n\r\nThis happens because conditions added by `\\Magento\\Customer\\Model\\GroupManagement::getLoggedInGroups` refer to field `customer_group_id` without the table alias prefix."}}
{"actor":{"display_login":"VladimirZaets"}}