craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
226 stars 170 forks source link

[4.x]: GQL Query for variant with hasProduct Params return an error #3357

Open aodihis opened 11 months ago

aodihis commented 11 months ago

What happened?

Description

In Commerce 4.3.3 when we do query a variant with hasProduct param it will return an error, which on version before this one is fine. Here is our query and the error message.

query:

{
  variant (hasProduct:{slug:"some-slug"}) {
    id
  }
}

error message:

"SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)"

Steps to reproduce

  1. Query a variant with hasProduct param.

Expected behavior

Will return the variant

Actual behavior

giving an error

Craft CMS version

4.5.13

Craft Commerce version

4.3.3

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

### Tasks
nfourtythree commented 2 months ago

Hi @aodihis

Thank you for your feedback.

We have just tried to replicate this issue on the latest version of Commerce 4.x and everything seems to be working as expected.

CleanShot 2024-09-24 at 12 18 27@2x

Is this still an issue for you?

Thanks

nfourtythree commented 2 months ago

Closing this as stale, please provide any further feedback here and we can re-open the issue and look into it.

Thanks!

rezzart-id commented 1 month ago

Hi @nfourtythree, thank you for your response.

Following up on this issue, our team has continued testing and we've updated Commerce to versions 4.3.3 and higher, including the latest version 4.5.4, but we are still encountering the same error:

Error message:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

However, when downgrading to Commerce 4.3.2, the query works without any issues.

We’ve attached screenshots showing the error in the newer versions and the successful result in 4.3.2 for comparison. It seems the issue persists in all versions starting from 4.3.3.

Image Image

Additionally, here is the complete error response we received:

{
  "errors": [
    {
      "debugMessage": "SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 1320,
          "call": "PDOStatement::execute()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 1186,
          "call": "yii\\db\\Command::internalExecute()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 431,
          "call": "yii\\db\\Command::queryInternal()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Query.php",
          "line": 287,
          "call": "yii\\db\\Command::queryOne()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/db/Query.php",
          "line": 280,
          "call": "yii\\db\\Query::one()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 1672,
          "call": "craft\\db\\Query::one()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/gql/base/ElementResolver.php",
          "line": 41,
          "call": "craft\\elements\\db\\ElementQuery::one()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "craft\\gql\\base\\ElementResolver::resolveOne()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Gql.php",
          "line": 515,
          "call": "GraphQL\\GraphQL::executeQuery()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 195,
          "call": "craft\\services\\Gql::executeQuery()"
        },
        {
          "call": "craft\\controllers\\GraphqlController::actionApi()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "call": "yii\\base\\InlineAction::runWithParams()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "call": "yii\\base\\Controller::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 341,
          "call": "yii\\base\\Module::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 640,
          "call": "craft\\web\\Application::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 303,
          "call": "craft\\web\\Application::_processActionRequest()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "call": "craft\\web\\Application::handleRequest()"
        },
        {
          "file": "/var/www/html/web-cms/index.php",
          "line": 22,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ],
  "data": {
    "variant": null
  }
}

Please let us know if there’s any further information or testing we can assist with to help resolve this.

Thank you.

nfourtythree commented 1 month ago

Hi @aodihis

Thank you for your feedback.

Please try updating to the latest Craft (4.12.6.1) and Commerce (4.6.13) and let me know if the issue persists.

If it does can you please send over a database backup and your composer files to support@craftcms.com, reference this issue and we can take a further look.

Thanks!

aodihis commented 1 month ago

@rezzart-id

rezzart-id commented 1 month ago

Hi @nfourtythree ,

We’ve updated to the latest versions of Craft (4.12.6.1) and Commerce (4.6.13) as suggested, but unfortunately, the issue still persists. The error message remains the same:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)
linear[bot] commented 1 month ago

PT-2231 [4.x]: GQL Query for variant with hasProduct Params return an error

nfourtythree commented 1 month ago

Hi @rezzart-id

Thank you for your message.

Could you please send a database backup and your composer files to support@craftcms.com referencing this issue so we can look into it further.

As, unfortunately, at the moment we are unable to replicate what you are seeing.

Thanks!