netresearch / dhl-shipping-m2

DHL multi-division shipping extension for Magento 2
Open Software License 3.0
13 stars 4 forks source link

SQL error when querying customer orders with GraphQL #49

Closed deurzen closed 2 years ago

deurzen commented 2 years ago

Hello, I've just installed and configured the 2.7.0 version of your plugin for our Magento 2.4.4 instance. After marking an order as shipped with DHL and adding a tracking number, I'm no longer able to retrieve customer orders over GraphQL. The following simple GraphQL query, for example:

{
  customer {
    orders {
      items {
        items {
          product_name
        }
        shipments {
          tracking {
            carrier
            number
            title
          }
        }
      }
    }
  }
}

results in an "Internal server error." Specifically, the following response is returned:

{
  "errors": [
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 5,
          "column": 9
        }
      ],
      "path": [
        "customer",
        "orders",
        "items",
        0,
        "items",
        0
      ]
    }
  ],
  "data": {
    "customer": {
      "orders": {
        "items": [
          {
            "items": [
              null,
              null,
              null,
              null,
              null
            ],
            "shipments": [
              {
                "tracking": [
                  {
                    "carrier": "dhlpaket",
                    "number": "<THE TRACKING NUMBER I SUPPLIED>",
                    "title": "DHL Paket"
                  }
                ]
              }
            ]
          },
          ... (more orders)
        ]
      }
    }
  }
}

That is, all items within an order are, incorrectly, null. After further inspection, the items array queried through GraphQL under customer -> order -> invoices is also always null. The following error was retrieved from the system logs after performing the above query:

[2022-07-20T00:22:10.303033+00:00] main.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'item_id' in where clause is ambiguous, query was: SELECT `main_table`.*, `extension_attribute_nrshipping_country_of_manufacture`.`country_of_manufacture` AS `extension_attribute_nrshipping_country_of_manufacture_country_of_manufacture`, `extension_attribute_nrshipping_export_description`.`export_description` AS `extension_attribute_nrshipping_export_description_export_description`, `extension_attribute_nrshipping_hs_code`.`hs_code` AS `extension_attribute_nrshipping_hs_code_hs_code` FROM `sales_order_item` AS `main_table`
 LEFT JOIN `nrshipping_order_item` AS `extension_attribute_nrshipping_country_of_manufacture` ON main_table.item_id = extension_attribute_nrshipping_country_of_manufacture.item_id
 LEFT JOIN `nrshipping_order_item` AS `extension_attribute_nrshipping_export_description` ON main_table.item_id = extension_attribute_nrshipping_export_description.item_id
 LEFT JOIN `nrshipping_order_item` AS `extension_attribute_nrshipping_hs_code` ON main_table.item_id = extension_attribute_nrshipping_hs_code.item_id WHERE ((`item_id` IN(108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155)))

Thanks a lot, Max

mam08ixo commented 2 years ago

Thank you for reporting the issue. Confirmed, fix is being prepared.

Sebastian80 commented 2 years ago

Hello, we fixed this issue. Please see https://github.com/netresearch/module-shipping-core/releases/tag/2.8.1 and update the shipping core in your environment.

Best regards, Sebastian E.